Page MenuHomePhabricator

Watchlist Expiry: Enforce maximum expiry length when watching pages [medium]
Closed, ResolvedPublic

Description

As a Watchlist Expiry user, I want a maximum watch length implemented, so that the watchlist feature can be efficient and manageable from the back-end.

Technical Background: The DBAs have asked us to impose a maximum expiry length for temporarily watched pages, at least until we see how the new table and queries against it perform in wild. Currently, there is no mechanism to enforce a maximum duration. There should probably be a configuration variable for this (e.g. $wgWatchlistExpiryMaxDuration = '6 months'). When I attempt to set an expiry that exceeds this, either through the API or elsewhere, it should show an error message. Watching indefinitely of course will still be permissible.

Product Note: In the future, we may be able to consider the extension of the time period. However, we must first go by the maximum approved by the DBAs (6 months), which we can then test over a period of time after the feature is released.

Acceptance Criteria:

  • Implement a 6-month maximum watch period, so that users cannot exceed the 6-month period when watching pages.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
MusikAnimal renamed this task from [PLACEHOLDER] Enforce maximum expiry length when watching pages to Enforce maximum expiry length when watching pages.Apr 8 2020, 5:50 PM
DannyS712 removed a project: User-DannyS712.
DannyS712 subscribed.
DannyS712 unsubscribed.
ifried renamed this task from Enforce maximum expiry length when watching pages to Watchlist Expiry: Enforce maximum expiry length when watching pages.Apr 9 2020, 4:44 PM
ifried renamed this task from Watchlist Expiry: Enforce maximum expiry length when watching pages to Watchlist Expiry: Enforce maximum expiry length when watching pages [medium].Apr 9 2020, 5:43 PM

@Prtksxna and I discussed the behavior if users try to watch beyond the 6 month maximum via hacky behavior. We prefer that, if the user tries to exceed the 6 month maximum for watched items, the items are automatically set to the permitted maximum temporary watch period (6 months) rather than permanent. This is because the user has explicitly chosen a temporary rather than permanent period, and we should therefore allow the maximum available. The user would then see the 6 months watched in the success message. We would also clarify this behavior in the documentation.

Technical notes from the engineering meeting:

  • Keep WatchedItemStore::addWatchBatchForUser() return value as-is (boolean)
  • Consumers of WatchedItemStore::addWatchBatchForUser() are responsible for disallowing expiries that exceed the maximum, using common logic in WatchedItem class or something.
  • If WatchedItemStore::addWatchBatchForUser() gets an expiry that's too long, it will instead go with the maximum (6 months)
  • API can show a warning, and watch for the maximum.

@DannyS712 Did you want to take this on? Let me know if anything doesn't make sense. I left some technical notes above (T249672#6057433)

Spoke on IRC and decided I'd take this one on.

Change 591203 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[mediawiki/core@master] [WIP] Enforce a maximum watchlist expiry duration

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

Tagging Platform Team Workboards (Clinic Duty Team) as I'm told your help has been offered. If you're able to, we could use some review on https://gerrit.wikimedia.org/r/591203 given it is not a very well known nook of MediaWiki core (specifically the TypeDef stuff). Many thanks!

Change 591203 merged by jenkins-bot:
[mediawiki/core@master] WatchedItemStore: Enforce a maximum watchlist expiry duration

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

Patch merged! I didn't get that logging added yet. Let me know if you think we need it, Krinkle, and I'll make a follow-up patch. No opposition, I just didn't know where to log.

Notes for QA -- the action=watch is the only API that returns a warning when the expiry exceeds the limit (it will be added to other APIs in separate patches). However we're enforcing the maximum duration in the storage layer, so if you put 10 years as the expiry for any API, or trick the web UI to use 10 years, it should be saved as 6 months instead.

dom_walden subscribed.

Re-opening this, as the CommTech team haven't quite finished with it :)

I tested the basic functionality with API:Watch and action=watch:

  • If the expiry value is less than or equal to $wgWatchlistExpiryMaxDuration, page is watched for the expiry length
  • If the expiry value is greater than $wgWatchlistExpiryMaxDuration, the page is watched for the value of the latter (defaults to 6 months)
  • If the expiry is "infinite", the page is watched permanently
  • If there is no expiry value, the page is watched permanently or the expiry value is unchanged (if the page is already being watched)
  • If the value of $wgWatchlistExpiryMaxDuration is null, the expiry value can be any length of time

For API:Watch, if you exceed the maximum value it returns a helpful message of the form:
Given value "7 months" for parameter "expiry" exceeds the maximum of "6 months". Using maximum instead.

This isn't the case for action=watch, which returns the same success message it does now, and silently watches for the maximum amount of time.

Of course, you can extend the expiry period of a temporarily watched page beyond the max duration by watching it again before it expires.

For regression purposes, I set $wgWatchlistExpiry = false and tested some core functionality, including different ways of watching/unwatching pages.

You can set $wgWatchlistExpiryMaxDuration to lots of different types of values, including:

  • relative values like "last Monday"
  • absolute values like "3 June 2020" or even unix timestamps like '@1591094928'

If $wgWatchlistExpiryMaxDuration is an invalid value (such as an invalid date or something that isn't a string), the behaviour appears to be the same as when the value is null (i.e. no limit on expiry length).

When a user inputs an expiry value, if it is not a valid date in English, I believe it gets ignored.

For example, there is an error in the French translations of the expiry values for action=watch, which means any expiry value you put in gets ignored.

@AMooney, should this task be moved back to "In Progress"?

@Naike I wanted to check in to see why you may want to move this to "In Progress." As far as Community Tech is concerned, this work has been completed, but I'll wait to hear from you before marking it as done. Thanks!

As far as Community Tech is concerned, this work has been completed...

@ifried - According to dom, it sounds like the API error part either hasn't been done or doesn't work. From the task description: "When I attempt to set an expiry that exceeds this, either through the API or elsewhere, it should show an error message."

As far as Community Tech is concerned, this work has been completed...

@ifried - According to dom, it sounds like the API error part either hasn't been done or doesn't work. From the task description: "When I attempt to set an expiry that exceeds this, either through the API or elsewhere, it should show an error message."

Oh, sorry, I think I see the confusion. I didn't choose my words very carefully :). When I said action=watch I was referring to the UI (e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Gaspar_de_Santa_Coloma?action=watch). I forgot that action=watch could also refer to the API.

The error message for API has been done. If you set an expiry that exceeds the max, it currently shows a message like: Given value "7 months" for parameter "expiry" exceeds the maximum of "6 months". Using maximum instead.

However, there is no such error message for the UI, which MusikAnimal points out in T249672#6171005. I assume it will be done in another ticket.

Thanks for this information, @dom_walden! I'll be sure to write in the documentation that, if a user tries to somehow exceed the maximum length of 6 months, the page will be watched for 6 months (rather than the longer duration). As for the lack of a message directly in the UI, we'll leave the current behavior for now, since it would be an edge case for a user to exceed the maximum length in the UI. However, we'll monitor feedback upon our pilot release and see if the issue of exceeding the maximum length in the UI commonly arises. I'm marking this work as Done. Thanks!