Commit graph

47 commits

Author SHA1 Message Date
Michael Holloway 74c1a5bbc7 Collect baseline event and notification stats
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
2020-08-20 13:55:03 -04:00
Thiemo Kreuz 9474b9c942 Remove Phan exceptions reported as unused
Change-Id: I89fa328e8878d64887518a3f49145b19ea599676
2020-08-13 09:25:05 +00:00
jenkins-bot 92e72e9bad Merge "Replace deprecated User::isAllowed with PermissionManager" 2020-03-24 21:00:09 +00:00
DannyS712 1d8170a540 Use lowercase for primitive type 'string'
Change-Id: I7e4a3a198b973cf9037b283253c1e2dda6e8b873
2020-03-20 15:37:50 +00:00
Ammar Abdulhamid ad8340ea59 Replace deprecated User::isAllowed with PermissionManager
Bug: T220191
Change-Id: I321a1d67a9272dfb305d76589c6371176f1afc16
2020-03-14 19:14:37 +00:00
Umherirrender af3fa8a78b Enable MediaWiki.Usage.ForbiddenFunctions.isset and make pass
Change-Id: I4fe47b3cc4ecd124809a58306b6abb0ea202d56a
2020-02-09 11:58:49 +01:00
libraryupgrader ff43e1ecf2 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
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
2020-01-14 05:09:44 +00:00
libraryupgrader ef3d2b886d build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Change-Id: I03333636654eff80d4fe7fa543ac9e6c321af891
2019-12-29 11:59:32 +00:00
Thiemo Kreuz 0efef4faf3 Add strict "array" type hints to code expecting arrays
I found candidates for this by looking for parameters names that end
with a plural "s".

Change-Id: I61c706eb4dfbdadceb0129afd724e6ce1eb4f4a8
2019-10-24 15:18:58 +00:00
libraryupgrader 4bf8a6736a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 24.0.0 → 26.0.0

npm:
* set-value: 2.0.0 → 2.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* union-value: 1.0.0 → 1.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* mixin-deep: 1.3.1 → 1.3.2
  * https://npmjs.com/advisories/1013
  * CVE-2019-10746

Change-Id: I6d3efdf65c207b98447565e2df6f0698aaa8ea6b
2019-07-14 10:57:49 +00:00
Roan Kattouw b31119ea19 Remove unused method EchoEvent::isDismissable()
Change-Id: Ibea0c85cf9dd13cc2b6f22d27e8e3e0b927256c0
2019-05-18 17:37:54 +02:00
jenkins-bot c5ed6315cc Merge "Remove usage of deprecated Revision class in Echo" 2019-05-09 20:56:17 +00:00
Thiemo Kreuz be5919f623 Make use of the PHP 7 ?? operator where it makes sense
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
2019-05-09 15:57:16 +00:00
Derick Alangi 8e5aa13a73 Remove usage of deprecated Revision class in Echo
Class Revision is deprecated and in this patch, replaces
usage with appropriate classes; RevisionRecord, RevisionStore,
etc.

