Commit graph

921 commits

Author SHA1 Message Date
jenkins-bot e23cf162fe Merge "Migrate EchoLocalCache to MapCacheLRU" 2018-08-15 21:45:02 +00:00
Aaron Schulz 4939bff723 Migrate EchoLocalCache to MapCacheLRU
Change-Id: Ie007bc5ec1db4d9686ced724b87f9cbc328aa339
2018-08-15 12:30:51 -07:00
Thiemo Kreuz 63eee2b9a1 Remove two unused properties from AttributeManager
These two properties are protected. I used
https://codesearch.wmflabs.org/search/?q=EchoAttributeManager%5B%5ET%3A%5D
to make sure no subclass exists that might use them.

Change-Id: I37c71db55bc4832968a1812142588dddaa81724a
2018-08-15 09:29:54 +00:00
Thiemo Kreuz e5546e50b6 Add missing strict "array" type hints to DiscussionParser
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
2018-08-15 09:03:33 +00:00
jenkins-bot 15b15adcb3 Merge "Remove $wgEchoNewMsgAlert and 'echo-show-alert' preference" 2018-08-15 01:19:38 +00:00
jenkins-bot 7d305a77d0 Merge "Use ContentLanguage service instead of global $wgContLang" 2018-08-13 23:39:27 +00:00
Fomafix f8341386a0 Replace deprecated Linker::link() with LinkRenderer
Bug: T149346
Change-Id: Icfb0a96735f8f69d73c8d597e6c7b033ca3bcf1f
2018-08-13 23:36:47 +02:00
Fomafix a1f72bbfa0 Use ContentLanguage service instead of global $wgContLang
This change requires MediaWiki 1.32 which is already required in
extension.json.

Change-Id: I61856796d864c9493c1a7a875cb2415f11f081a9
Depends-On: I193f5b9a95430b0a05573c361715e053e5411e32
2018-08-13 23:30:34 +02:00
Paladox bacee60d42 Fix "PHP Warning: count(): Parameter must be an array or an object that implements Countable"
Change-Id: I6169f4226acd41c77d0b4b7710064dce45761bbd
2018-08-13 16:37:44 +00:00
Thiemo Kreuz fc59da2cca Add missing newlines before "use" sections
Change-Id: I15b4aaac007379370f832bc24e3cebfe54dda754
2018-08-13 09:29:32 +02:00
Kunal Mehta b0687600a2 Remove $wgEchoNewMsgAlert and 'echo-show-alert' preference
Unconditionally enable it for all users.

Bug: T58845
Change-Id: Ie3ba685cef8979fe750c449fec01992b32df0fba
2018-08-12 20:25:15 -07:00
Umherirrender dbfcd23b3b Pass correct IContextSource to HTMLForm
The special page is only a MessageLocalizer, not a IContextSource.
Its implements all methods of IContextSource, but are delegated to the
underlayed IContextSource. So pass it directly make phan happy, while
the current code works as expected

Change-Id: Ia9d83f2f71a466a2ba74540f96f165c96fb7ca00
2018-08-11 05:44:52 +00:00
jenkins-bot 96db879275 Merge "NotifUser: Remove basically-unused talk notification cache" 2018-08-10 02:05:21 +00:00
jenkins-bot 66ae28ae4c Merge "UserNotificationGateway: Use batching in markRead() and markUnread()" 2018-08-10 02:02:59 +00:00
Roan Kattouw 06f0a7a6d5 NotifUser: Remove basically-unused talk notification cache
This cache was only used so that, if we're told to clear the newtalk
flag and we already know there are no edit-user-talk notifications, we
won't try to delete them. But that's not a good justification for such a
confusingly-written cache that would have been hard to convert to
getWithSetCallback(), and I'm concerned that using cached data to make
this decision could lead to inconsistencies.

Also remove the notifCountHasReachedMax() check, which made no sense: if
the user has >99 notifications, that is no justification for not marking
their user talk notifications as read when they visit their user talk
page. Whether the displayed notification count will change has no
bearing on whether these notifications should be marked as read (and now
that bundled notifications are counted individually, the displayed count
actually could change).

Bug: T164860
Change-Id: I3ff5c9b31307839b9336bd8856015db9baa52fad
2018-08-09 16:34:04 -07:00
Roan Kattouw a9afcfb43a UserNotificationGateway: Use batching in markRead() and markUnread()
Change-Id: I85452d0f0afe974d26a575e000f6ae2ceeddf06c
2018-08-09 16:34:04 -07:00
jenkins-bot 8151b212ee Merge "Clean up EventLogging integration" 2018-08-09 21:54:37 +00:00
jenkins-bot 2e56ca2d4b Merge "NotificationMapper: Use batching in deleteByUserEventOffset()" 2018-08-09 18:52:07 +00:00
Kunal Mehta b574e252f8 Clean up EventLogging integration
* Move revision ids out of configuration and into MWEchoEventLogging
class. Because the EchoInteraction schema is used both server and
client, we have to duplicate the revision id.
* Use EventLoggingSchemas attribute to register client-side schema in
extension.json instead of a hook.
* Check if EventLogging is enabled in MWEchoEventLogging instead of
$wgExtensionFunctions.
* Pass only whether the EchoInteraction schema is enabled to the
client-side instead of all of $wgEchoEventLoggingSchemas.

