Page MenuHomePhabricator

Update core watchlist code to support expiries
Closed, ResolvedPublic

Description

After further investigation, it appears the watchlist code is more intertwined than we thought. Many of the core changes will need to happen in the same patch before we can proceed with other backend work.

Classes involved include but are not limited to WatchAction, WatchedItemStoreInterface, and WatchItemStore. Basically we want to introduce the concept of an expiry for a watched item, and handling of it should mimic expiries for blocks and user rights. This will involve some architectural decisions that may need extensive review.

The output of this task is a patch that adds the concept of an expiry to these PHP classes. It may involve some back-and-forth before the architecture is settled on. Once merged, we can proceed with work on the other tasks that will make use of the expiries.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 572107 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[mediawiki/core@master] [WIP] Introduce an expiry to WatchlistItem

https://gerrit.wikimedia.org/r/572107

Change 572107 merged by jenkins-bot:
[mediawiki/core@master] Introduce an expiry to WatchedItem

https://gerrit.wikimedia.org/r/572107

First patch merged! Nothing is user-facing yet; T245565 or T245078 will probably be the first means to test this in-browser. I'll still move this to the QA column in case Dom wants to test the patch locally (you'll need to manually add rows to watchlist_expiry). Otherwise I guess move to product sign-off for now.

@MusikAnimal When I batch delete pages from Special:EditWatchlist (EDIT: also via Special:EditWatchlist/raw), it only deletes the first page selected per namespace.

I can reproduce this on beta, but not on test.

Looking in the logs of my local version, I see (removing watch from pages "Foo" and "Bar"):

[DBQuery] Wikimedia\Rdbms\Database::selectField [0.001s] 127.0.0.1: SELECT  wl_id  FROM `watchlist`    WHERE wl_user = 55 AND wl_namespace = 0 AND wl_title IN ('Bar','Foo')   LIMIT 1  
[DBQuery] WatchedItemStore::removeWatchBatchForUser [0s] 127.0.0.1: DELETE FROM `watchlist` WHERE wl_id = '117'
[DBQuery] Wikimedia\Rdbms\Database::selectField [0.001s] 127.0.0.1: SELECT  wl_id  FROM `watchlist`    WHERE wl_user = 55 AND wl_namespace = 1 AND wl_title IN ('Bar','Foo')   LIMIT 1  
[DBQuery] WatchedItemStore::removeWatchBatchForUser [0s] 127.0.0.1: DELETE FROM `watchlist` WHERE wl_id = '118'

I am guessing LIMIT 1 is not enough.

Change 577301 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[mediawiki/core@master] [WIP] Fixes for batch watchlist deletion and relative expiries

https://gerrit.wikimedia.org/r/577301

Change 577301 merged by jenkins-bot:
[mediawiki/core@master] Fixes for batch watchlist deletion and relative expiries

https://gerrit.wikimedia.org/r/577301

dom_walden added subscribers: ifried, Mooeypoo.

Testing for this mainly focussed on the risk of regression (that watchlist behaviour is effected even when the new feature is disabled).

On beta (https://en.wikipedia.beta.wmflabs.org), I tried to find as many ways to watch and unwatch articles as possible. This included:

  • EditWatchlist
  • EditWatchlistRaw
  • Watch star in article
  • When creating, editing, moving or deleting an article

I compared the behaviour to the documentation I have read so far and my understanding of the purpose of the watch functionality. Also, sometimes comparing to testwiki when unsure.

I did all of this as one regular user. Sometimes admin users have extra options when, for instance, they are moving an article which I did not test.

I had one other regular user who was watching most of the same articles as my test user, just to check that their watchlist was left untouched. It was as far as I could tell.

I haven't tested doing edits, deletes, etc. via the API, but I did test the Move API. It behaved the same on beta as testwiki.

I could not test uploading files (which also watches them), as it is broken on beta.

I haven't tested Special:Watchlist. I don't know if this code change touches it (other than which watched items it fetches notifications for). I did briefly test on my local that notifications for watched articles (e.g. when they are edited) get correctly added/updated/removed in the database.

@ifried There is one issue on my local environment where moved items do not always get their watched status preserved. @MusikAnimal, @Mooeypoo and I discussed this on Slack. This cannot be reproduced on beta. Beta is more like production and hopefully there is just something weird about my local environment, but worth noting that there might be a set of conditions I have missed.

As to the functionality implemented in this task, if you have access to the DB you can add expiry times to watch items. This affects whether they appear in Special:EditWatchlist and Special:EditWatchlist/raw (probably other places, I have not looked closely). When the item is deleted the expiry is deleted (although not always, see T245224#5947415).

There are still things to implement and perhaps some outstanding issues (T245224#5947415). But, because expiries cannot be set on production, and much of the functionality is hidden behind the $wgWatchlistExpiry feature flag, none of this should impact production.

Thanks for this information, @dom_walden! If we cannot reproduce the move issue on beta, we'll keep an eye out for the issue, and we should keep on testing temporary watchlist behavior + moves (in case we see the issue arise again). Your thorough analysis is appreciated. Thanks!

Change 583513 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/core@master] Add release notes for recently-merged watchlist expiry work

https://gerrit.wikimedia.org/r/583513

Change 583513 merged by jenkins-bot:
[mediawiki/core@master] Add release notes for recently-merged watchlist expiry work

https://gerrit.wikimedia.org/r/583513

ifried moved this task from Product sign-off to Done on the Community-Tech (Kanban-2019-20-Q4) board.

This work has been merged, and there is nothing user-facing to test. I'm marking as it as Done.