Bug: T221163
Change-Id: Icfc85167a636bef95daab236ab80113c1a3cf41b
2019-05-08 19:50:58 +01:00
Stephane Bisson 61a839315a Use echo_event.event_page_id to find events to moderate
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
2019-04-11 10:48:49 -04:00
Umherirrender c3d0760405 Use php null coalesce operator ??
Change-Id: Icb7d61b0b9040ee08caedef90b4dd2b65d403540
2019-03-12 21:04:00 +01:00
Roan Kattouw b73522549d Migrate and remove event_page_namespace and event_page_title
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
2019-03-04 13:12:52 -08:00
Umherirrender 8ce0cc171d Fix UserMerge integration for use with table prefix
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
2019-03-02 22:05:22 +01:00
Umherirrender cdae062d47 Improve param docs and add @var to clarify types
Change-Id: I44f872b3a2921e75aab8e22fec57735f17ee1d8b
2019-02-15 21:23:02 +01:00
libraryupgrader 5bd2eaf70e build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: Ifd3dde125bae36b1076576ddc0c8b09eadd18a72
2019-02-06 13:01:32 +00:00
jenkins-bot f75d5d120f Merge "Add method scope visibility" 2018-11-02 23:55:06 +00:00
Umherirrender 81183a6d86 Add method scope visibility
Change-Id: Id4fe59155d6e0fa2ef1ccf4dc46ee1f109265246
2018-11-02 18:47:39 +01:00
Roan Kattouw de536d09d9 Make notifyAgent a per-type property rather than per-event
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
2018-10-29 15:41:51 -07:00
jenkins-bot af2b92856f Merge "Fix missing/mismatching type hints PHPDoc tags" 2018-08-16 08:39:29 +00:00
Thiemo Kreuz 2d7096bcff Fix missing/mismatching type hints PHPDoc tags
This fixes some issues I found while updating this code base, e.g.
this removes types a method really does not return.

Change-Id: I19457e7bf88945eec958bf53e0b76a7585715a45
2018-08-16 07:07:20 +00:00
Thiemo Kreuz 8a7c3a78a9 Use "false" as type hint in PHPDoc tags
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
2018-08-13 15:31:13 +00:00
Moriel Schottlender 592bc476b2 Add timestamps to generated notifications
Add the ability to create notifications with specific timestamps
when generating notifications through the maintenance script.

Note, that not all notifications can be given specific timestamp;
only notifications that do not involve a direct editing action
will be given this timestamp and their events will be created
as if the actions were taken at the given timestamp, with
1 minute intervals.

Change-Id: I9e6b8660178ca0734979946c8e6ec8d43fc3de41
2018-06-27 11:16:22 -07:00
Umherirrender dc7d27a795 Split assignment and return statement
Doing it in two lines makes it easier to read
This makes also clear that this is not a broken condition

Change-Id: I9771b6457789b7dc572f2d73d1fae8c361f9a1e6
2018-02-06 22:52:47 +00:00
Chad Horohoe 382d163f95 Remove unstub logic
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
2017-10-03 23:15:51 +00:00
Umherirrender 5b4730c9bc Improve some parameter docs
Change-Id: Ie71fb080926781f2905e6264be060203c56185ea
2017-08-09 17:21:10 +02:00
Umherirrender 79b6f470af build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: I2326cf81e907f2a02615f96f922b66fd2806defd
2017-07-26 21:34:44 +02:00
Chad Horohoe f4a5ad9300 LoggerFactory is now namespaced, reference it properly
Bug: T161837
Change-Id: Ide941dc019163ed09f208caa7a615d1e3483bc91
2017-03-30 12:35:47 -07:00
Roan Kattouw e0ecaad90e Log more info for unserialize failures, and don't treat them as errors
Bug: T159372
Change-Id: I1110465759bd831a9a324bf3f11a3add4f5f446b
2017-03-01 13:02:59 -08:00
James D. Forrester 8c810dff48 build: Update mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I25cb61b3b92798f1259d1575a336e2b056d5764f
2016-12-05 15:54:30 -08:00
Stephane Bisson bc03468473 Actually insert target page entries when creating an Event
This was broken in Ib57510e6b0e9202a7e035f8ea59955dca8a0b24a

Bug: T145232
Change-Id: Ieaad1febaf07bdcf8aee3761afbd039c082fc9ad
2016-09-12 15:05:18 -04:00
Stephane Bisson b3c07eedeb Remove etp_user
Target page entries used to exist for each user
that was notified for an event. They were
removed as the notifications were marked as read.

Now they remain so that the association between
pages and events can be used for moderation
regardless of the notifications read status.

This patch removes everything about
echo_target_page.etp_user from sql and php code.

Bug: T143959
Change-Id: Ib57510e6b0e9202a7e035f8ea59955dca8a0b24a
2016-09-09 09:32:28 -04:00
Stephane Bisson 6e2236db81 Moderate notifications
* When a page is deleted, moderate associated
  notifications. When it is undeleted, unmoderate.