Change-Id: I968294f96cedac19dc9d8f53df14fecfb666ceee
2018-08-09 14:19:45 +00:00
Roan Kattouw fe17b49fcd NotificationMapper: Use batching in deleteByUserEventOffset()
Also test it more meaningfully by setting up a mock database and
asserting that the right DELETE queries are issued.

Change-Id: Id39723b92118e98d9c9f0cd7381e9396dce67c17
2018-08-08 14:57:58 -07:00
Kunal Mehta 832d9d4d16 Remove $wgEchoEventLoggingSchemas qunit hack
The only place that reads the config variable is in ext.echo.logger,
which uses OO.getProp() to do so. If that property doesn't exist,
`undefined` will be returned, which we can force to boolean false.

Bug: T118488
Change-Id: Iac352b133950f6f2e4b88950c1fcd0c893284fd9
2018-07-26 19:34:42 -07:00
Kunal Mehta 2f5581c30a Move ext.echo.logger module registration to extension.json
Change-Id: Iec48ff2f2362f5861ee52fde3394a820f9cb2d07
2018-07-26 19:34:42 -07:00
Kunal Mehta 9a828c7b56 Use mw.track() to submit EventLogging data client-side
This avoids needing any dependencies on EventLogging in the module
definition, as well as allowing the extra dependencies to be lazy-loaded
as necessary.

Change-Id: I49b5be4be4f55cd4e27064247463b2ddb8e81296
2018-07-26 19:34:37 -07:00
Kunal Mehta 9f2383a727 Use UserGetDefaultOptions hook instead of $wgExtensionFunctions
$wgExtensionFunctions are run on every MediaWiki request, and should be
avoided unless necessary. Default user options should be controlled by
the UserGetDefaultOptions hook instead.

Bug: T180192
Change-Id: I2a79e078753d289c3ea2f04b613ce72c59a9e59a
2018-07-25 17:19:17 -07:00
Max Semenik f8ef0cc7f5 Get rid of special casing for user blacklist
Makes so many things simpler and robust.

Bug: T198935
Change-Id: Ia836f8f497cae8599f85cf86a7f6b299cd012e81
Depends-On: Iff63da0d215585cfcf083e7f7ec8ed45d5b77301
2018-07-09 15:50:38 -07:00
Thiemo Kreuz 75a55b80ee Remove some non-helpful lines of documentation
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
2018-07-06 15:14:44 +00:00
Stephane Bisson 10a99b016b Handle missing presentation model
When a presentation model is specified for an event type,
check if the class actually exist before trying to use it.
Logs to debug when the class is not specified or doesn't exist.

This is useful for extensions that get undeployed
(looking at you, OpenStackManager). Their notifications
cannot really render since the code to render them
is not available anymore. This make them simply go away and
the notification counts get updated shortly after because
unrenderable notifications are marked as deleted.

Bug: T195253
Change-Id: I6335204942002bba3e73887ab81e55a27b4e181a
2018-07-03 12:49:20 -04:00
jenkins-bot 65470a8d10 Merge "Add timestamps to generated notifications" 2018-06-28 13:09:29 +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
jenkins-bot 855497c3ba Merge "Avoid counting where not necessary" 2018-06-26 13:54:59 +00:00
Thiemo Kreuz cb282251a8 Avoid counting where not necessary
Change-Id: I0abbdced4474dabbdecd3bbfae194e79b7c29db1
2018-06-26 07:10:38 +00:00
jenkins-bot 1c6d589b1b Merge "Remove masterPos from the job specification." 2018-06-25 10:48:16 +00:00
Petr Pchelko bf2cc7e687 Remove masterPos from the job specification.
The `DBMasterPos` class is not JSON-serializable, so
we can not transfer the job in the kafka-based queue.
Before, we were waiting for slaves before executing the
job till the point in time when the job was submitted,
now we will just wait for slaves till the point in time
the job was executed. That lets up not to include the
database master position in the event and make it serializable.

Bug: T192945
Change-Id: I7c754bd1e899bad030cc6434be19daf2542e015f
2018-06-18 19:56:15 +03:00
jenkins-bot 61cfa13beb Merge "Update some PHPDoc tags for improved type safety" 2018-06-18 01:14:37 +00:00
jenkins-bot afec5a19ec Merge "Directly use Language::factory instead of wfGetLangObj" 2018-06-18 01:14:35 +00:00
Thiemo Kreuz 6aa6824f96 Update some PHPDoc tags for improved type safety
Change-Id: I7573ab01e88c86c25180bc56b3874505aa00a047
2018-06-17 19:04:54 +02:00
C. Scott Ananian 190377dbbc Replace uses of deprecated Language::truncate()
See I2291c69d9df17c1a9e4ab1b7d4cbc73bc51d3ebb for the anticipated
hard-deprecation of this method in core.

