Creates a new push-subscription-manager group and an associated
right, manage-all-push-subscriptions. The purpose of this is to
allow privileged accounts to purge expired subscriptions from the
database on behalf of other users. A user with this right will be
permitted to delete any subscription from the DB based on the token
alone. For all other users, deletion requests will be limited to
those associated with the requesting user's central ID.
This right will be granted to a bot account on Metawiki associated
with the Wikimedia push notifications service, and the push
notifications service account will make push subscription delete
requests to the API for subscriptions for which vendor APIs return bad
subscription responses.
Additionally, the providertoken parameter to ApiPushSubscriptionDelete
is updated to allow multiple providertoken values.
Bug: T259148
Change-Id: Ia6c17588ee94e6be74e5e3a75eb33e38f172fc93
Adds statsd counters for events and notifications, both overall and by
type. (Events and notifications have a one-to-many relationship, as
notifications may be created for multiple users per event.)
These are specifically of interest to estimate the potential volume of
notifications to be handled by the new push service.
Bug: T260836
Change-Id: I41974cd30a90c674f56003e15d540a5581d19c7d
1) send apns topic when present in subscription metadata
2) check if subscription metadata is a valid JSON string
3) make epp_id column at echo_push_provider table auto_increment,
otherwise it will fail when trying to add a second row in the table
Bug: T259394
Change-Id: I785435e9f2d4ba9c14977d431d271f0fa2d0c795
array_plus (+=) does a union over keys and does not merge
sequential (integer) keys like array_merge. This probably
broke the "do not notify me of seen notifications" feature.
Use cleaner syntax for query building.
Change-Id: Ie0e8d562aec94060c18eed989bb54a9484ccb5d3
Both styles create the exact same object. Casting an array to an
object creates an stdClass object as well. The main benefit of this
syntax is that there is much less repetition. Everything is one
token instead of individual lines, where each line might contain a
typo.
Change-Id: Id43fa2c4b6bd5d9dbc60008427d4a9e14ae3811c
ParserOptions::setTidy() was already a no-op in MW 1.35, and
Echo already requires MW >= 1.35 in extension.json.
ParserOptions::setTidy() was deprecated in MW 1.35 and will be removed
in a future release.
Bug: T198214
Change-Id: I6a5378a42a6cf035296ad549525c25438803970a
Creates a EchoPushMaxSubscriptionsPerUser config setting (default: 0)
that controls the maximum number of subscriptions a user may associate
with the user's central user ID.
The setting is enforced in EchoPush\SubscriptionManager::create().
To allow creating push subscriptions for development, set
$wgEchoPushMaxSubscriptionsPerUser to a positive integer value in
LocalSettings.php:
$wgEchoPushMaxSubscriptionsPerUser = 10;
Bug: T259150
Change-Id: Ib97b6b6cbb8161dd75dad92c54b4fe4fff80c421
PersonalUrls hooks is not meant to be used to add RL modules,
its documentation says it's meant to "alter the user-specific
navigation links (e.g. "my page, * my talk page, my contributions" etc)."
Echo is already using BeforePageDisplay hook to add modules, let's
now register all our modules via that
Bug: T259872
Change-Id: I12616a9947ea0e574287443361e2180c42e48d4b
The automatic registration for these was broken, because
$wgResourceModules no longer contains Echo's modules (since they are now
registered in extension.json).
Instead, add the test files in tests/qunit/model/ explicitly in
onResourceLoaderTestModules. The tests in tests/qunit/mobile/ are
already added through QUnitTestModule in extension.json.
Delete the ext.echo.overlay tests, they were testing code that was
removed years ago.
Bug: T258818
Change-Id: I7b996dc8631a86033830cf532f1b8e85251788ad
The Revision->RevisionStore migration accidentally injected User
objects for reverted-user-id in two different places at different times.
This doesn't break, because there's backwards compatibility logic that
handles User objects appropriately, but we shouldn't be doing this.
Co-authored-by: Roan Kattouw <roan.kattouw@gmail.com>
Change-Id: I4170c207c3d4fc7f0d869c0b367b53389a70ce80
See https://en.wiktionary.org/wiki/victim
"Reverted user" is more descriptive in any case.
Bug: T254646
Change-Id: I70964850e63cdd832b2cc1799161c480f283d08c
Implement RecentChange_saveHook interface and pass Config via hook handler
declaration in extension.json.
Change-Id: I2bc5950eb6fc066b2f2a83ea84b700d02b075de9
The final iteration of Ie41331f made it clear that ::getTarget()
method of the special page can be null other than User object.
Since we know this we should not make unchecked method call on it.
Bug: T251687
Change-Id: Ib36a6c947b58780171cf5e7343e79d8724414b83
Adds additional job parameters to help diagnose the apparent issue of
jobs being performed twice on Beta.
Bug: T255068
Change-Id: Ib257a24056539487e1110fe286fa4535c3fec94a
It is the notifier implementation's responsibility to check the user's
notification preferences before sending a notification. This adds the
check.
Change-Id: I4b7fd7ea444f5a6db6d79fadb48a440d4fdf0ac9
The nicer approach would be setting the parameter default to [],
but that breaks ApiSandbox.
Bug: T254699
Change-Id: I6c553e27248ff7d6c696f116cb34eb238dade440
Rather than catching all DB errors (and assuming they are duplicate
entry errors), ignore duplicate entry errors and use affectedRows() to
determine whether the subscription already existed.
Change-Id: I4d50cb8222e52cc1a4e1f0fb3f596f36cb565dbb
Finishes the implementation of the stubbed NotificationServiceClient.
Sends push notification request messages to the endpoint configured in
the EchoPushServiceBaseUrl setting. For example, to send messages to an
instance of mediawiki/services/push-notifications running on the host
machine while running MediaWiki in Docker, add the following line to
LocalSettings.php:
$wgEchoPushServiceBaseUrl = 'http://172.17.0.1:8900/v1/message';
Bug: T252899
Change-Id: Icab7825e9080d6b1a4cfc5e12fed1da221ce4610
Updates the push subscription query to retrieve a provider string rather
than only its numeric internal ID.
Change-Id: I910173409e48e8b6a6739d3122165c40b0d52b7f
Provides a basic push notifier implementation. Since the push service is
not yet in place, all it does for now is log debug output when a
notification is to be sent.
To register the push notifier, add the following configuration to
LocalSettings.php:
$wgEchoNotifiers['push'] = [ 'EchoPush\\PushNotifier', 'notifyWithPush' ];
$wgDefaultNotifyTypeAvailability['push'] = true;
$wgNotifyTypeAvailabilityByCategory['system']['push'] = false;
$wgNotifyTypeAvailabilityByCategory['system-noemail']['push'] = false;
We'll register the notifier in configuration for now, rather than
hard-coding the default in extension.json, in order to have control over
when and where it rolls out (beta vs. prod, as well as which wikis).
Since the push notifier implementation depends on jobs being processed
by the job queue, I also recommend adding the following configuration
setting to ensure that all pending jobs are processed at the end of each
web request:
// ensure all pending jobs are processed when a web request completes
$wgJobRunRate = PHP_INT_MAX;
Bug: T252899
Change-Id: Ie7f222443045d30620ff297b006104ef18a074a8
Adds DB tables for storing push subscriptions, some DB interaction code
for retrieving them within MediaWiki, and a set of API modules for
managing them from the outside world.
When testing this patch, be sure to run maintenance/update.php to create
the new tables, and set $wgEchoEnablePush = true in LocalSettings.php
to enable the API new API module.
N.B. The current DB schema is centered on app push subscriptions. Web
push subscriptions require slightly different handling, since they are
provided by browsers as a JSON blob rather than a token string. How to
handle web push subscriptions is a question we can defer until the time
comes to add web push support.
Subscription data is stored in the echo_push_subscription table, with
provider names normalized into the echo_push_provider table. We expect to
be looking up subscriptions by central user ID, so that column is indexed.
The subscription data also includes a column to store SHA256 digests of
the subscriber tokens. This is for use as a unique key constraint, since
we expect every push token to be univerally unique, and the token values
themselves may be too large to reasonably index in MySQL.
Bug: T252899
Change-Id: I3928761b3fba12e54ff4850e9a05c68ec7772f62
Use the globally configured request timeout instead of MultiHttpClient's
hard-coded default. This means that the request timeout for
ForeignWikiRequest will typically be reduced from 900s to 25s.
Bug: T245170
Depends-On: I8252f6c854b98059f4916d5460ea71cf4b580149
Change-Id: I1c3d96720709253ad15bb8528cdd132571de2e4e
* Add a section on the preference form to allow users to mute articles
from generating "page linked" notices
* The preference will save the article title as an article ID
Depends-On: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1
Bug: T46787
Change-Id: I67f751eae5fdc5bccff7fe3047227d432c1cb8d5
DiscussionParser::getUserMentions() returns mentions in an array of the
form [ID => ID]. UserLocator says "we shouldn't receive User instances,
but allow it for backward compatability". But
DiscussionParser::generateEventsForRevision() was putting User objects
into the extra when there is a mention in the edit summary.
I noticed this when I accidentally made User objects be unserializable
in a core patch.
So, I made generateEventsForRevision() generate mention arrays in the
same ID=>ID format as getUserMentions().
Change-Id: I7c6d25950c8887b50426863c7b0a2d5d007559dd
1. Preamble:
Currently Extension:Echo unconditionally suppresses NewMessagesAlert,
because "You have new messages" is replaced by Echo notification.
2. Problem:
Some third-party extensions (such as Extension:Moderation) can use
GetNewMessagesAlert hook to inject their own notification, which must
not be suppressed.
By returning "false" from GetNewMessagesAlert hook, Echo stops those
third-party extensions from showing their notifications too.
3. Solution:
Allow those third-party extension to tell Echo "don't suppress this"
by returning false from the hook EchoCanAbortNewMessagesAlert.
This change has no impact on situations when no such third-party
extensions are installed.
4. How it was handled before this change:
Old solution for those extensions was to remove the hook of Echo from
$wgHooks, which was a dirty hack and is not compatible with T240307.
Change-Id: I433e30c5f639b5f20838804e8fa7c94a4bcf5349
There are cases where we want to vary on $distributionType what is sent.
If it's an email (for example), we might want more information and
context which is unneeded via the web notification.
Bug: T249408
Change-Id: I68cedfa8389e1d935b02ca7475bf42262005d2bc
Loosen check for $wgEchoCluster, because when this hook fires $wgEchoCluster is
set to null (even though extension.json sets it to false as the default).
Bug: T165317
Change-Id: If7f2677a20407612de17a38ac2c6da444377d7b4
There are two counters (ext.echo.unseen and ext.echo.unseen.click) that
are incremented in two different places. It's hard to see how they're
connected unless you know where to look.
Add comments to each of these counters pointing to the other one and
explaining what they're for.
Change-Id: I0699cba85bf797e4f7ef42cc6a7a996aa35510f0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Usage.ForbiddenFunctions.isset
* MediaWiki.Usage.PHPUnitDeprecatedMethods.AssertInternalTypeGeneric
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.
Change-Id: I29416247ff3736799543926813beaf4afd569a6e
This seems strange, because markseen sounds like a write action, but it
writes to the seentime cache rather than the database. For multi-DC
support, we need writes to the seentime cache to happen in the local
data center, and the easiest way to do that is to make it a GET request
rather than a POST request.
It would be nice if marking as seen could be consolidated into the GET
request for fetching notifications, but I didn't do that because the
code for those fetches is pretty complicated, and some fetches (like
polling) should not mark as seen.
Bug: T222851
Change-Id: If4c504a9dc562b1d4e626e155fba8ebb5cdb0579
Allows users to opt out of receiving daily or weekly digests containing notifications
they have already marked as read on the web.
Bug: T169386
Change-Id: Ib47248678f88095492fb6896530be5a9f5bb43ca
Instead of returning false when no links in the user namespace are
found, return an empty array. They're both falsey, but this way we don't
break the type hint in generateMentionEvents(), which is the only thing
that getUserLinks() is used for anyway.
Bug: T239275
Change-Id: I93b320be07cfdae68c5e296b2caa62ea4fae5ff2
Now that seen times are TTL'ed, there is little sense/incentive to set
them in the cache to the default value, since we assume the default
value if they're not in cache (which is being set here). Therefore,
setting them only increases the cache size without any gains.
Bug: T222851
Change-Id: I78a0045e4a53653196114da81c2d60328e78c269
These entries weren't TTLed at all, and so we had millions of records
for inactive users that were being stored forever. If a user doesn't
view their notifications for a year, it's OK for their notifications
badge to go back to the unseen state until they click it.
(The fallback behavior on a cache miss is to act as if the seentime is
the UNIX epoch, which means that any unread notification they have is
more recent than it, and is considered unseen.)
Bug: T222851
Change-Id: I99230d2351b40751a3f2f5123c5f38693120259e
Defaults to MainStash, but can be configured to use a different cache
backend by setting $wgEchoSeenTimeCacheType to a string that keys into
$wgObjectCaches.
Bug: T222851
Change-Id: Ifb935cc8be4618f7794ee79a234fc66d5cc5728a
This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f
relinquishes the responsibility for rendering the Echo notification badge
and wiring up of the related JS.
It makes 3 assumptions:
1) Minerva will expose a VERSION property on the skins.minerva.scripts module
to tell Echo it can begin control of the functionality
2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side
allowing Echo extension to render the Notifications badge in Minerva.
3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or
closed.
All code relating to Echo inside MobileFrontend and Minerva is
moved here.
CSS for the modules is kept in Minerva as skinStyles
This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands.
It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that
substitutes the Minerva badge.
It also watches the export value of skins.minerva.scripts for a VERSION value - when
this appears it will take the signal that it should manage the frontend code.
In the new system the mobile specific code is limited to the mobile version of
Minerva. The desktop version of Echo loads on Minerva desktop - presenting an
opportunity in future to consolidate both implementations to use the same component.
The mobile version of Vector and Timeless for example will load the mobile overlay
(with existing styling issues that we don't need to worry about right now given
we don't officially support skins other than Minerva as mobile)
Testers:
* Check require( 'ext.echo.mobile' )(); inside initMobile
inside ext.echo.init does not fire until
Iba1d7863171268066bf7597182c57a0a2041497f is checked out.
Depends-On: I1a66939d2b596094b419de40b370e79f09c85581
Bug: T221007
Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
Update usages of the variable for the capitalization difference.
Depends-On: I4d289267991f1f9a8e0710ec6ee5a2131306c510
Change-Id: Ie49e898b33765aa0723501be8c0c30622e7cbd2f
As noted in Ic22075bb5e, UserNotificationGatewayTest relies on the presence of
globals. When Ic22075bb5e is merged, UserNotificationGatewayTest will fail in
CI. This patch injects the configuration object into UserNotificationGateway.
Change-Id: I9c15a588a76a41a3ebfb59dac7f0761f756008ff
New preference added so that user can set
* Displaying (n) total unread count in the title
* Displaying notification snippet for incoming notification
Bug: T229732
Change-Id: I35eb68dedf1e087b4668bfec404935f1244b3d0b
There's no real reason for these to be in MakeGlobalVariablesScript
because they don't really depend on the request context: they were being
omitted if the user was not logged in, but we can just check the user's
logged-in status in JS instead.
Bug: T221151
Change-Id: I2df6d7e061545d342bc3068dccd5ce2f6e85fe78
Remove wgEchoMaxNotificationCount and wgEchoPollForUpdates from the
startup module and put them in the ext.echo.init module.
Change-Id: I03f9a3953aa97ead1a29c13a992a02404a6d0b68
The hook (SpecialMuteModifyFormFields) is used to append
the option to mute/unmute echo notifications from a specified user.
Special:Mute handles posting and saving the fields, the only
requirement is that the field name is the same as the property
that wants to be modified, in this case 'echo-notifications-blacklist'
Bug: T220163
Depends-On: I2b3eee0802cb086091f35ecce13ae77a8e7d518d
Change-Id: I77b3ccfdce9b501eb8ecd58c0d7bbecb78029a7e
RevisionRecord::getComment() can return null. When it does, accessing
->text on it fails.
Bug: T226681
Change-Id: I069cd5d5bef51a3e2b8f4e7b50d478cf47f65e00
* MVC is used to change the count of notifications on header icons.
* The Widgets are loaded after 60secs or icon click, whichever occurs first.
Bug: T219222
Change-Id: I2d034a76d5c3abe55894dd1dd10e28713344c5bb
PHP doesn't care much about the name (in terms of case sensitivity)
but I think we should make sure the names of the method should be as
they're in their definition.
Change-Id: I6e38d8be64efaec4200471f2d3007275d7ddecec
Now that OOUI's "alerts" icon pack includes all the icons we need, we can use it and get rid of the badgeicons module.
Bug: T139779
Change-Id: I8218530ed2cdd2d81c1fc24509f36ea2b6742bd9
Follow-up Icfc8516 and I3d997f9 (migrating from deprecated Revision
to RevisionRecord)
When generating 'edit-user-talk' events, if we don't have the section-text,
we use the edit summary instead.
Revision->getComment() returns a string but RevisionRecord->getComment()
returns a CommentStoreComment. As a result of the migration, an instance
of CommentStoreComment was put into the event 'extra_data' and later
added as a plain text params during notification presentation.
This patch proposes to
1) Make sure to add the comment's TEXT to the event
2) Test that the 'section-text' is a string before using it
as a message parameter. This will cause faulty notifications to
render without a body instead of erroring out. We could write a
maintenance script to fix those notifications but I don't
think it's worth it.
Bug: T223741
Change-Id: Ie3a1c59a43b0981ec42fc77e7ebb0e8bd132dbe2
This reverts commit 13956265c1.
The Wikimedia CI jobs running phan were installing mediawiki development
dependencies which might overlap with the dependencies from the
extension. Ultimately phan failed with:
includes/RemoteSchema.php:9
PhanRedefinedInheritedInterface
\RemoteSchema inherits abstract Interface \JsonSerializable declared at
internal:0 which is also declared at
../../vendor/jakub-onderka/php-parallel-lint/src/JsonSerializable.php:4.
This may lead to confusing errors.
If7171a6d46473b0bb05e3adaeb40229e7881c2b6 adjusts the CI configuration
to no more install MediaWiki core development dependencies and solely
relies on mediawiki/vendor.git. That prevents the duplicate interface
definition.
Bug: T223397
Depends-On: If7171a6d46473b0bb05e3adaeb40229e7881c2b6
Change-Id: I794fbffe59104f138802bc6ded1a9d9a58ba9437
Follow up on Icfc85167a636bef95daab2.
Bug: T221163
Depends-On: I31d819f4453032da8deb117254b954fba058e0a3
Change-Id: I3d997f9e8d4bd1566ec6fd8fe2d33be5161458b3
To my knowledge in all the places I'm touching in this patch the new
code is functionally identical to the old one.
Change-Id: I0ffa96d2f9cb9bf932f68b689244051c96c17ad9
Class Revision is deprecated and in this patch, replaces
usage with appropriate classes; RevisionRecord, RevisionStore,
etc.
Bug: T221163
Change-Id: Icfc85167a636bef95daab236ab80113c1a3cf41b
When creating the various notification sources,
the server was indexing them with wfWikiID() but
the client was using wgDBname to find which one
is local and which are remote. On some wikis,
like TWN, wfWikiID() includes a db suffix so
the JS app on Special:Notifications is failing to
find the local source and errors.
Bug: T167336
Change-Id: Id60f723b615fb7db54a6f17b1c1be20dfe98e36c
When deleting echo_notification or echo_email_batch rows, also delete
the corresponding echo_event rows if no other echo_notification rows
or echo_email_batch rows refer to them.
Bug: T221262
Change-Id: I416ff107bd000a0cfac102408c993f8bec2d0286
$wgEchoSectionTransition was introduced when we moved some notification
types between sections (alert, message).
$wgEchoBundleTransition was introduced when we made bundles dynamic
and expandable.
Both flags have been OFF for years and are not needed anymore.
This patch removes all traces of them.
Bug: T140710
Change-Id: I16a5d54b09e71997f80208db6f4fbdb040d03ab1
EventMapper->fetchById() has retry on master built-in but it doesn't
kick in in a Job because the load balancer is a new instance and doesn't
know about previous writes.
This change makes the job always read from master to make
sure the event is found. It is going to write to master
right after anyway.
Bug: T204894
Change-Id: I9a2873234f1dd5416e6c2bedeb904880d1f79562
It was sort of checked in an implicit and roundabout way, in the sense
that the preferences page checks this and forces the relevant
preferences to on or off. But this was difficult to discover, and it's
not clear if this works correctly when defaults change.
Instead, explicitly check whether the requested notify type is available
for the event's category. Also rewrite the entire method to use
array_filter().
Change-Id: I9502a42fc705b2e56ef5edab433f1804f2924359
When pages are deleted or undeleted, their associated
Echo notifications also need to be marked as deleted
or undeleted. This is done by looking up the
echo_target_page table.
With this change, echo_event.event_page_id is also included
in the search. This way, all the events that don't use
target pages are also moderated when needed.
Bug: T217452
Change-Id: I277fca68ce088ab564e76ed9dfb2134ab3be4c4a
When the location on disk of an icon is known,
load its content and turn it into a data uri
for the <img> tag.
Otherwise (when it's only configured with a url),
use the url in the <img> tag.
Bonus: the rasterized icons were a bit blurry
and they are now crisp.
Bug: T55479
Change-Id: I8b5d7f09d8181f22927b8d4712505212ea1a10b1
This trait was using private fields from its host classes
($this->event, $this->language). It created a weird coupling
situation where the host class uses the trait and the trait
uses the host class. Effectively a circular dependency.
Also, phan is complaining about it in
I65ae6adc10941c05a2646e551b1baa829e4e8654
Change-Id: Ib2796b7ca62ecd7ece19583d7ca83e4252a5d878
Do this by default in EventPresentationModel so it automatically works
for all email subject messages.
Update messages to use this parameter. Also update email subject
messages that were trying to use parameters that didn't exist, and fix
message documentation that was completely wrong about what the
parameters were.
Also update translated messages to account for parameter shifts (in many
cases, these messages were using the wrong parameter or a nonexistent
one).
Bug: T219620
Change-Id: Ia420c4db13c95d91e1bfc4c7950942df5858379b
It is already called with a context in SpecialNotifications
Set context on SpecialNotificationsMarkRead and pass title to html form
to pass texts
Change-Id: I24eb85648580ac1a4df5e7587806bad57c141785
Also remove fetchNewestByUserBundleHash() because it's now unused,
and remove the echo_notification_user_hash_timestamp index which
existed specifically to support that function's DB query.
Bug: T143763
Change-Id: I74be8f156bc14d0e189d328953d17dc26cdb697b
This code improvements seeks to improve on code readability, consistency,
maintainability and efficiency.
Change-Id: I4f07886044e9a75824f9e7ddad039f3112b1c4a1
Incrementing user edit count was moved to a deferred update in
I0d6d7ddd91bbb21995142808248d162e05696d47
That causes the notification to lag behind, and the thank you notification is
sent for your first edit on the second, you 10th on the 11th, etc.
This change simply assumes one more edit than the current count unless it is
running from the CLI (this is needed for the test to continue to work).
Since the update job is mergeable, it is possible that a certain value will
be skipped and the notification for it never sent. See task for moe details.
Bug: T209541
Change-Id: Iea61b0f525be25f63f50582933a16a79a52e141f
No longer used in the new bundling system.
Also removes indexes that contain bundle_base.
Bug: T143763
Bug: T131415
Change-Id: Ibf94cdc471a11cb14995fee6a55af0d227b50aa5
By running updateEchoSchemaForSuppression.php as an updater.
The patch-*.sql files already existed, they were added
in 2013(!) by 34fbeaf8c but never applied.
Bug: T136427
Bug: T50059
Change-Id: Ied049681df4bab325f069c3a68cf704ee9a8f2c9
This fixes tests, because EchoHooks has "echo_event.*" which is invalid
with table prefixes, like done in unit tests
Added EchoEvent::selectFields() for future use and to replace more
SELECT *
Bug: T217487
Change-Id: I51cb46812431635d11780633dc7d807cd04f813d
This codebase already used the …::class feature a lot. This is more
about making the code consistent and easier to refactor in the future.
Change-Id: If5b2456b825aae753ed97445160ec191c18df8e3
* preg_match_all already returns the number of matches. We can just use
this number instead of counting it.
* Checking for a strlen() of 0 is a little tooo expressive, because we
don't really care about the actual length of the string.
Change-Id: I0537a7740e5d369b79364f24aecf71c4e8fa7db1
Since the correct transformation method is unclear, change them to plain message keys.
Bug: T211876
Change-Id: I055c089574e7dcf5d634da402290a2ad024126f9
Several links that link to mediawiki.org still use
"http" protocol which isn't a safe protocol. This commit
changes http links that link to mediawiki.org to use
"https" protocol instead.
Bug: T189687
Change-Id: Ie8a8fca4148181c9d1fe4379993aae3aaacf5ed9
Specify which notification types allow notifying the event agent in
$wgEchoNotifications, and stop specifying it in the event_extra data.
Putting 'notifyAgent' => true in event_extra will still work, but is
discouraged.
Change-Id: I4f558654ec23757dd4ecd6986eb3e9a5593f5386
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
Note that the array of matches returned by preg_match changes when
PREG_OFFSET_CAPTURE is set. That's why the additional [0] (for the
match) and [1] (for the offset) are needed.
Bug: T203930
Change-Id: I89f9ea3bef49fe9128fd42805695982f012ecba9
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
Disable some errors related to different members of an array
having different taints, and phan-taint-check conflating them.
Bug: T202383
Change-Id: Ic6c2c5bb7c6092d581e646358d836f55d5cf3222