* When a notification cannot be rendered
  (canRender() returns false), moderate it.

The biggest advantage of moderation over mark-read-and-ignore
is that those notifications are filtered out at the database
level from this point on. They are not re-processed every single
time and do not affect the number of notifications returned by
the API.

Bug: T140327
Bug: T140836
Bug: T141463
Change-Id: Idefe78408fd584c13aaa9174cee3055539d92848
2016-08-19 22:20:04 +00:00
Stephane Bisson 24caf50ff6 Dynamic bundles
To allow individual notifications to be
marked as read/unread or moderated,
bundles are created by grouping associated
notifications when they are fetched for display
instead of when they are created.

From a product perspective, this change doesn't
introduce moderation or expandable bundles but
it counts each individual notifications.
For instance, the bundled notification
"3 new topics on PageA" now counts as 3
notifications.

Bug: T93673
Bug: T120153
Change-Id: Iacd098573efd92bb1e3fcd7da4cd40cea9522f15
2016-06-27 09:49:13 -04:00
Kunal Mehta 64127cd815 Avoid exceptions when event_extra can't be unserialized
Check for proper unserialization in EchoEvent::loadFromRow(), and return
false if not possible. Callers were updated to check for a false return.

Bug: T73489
Change-Id: I33867aa9bbbc5f0ecfe0d2a9e1b03eb1a937ae83
2016-05-13 16:39:17 -07:00
Kunal Mehta 5be28ba4df Require a User object to be passed to EchoEvent::userCan()
All callers were already doing this.

Change-Id: If9e20e3d4740bcdb8842592e4cd988f8b35e1300
2015-11-23 16:08:17 -08:00
Aaron Schulz e261aa7593 Make EchoEvent::create() a no-op if the DB is read-only
This seems better for availability than stopping the world
and rolling everything back (or just throwing post-commit
errors that didn't stop the original change anyway).

Change-Id: I816b3cb5f0d26de608e620a01571a332aa832c05
2015-11-02 11:17:05 -08:00
James D. Forrester cd8c77df29 build: Enable phpcs rule 'MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment' and make pass
Change-Id: Ied1a479e6f5aa82d03e449ec10d655a921cd37e4
2015-10-29 13:06:14 +01:00
Kunal Mehta 8cfb10766b SECURITY: Handle suppressed usernames in non-revision based events
We only track revisions for some notification types, others still
reference usernames, but don't check for suppression status. If no
revision is available, use User::isHidden() to check whether
EchoEvent::getAgent() has been hidden.

Bug: T110553
Change-Id: I31e635e365bbb0f6c6ac63be2bdb07e5e2d67c96
2015-10-16 14:56:43 -07:00
Siebrand Mazeland 33126b69aa Update formatting
In preparation of Code Sniffer based updates.

Change-Id: Id5d43332b44a37665d57dc24ef8c432bc65b2f6a
2015-10-03 23:28:54 -04:00
Matthew Flaschen b410f768f9 Document Event methods that can return null
Change-Id: Iecb3ba68ae48924c68781e195557954afd770af3
2015-08-19 15:18:27 -04:00
Kunal Mehta a7c36b0b86 Flip EchoEvent::getUseJobQueue() default
Rather than making each notification type opt-in to using the job queue,
make them opt-out by setting an 'immediate' => true flag.

Configure the 'edit-user-talk' notification type to be immediate since
it should not lag behind the orange bar indicator.

Change-Id: I707bc01a97082887c3f1c353d45cdf1c1eaeff04
2015-07-01 20:36:47 -07:00
Kunal Mehta 9d08c96fad Move all PHP code into includes/
Mainly because I was annoyed at m<tab>o<tab>d<tab>u<tab> to reach
modules/.

Change-Id: Ib149cb2e2612ccddd0503f9d0c5d05b554860a00
2015-06-07 18:54:14 -07:00
Renamed from model/Event.php (Browse further)