Bug: T197492
Change-Id: I4687db09c27480147cfa7a648a886b1670812deb
2018-06-16 09:30:06 -04:00
Max Semenik 0a09984f55 Get rid of call_user_func_array()
Yay PHP7!

Change-Id: I3bad8d1a5a65137d9617ccd39c65b8a97edbf01a
2018-06-08 01:03:46 -07:00
Fomafix 99173922c1 Directly use Language::factory instead of wfGetLangObj
Other places like Message::inLanguage also use
Language::factory( $user->getOption( 'language' ) ).

Change-Id: I911dc2319e1922276daa3eb3614a350c80b8b57f
2018-06-05 11:00:14 +02:00
Roan Kattouw d0714b2928 NotifUser: Simplify function signatures for getNotificationCount() and friends
The $cached and $dbSource parameters are now unused, so remove them.
This affects get{Notification,Alert,Message}Count and
getLastUnread{Notification,Alert,Message}Time.

There are some callers in other extensions and in skins, but none of
them pass any parameters (except one, which I fixed in Ice42930280da).

Change-Id: If6f10c4f163ecb1def5a150656a60d1ab5f44d52
2018-06-05 01:07:23 +00:00
jenkins-bot aa984f1b9b Merge "NotifUser: Add a doc comment for getForeignCount()" 2018-06-02 17:20:28 +00:00
jenkins-bot 205c937164 Merge "NotifUser: Simplify timestamp comparisons in getForeignTimestamp() too" 2018-06-02 17:14:01 +00:00
jenkins-bot ffa6922558 Merge "NotifUser: Remove $dbSource parameter from resetNotificationCount()" 2018-06-02 17:11:34 +00:00
jenkins-bot 533a58dfcc Merge "NotifUser: Un-merge getMemcKey() and getGlobalMemcKey()" 2018-06-02 17:11:33 +00:00
jenkins-bot bb453d23e3 Merge "NotifUser: Redo caching strategy for multi-DC compatibility" 2018-06-02 17:10:20 +00:00
Roan Kattouw fa21b7b0cd NotifUser: Un-merge getMemcKey() and getGlobalMemcKey()
We used to have code that called getMemcKey() with a boolean parameter
deciding whether to get a local or global key, but we don't do that
anymore: every code path now knows whether it needs a local or global
key. Consequently, move the code for global cache key generation back to
getGlobalMemcKey(), rather than having both be in getMemcKey() and
getGlobalMemcKey() being a wrapper.

Change-Id: If35bafc53e1e0086c31fd9675a9dc057e36f5717
2018-05-31 16:01:57 -07:00
Roan Kattouw 1fec0793e1 NotifUser: Remove $dbSource parameter from resetNotificationCount()
As Krinkle points out, it always writes to DB_MASTER, so it doesn't make
much sense to offer an option to read from DB_REPLICA. This also
resolves the race condition that I believe arises from the one caller
that passes in DB_REPLICA.

Change-Id: I6976e5479debc3f4a8f28d53b1616c01475772be
2018-05-31 00:53:06 +00:00
Roan Kattouw 0edd96da17 NotifUser: Add a doc comment for getForeignCount()
Change-Id: I47fc2d879b6292d70ba53f8a52f450eed83cfcb6
2018-05-31 00:52:59 +00:00
Roan Kattouw 5935a63731 NotifUser: Simplify timestamp comparisons in getForeignTimestamp() too
Change-Id: I89e75eeded95f7417f8fccfa6274fa19ff5a26c7
2018-05-31 00:52:52 +00:00
Roan Kattouw d90e2d1066 NotifUser: Redo caching strategy for multi-DC compatibility
To use WANObjectCache correctly in a multi-DC-safe way, we need to use
getWithSetCallback() to read data, and call delete() when it changes.
NotifUser's caching of notification counts and timestamps relied
heavily on set() calls, and so wasn't multi-DC-safe.

Changes in this commit:
* Rather than caching counts/timestamps in separate cache keys, and
  using separate cache keys for each section (alert/message/all), put
  all this data in an array and store that in a single cache key.
  This reduces the number of cache keys per user per wiki from 6 to 1.
* Similarly, use a single global cache key per user. The global check
  key for the last updated timestamp is retained, so we now have
  2 global cache keys per user (down from 7)
* Remove preloading using getMulti(), no longer needed
* Move computation of counts and timestamps into separate compute
  functions (one for local, one for global), and wrap them with
  a getter that uses getWithSetCallback().
* Use TS_MW strings instead of MWTimestamp objects internally, to
  simplify comparisons and max() operations.
* Make existing getters wrap around this new getter. They now ignore
  their $cached and $dbSource parameters, and we should deprecate/change
  these function signatures.
* In resetNotificationCounts(), just delete the cache keys. In global
  mode, also recompute the notification counts and put them in the
  echo_unread_wikis table. We could also set() the data into the cache
  at this point, but don't, because you're not supposed to mix set() and
  getWithSetCallback() calls and I don't want to find out what happens
  if you do.

Bug: T164860
Change-Id: I4f86aab11d50d20280a33e0504ba8ad0c6c01842
2018-05-30 17:49:48 -07:00