I found this code while looking for possibly problematic count()s.
I noticed the line "$user = $pageData['revisions'][0]…", which means
the code assumes element [0] is always there. Therefore I droped the
"count() == 1" check.
The other count() got replaced with an isset().
Change-Id: Ic582c85d07db0cbed56512e3e381120b628f2288
These are updated in deferred updates and should not rely on the same
User instance being used in those updates. This also avoids convoluted
logic in User to set the new edit count for various cases.
Change-Id: I0ad3d17107efc7b0e59f1dd54d5733cd1572a2b7
For the algorithms in question this does not make any difference. Excess
elements are thrown away anyway. This is for performance.
Change-Id: I645e389b3f993bc8015fd729b9302aa25471f833
If all the code needs to know is if an array is empty or not, using
count() creates more confusion than anything.
Change-Id: I253308505fe5af5b5c56d85169789271967298ba
Some Echo events include 'revid' in their extra info.
It can be used to check if a revision is minor in order
to respect the 'enotifminoredits' preference.
This patch ensures that it is not trying to call a function on
a null revision reference and it logs to debug to help
troubleshooting.
Also encapsulate the "is minor" check to a private function
to (hopefully) make the relationship with the preference
more clear.
Bug: T204795
Change-Id: I28a4c54f610dccc1356f6af0de9c2623d7bf94f0
See, this last part of the compiled regular expression is wrapped in
an (…)*, which means it is entirely optional. It does not make any
difference if this part is found or not. The compiled regular
expression matches with or without any of these "line ending"
fragments being present.
I can not really figure out what the intention of this was. A line
ending anchor ($) is not missing – I'm pretty sure about this.
Otherwise it could not detect signatures that are wrapped in more
than a single HTML tag, for example.
Instead of fixing it I decided to remove it. The tests should show
this code was not needed.
The motivation for this patch is to improve performance. This part of
the regular expression is quite heavy and can cause a lot of
backtracking for literally zero benefit.
Bug: T203930
Bug: T204291
Change-Id: Ia5323b401b947edeb7094d7eec131ba6c80edf70
\h matches only horizontal whitespace, but no newlines. This is what
we want in all these cases, because nothing of this (headlines,
signatures, timestamps) is even allowed to span multiple lines in
wikitext. The tests should show this still succeeds.
The idea is to make these regular expressions more strict so they
don't run in so much expensive backtracking.
Bug: T203930
Bug: T204291
Change-Id: I805f8cb082edcd26713ef41d3ae5b61194c131e5
In double quoted strings PHP tries to understand all kinds of escape
sequences, but \A is not one of them. Such sequences are left untouched,
including the backslash.
In single quoted strings, there are no escape sequences. All are left
untouched, which is what we want in case of a regular expression.
TL;DR: The resulting string is the same in both cases. I'm touching this
because my IDE shows a warning about the unknown \A escape sequence.
It must be either turned into "\\A" or '\A'.
Change-Id: Ie1e84c67c344faf77bc86a0b28dc82d31c3a7dbe
false ?? null evaluates to false, so for non-write modules we were
passing false as the token type instead of null, which breaks.
Bug: T204758
Change-Id: Ief25150ce8f4b4b64a224f97f3fd528883b2f326