Page MenuHomePhabricator

Make class WatchAction a real action class and move helper function to own service
Closed, ResolvedPublic

Description

WatchAction::doWatchOrUnwatch needs some services

https://codesearch.wmcloud.org/search/?q=WatchAction&i=nope&files=&repos=

Event Timeline

DannyS712 subscribed.

If WatchAction::doWatchOrUnwatch moves, so should WatchAction::doWatch and WatchAction::doUnwatch
The following services should be injected to the new service:
WatchedItemStore - currently retrieved from MediaWikiServices
PermissionManager - currently retrieved from MediaWikiServices
HookContainer - currently used via Hooks::runner()

The WatchAction methods use calls to User::addWatch and ::removeWatch, which internally use a PermissionManager and a WatchedItemStore. Thus, I would suggest that the new service avoid using the user methods, and instead the user methods be deprecated in favor of calls to the new service.
Alternatively, the code could all be moved into the existing WatchedItemStore

DannyS712 added a subscriber: Pchelolo.

@Pchelolo WatchAction::doWatchOrUnwatch, doWatch, and doUnwatch still have all of the logic - this doesn't appear to have been done

Oh, I resolved it by mistake. Mostly wanted to CC Cindy since she's working on this area.

I should have linked this task from the relevant patches (https://gerrit.wikimedia.org/r/c/mediawiki/core/+/678679 and https://gerrit.wikimedia.org/r/c/mediawiki/core/+/681141). The following were done in those patches:

  • WatchAction::doWatch has been merged with WatchlistManager::addWatch
  • WatchAction::doUnwatch has been merged with WatchlistManager::removeWatch
  • WatchAction::::doWatchOrUnwatch has been moved to WatchlistManager and renamed WatchlistManager::setWatch

I will be working on removing remaining uses of and hard deprecating the methods in WatchAction.

The remaining functions still need to be addressed (I'm not currently working on them, so they're free to be picked up by somebody else if they want):

  • WatchAction::getExpiryOptions
  • WatchAction::getWatchToken

I don't think getExpiryOptions necessarily need to be addressed right away, it's just rendering localized names for possible expiry options, so it's fine to live in WatchAction.

WatchAction::getWatchToken though needs to be hard-deprecated. Should be done after https://gerrit.wikimedia.org/r/c/mediawiki/core/+/697639 is merged.

Change 701161 had a related patch set uploaded (by Vlad.shapik; author: Vlad.shapik):

[mediawiki/core@master] Hard deprecate WatchAction::getWatchToken

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

Change 701161 merged by jenkins-bot:

[mediawiki/core@master] Hard deprecate WatchAction::getWatchToken

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