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
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
This patch adds a few strict type hints on the language level, not
only on the PHPDoc level as my other patches do.
Change-Id: Ie66f9ebf80317dcaf13e2e96a93332a1a93cebbe
This change requires MediaWiki 1.32 which is already required in
extension.json.
Change-Id: I61856796d864c9493c1a7a875cb2415f11f081a9
Depends-On: I193f5b9a95430b0a05573c361715e053e5411e32
Most modern IDEs as well as documentation generators understand the
keywords "false" and "true", when a bool can only be one of the two.
Change-Id: I83dd1f0cc0802fa74ee35e7ca7425615230a767f
There are about 200 of such generic "array" type hints in this code base,
the majority in @param tags. I started with what I found most relevant:
@var and @return tags. I might continue working on this later, but
wanted to stop for now to keep this patch moderately small.
Change-Id: Iff0d9590a794ae0f885466ef6bb336b0b42a6cd3
Tested with the quick preview (Ctrl+Q) feature in PHPStorm.
I'm also updating a few type hints I could not split off into a separate
patch, because the lines are to close to each other.
Change-Id: I312ec601a5f443c2b12515e34c574b8889c4c128
Explaining that a variable named "$username" contains a "username" is
not helpful. One have to read this comment first to understand that it
does not add anything to what's already obvious from the variable name
and the type.
Change-Id: I9a43866498d0c94422caf16233f502320a8e36c9
See I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb for the anticipated
hard-deprecation of this method in core.
Bug: T197492
Change-Id: I4687db09c27480147cfa7a648a886b1670812deb
See MediaWiki core change Ied5fe1a61. There's no need for a dependency
here, though, since it'll just ignore the extra parameter.
Change-Id: Iff28b00638c15de7307a130196bbb91cda91c3d1
User objects haven't been stubbed in awhile, and language objects
aren't being stubbed anymore.
While we're here, swap a few MWException -> InvalidArgumentException
since they're more accurate :)
Change-Id: I7e2f2aa135b024fb653c3ec13181d7015383ff2f
The latter doesn't trim(), so add trim() calls in some cases.
User input is trimmed, parsed i18n messages are not.
Change-Id: I933a6a929bf7d3e2d1623ea537227dc8c731cb6f
When content is changed and the change contains the signature
of the user, the method checking for reasonable mentions in
that changes did not consider multiple signatures.
The patch fixes that and adds a test for it.
Bug: T154406
Change-Id: I86303f42e97d16c68e3235b0e2d13542ceedf1fe
This sends out a notification when a user gets mentioned in a change as
long as a signature is added in the same section.
Bug: T138938
Change-Id: Ie183fbb8150bd9451a5b0a9fea0227e3241b26a0
This patch fixes mentions not being send when multiple sections were added
in between sections.
Since we only want to send mentions when userlinks and signature are present
in the same section a new method was added extracting sections and the related
content from an addition. The results are checked whether a section content
contains a signature and might be relevant for mentions.
Bug: T141863
Change-Id: I434c664552bbadbeef6e897e20703e813f5a4c52
This logs whenever a user gets mentioned in a change as
long as a signature is added in the same edit.
Bug: T138938
Change-Id: I2a775d1dcac6a947b353c8bd2f7be70b6384641f
This patch logs multiple section edits that could trigger mentions.
Since we only want to send mentions when userlinks and signature are present
in the same section a new method was added extracting sections and the related
content from an addition. The results are checked whether a section content
contains a signature and might be relevant for mentions.
Bug: T141863
Change-Id: Ib06cd855b2c7fbd51d8ab6602882cb38aadf8350
While manual rebasing the bundle patch the wrong
line was removed.
Also improves tests to check for notifyAgent.
See I1069aeb5523db8710da4e8e21065bf447d031e3c
Change-Id: I33ddeccea153d6f6ae97e5c60e8b47dc24fb4833
Adds common bundling including messages and icons.
Bundling relates to revision now.
Changed order how notifications are generated. Now errors will
show first, since they are generated last.
Bug: T140224
Change-Id: I1069aeb5523db8710da4e8e21065bf447d031e3c
This will allow us to:
1) Fix a bug involving showing the sig in the snippets
of mentions (Something catrope mentioned to me but
I do not know of a bug number for it)
2) Send more accurate sameUser failure metrics to
graphite as signature links would never be counted
as a mention
Change-Id: I33677012673ae6e4665aaaf59d4f350602f7276a