MediaWiki  master
MediaWiki\Watchlist\WatchlistManager Class Reference

WatchlistManager service. More...

Collaboration diagram for MediaWiki\Watchlist\WatchlistManager:

Public Member Functions

 __construct (ServiceOptions $options, HookContainer $hookContainer, ReadOnlyMode $readOnlyMode, RevisionLookup $revisionLookup, TalkPageNotificationManager $talkPageNotificationManager, WatchedItemStoreInterface $watchedItemStore, UserFactory $userFactory, NamespaceInfo $nsInfo, WikiPageFactory $wikiPageFactory)
 
 addWatch (Authority $performer, PageIdentity $target, ?string $expiry=null)
 Watch a page if the user has permission to edit their watchlist. More...
 
 addWatchIgnoringRights (UserIdentity $userIdentity, PageIdentity $target, ?string $expiry=null)
 Watch a page. More...
 
 clearAllUserNotifications ( $performer)
 Resets all of the given user's page-change notification timestamps. More...
 
 clearTitleUserNotifications ( $performer, $title, int $oldid=0)
 Clear the user's notification timestamp for the given title. More...
 
 getTitleNotificationTimestamp (UserIdentity $user, $title)
 Get the timestamp when this page was updated since the user last saw it. More...
 
 isTempWatched (Authority $performer, PageIdentity $target)
 Check if the page is temporarily watched by the user and the user has permission to view their watchlist. More...
 
 isTempWatchedIgnoringRights (UserIdentity $userIdentity, PageIdentity $target)
 Check if the article is temporarily watched by the user. More...
 
 isWatchable (PageReference $target)
 
 isWatched (Authority $performer, PageIdentity $target)
 Check if the page is watched by the user and the user has permission to view their watchlist. More...
 
 isWatchedIgnoringRights (UserIdentity $userIdentity, PageIdentity $target)
 Check if the page is watched by the user. More...
 
 removeWatch (Authority $performer, PageIdentity $target)
 Stop watching a page if the user has permission to edit their watchlist. More...
 
 removeWatchIgnoringRights (UserIdentity $userIdentity, PageIdentity $target)
 Stop watching a page. More...
 
 setWatch (bool $watch, Authority $performer, PageIdentity $target, string $expiry=null)
 Watch or unwatch a page, calling watch/unwatch hooks as appropriate. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Attributes

HookRunner $hookRunner
 
array $notificationTimestampCache = []
 Cache for getTitleNotificationTimestamp. More...
 
NamespaceInfo $nsInfo
 
ServiceOptions $options
 
ReadOnlyMode $readOnlyMode
 
RevisionLookup $revisionLookup
 
TalkPageNotificationManager $talkPageNotificationManager
 
UserFactory $userFactory
 
WatchedItemStoreInterface $watchedItemStore
 
WikiPageFactory $wikiPageFactory
 

Detailed Description

WatchlistManager service.

Since
1.35

Definition at line 52 of file WatchlistManager.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Watchlist\WatchlistManager::__construct ( ServiceOptions  $options,
HookContainer  $hookContainer,
ReadOnlyMode  $readOnlyMode,
RevisionLookup  $revisionLookup,
TalkPageNotificationManager  $talkPageNotificationManager,
WatchedItemStoreInterface  $watchedItemStore,
UserFactory  $userFactory,
NamespaceInfo  $nsInfo,
WikiPageFactory  $wikiPageFactory 
)

Member Function Documentation

◆ addWatch()

MediaWiki\Watchlist\WatchlistManager::addWatch ( Authority  $performer,
PageIdentity  $target,
?string  $expiry = null 
)

Watch a page if the user has permission to edit their watchlist.

Calls the WatchArticle and WatchArticleComplete hooks.

Since
1.37
Parameters
Authority$performer
PageIdentity$target
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
Returns
StatusValue

Definition at line 446 of file WatchlistManager.php.

References MediaWiki\Watchlist\WatchlistManager\addWatchIgnoringRights(), MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), and User\newFatalPermissionDeniedStatus().

◆ addWatchIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::addWatchIgnoringRights ( UserIdentity  $userIdentity,
PageIdentity  $target,
?string  $expiry = null 
)

Watch a page.

Calls the WatchArticle and WatchArticleComplete hooks.

Since
1.37
Parameters
UserIdentity$userIdentity
PageIdentity$target
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
Returns
StatusValue

Definition at line 406 of file WatchlistManager.php.

References $title, MediaWiki\Watchlist\WatchlistManager\isWatchable(), StatusValue\newFatal(), and StatusValue\newGood().

Referenced by MediaWiki\Watchlist\WatchlistManager\addWatch(), and MediaWiki\Watchlist\WatchlistManager\setWatch().

◆ clearAllUserNotifications()

MediaWiki\Watchlist\WatchlistManager::clearAllUserNotifications (   $performer)

Resets all of the given user's page-change notification timestamps.

If e-notif e-mails are on, they will receive notification mails on the next change of any watched page.

Note
If the user doesn't have 'editmywatchlist', this will do nothing.
Parameters
Authority | UserIdentity$performerdeprecated passing UserIdentity since 1.37

Definition at line 150 of file WatchlistManager.php.

◆ clearTitleUserNotifications()

MediaWiki\Watchlist\WatchlistManager::clearTitleUserNotifications (   $performer,
  $title,
int  $oldid = 0 
)

Clear the user's notification timestamp for the given title.

If e-notif e-mails are on, they will receive notification mails on the next change of the page if it's watched etc.

Note
If the user doesn't have 'editmywatchlist', this will do nothing.
Parameters
Authority | UserIdentity$performerdeprecated passing UserIdentity since 1.37
LinkTarget | PageIdentity$titledeprecated passing LinkTarget since 1.37
int$oldidThe revision id being viewed. If not given or 0, latest revision is assumed.

Definition at line 196 of file WatchlistManager.php.

References MediaWiki\Watchlist\WatchlistManager\$revisionLookup, MediaWiki\Watchlist\WatchlistManager\$talkPageNotificationManager, $title, DeferredUpdates\addCallableUpdate(), MediaWiki\Revision\RevisionLookup\getNextRevision(), MediaWiki\Revision\RevisionLookup\getRevisionById(), if, NS_USER_TALK, MediaWiki\User\TalkPageNotificationManager\removeUserHasNewMessages(), MediaWiki\User\TalkPageNotificationManager\setUserHasNewMessages(), and MediaWiki\User\TalkPageNotificationManager\userHasNewMessages().

◆ getTitleNotificationTimestamp()

MediaWiki\Watchlist\WatchlistManager::getTitleNotificationTimestamp ( UserIdentity  $user,
  $title 
)

Get the timestamp when this page was updated since the user last saw it.

Parameters
UserIdentity$user
LinkTarget | PageIdentity$titledeprecated passing LinkTarget since 1.37
Returns
string|bool|null String timestamp, false if not watched, null if nothing is unseen

Definition at line 295 of file WatchlistManager.php.

References $title, and MediaWiki\User\UserIdentity\getId().

◆ isTempWatched()

MediaWiki\Watchlist\WatchlistManager::isTempWatched ( Authority  $performer,
PageIdentity  $target 
)

Check if the page is temporarily watched by the user and the user has permission to view their watchlist.

Since
1.37
Parameters
Authority$performer
PageIdentity$target
Returns
bool

Definition at line 390 of file WatchlistManager.php.

References MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), and MediaWiki\Watchlist\WatchlistManager\isTempWatchedIgnoringRights().

◆ isTempWatchedIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::isTempWatchedIgnoringRights ( UserIdentity  $userIdentity,
PageIdentity  $target 
)

Check if the article is temporarily watched by the user.

Since
1.37
Parameters
UserIdentity$userIdentity
PageIdentity$target
Returns
bool

Definition at line 375 of file WatchlistManager.php.

References MediaWiki\Watchlist\WatchlistManager\isWatchable().

Referenced by MediaWiki\Watchlist\WatchlistManager\isTempWatched().

◆ isWatchable()

◆ isWatched()

MediaWiki\Watchlist\WatchlistManager::isWatched ( Authority  $performer,
PageIdentity  $target 
)

Check if the page is watched by the user and the user has permission to view their watchlist.

Since
1.37
Parameters
Authority$performer
PageIdentity$target
Returns
bool

Definition at line 361 of file WatchlistManager.php.

References MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), and MediaWiki\Watchlist\WatchlistManager\isWatchedIgnoringRights().

◆ isWatchedIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::isWatchedIgnoringRights ( UserIdentity  $userIdentity,
PageIdentity  $target 
)

Check if the page is watched by the user.

Since
1.37
Parameters
UserIdentity$userIdentity
PageIdentity$target
Returns
bool

Definition at line 346 of file WatchlistManager.php.

References MediaWiki\Watchlist\WatchlistManager\isWatchable().

Referenced by MediaWiki\Watchlist\WatchlistManager\isWatched().

◆ removeWatch()

MediaWiki\Watchlist\WatchlistManager::removeWatch ( Authority  $performer,
PageIdentity  $target 
)

Stop watching a page if the user has permission to edit their watchlist.

Calls the UnwatchArticle and UnwatchArticleComplete hooks.

Since
1.37
Parameters
Authority$performer
PageIdentity$target
Returns
StatusValue

Definition at line 503 of file WatchlistManager.php.

References MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), User\newFatalPermissionDeniedStatus(), and MediaWiki\Watchlist\WatchlistManager\removeWatchIgnoringRights().

Referenced by MediaWiki\Watchlist\WatchlistManager\setWatch().

◆ removeWatchIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::removeWatchIgnoringRights ( UserIdentity  $userIdentity,
PageIdentity  $target 
)

Stop watching a page.

Calls the UnwatchArticle and UnwatchArticleComplete hooks.

Since
1.37
Parameters
UserIdentity$userIdentity
PageIdentity$target
Returns
StatusValue

Definition at line 466 of file WatchlistManager.php.

References $title, MediaWiki\Watchlist\WatchlistManager\isWatchable(), StatusValue\newFatal(), and StatusValue\newGood().

Referenced by MediaWiki\Watchlist\WatchlistManager\removeWatch().

◆ setWatch()

MediaWiki\Watchlist\WatchlistManager::setWatch ( bool  $watch,
Authority  $performer,
PageIdentity  $target,
string  $expiry = null 
)

Watch or unwatch a page, calling watch/unwatch hooks as appropriate.

Checks before watching or unwatching to see if the page is already in the requested watch state and if the expiry is the same so it does not act unnecessarily.

Parameters
bool$watchWhether to watch or unwatch the page
Authority$performerwho is watching/unwatching
PageIdentity$targetPage to watch/unwatch
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
Returns
StatusValue
Since
1.37

Definition at line 528 of file WatchlistManager.php.

References MediaWiki\Watchlist\WatchlistManager\addWatchIgnoringRights(), MediaWiki\Permissions\Authority\getUser(), TitleValue\newFromPage(), StatusValue\newGood(), Wikimedia\ParamValidator\TypeDef\ExpiryDef\normalizeExpiry(), and MediaWiki\Watchlist\WatchlistManager\removeWatch().

Member Data Documentation

◆ $hookRunner

HookRunner MediaWiki\Watchlist\WatchlistManager::$hookRunner
private

Definition at line 66 of file WatchlistManager.php.

◆ $notificationTimestampCache

array MediaWiki\Watchlist\WatchlistManager::$notificationTimestampCache = []
private

Cache for getTitleNotificationTimestamp.

Keys need to reflect both the specific user and the title:

Since only users have watchlists, the user is represented with u⧼user id⧽

Since the method accepts LinkTarget objects, cannot rely on the object's toString, since it is different for TitleValue and Title. Implement a simplified string representation of the string that TitleValue uses: ⧼namespace number⧽:⧼db key⧽

Entries are in the form of u⧼user id⧽-⧼namespace number⧽:⧼db key⧽ => ⧼timestamp or false⧽

Definition at line 105 of file WatchlistManager.php.

◆ $nsInfo

NamespaceInfo MediaWiki\Watchlist\WatchlistManager::$nsInfo
private

◆ $options

ServiceOptions MediaWiki\Watchlist\WatchlistManager::$options
private

◆ $readOnlyMode

ReadOnlyMode MediaWiki\Watchlist\WatchlistManager::$readOnlyMode
private

◆ $revisionLookup

RevisionLookup MediaWiki\Watchlist\WatchlistManager::$revisionLookup
private

◆ $talkPageNotificationManager

TalkPageNotificationManager MediaWiki\Watchlist\WatchlistManager::$talkPageNotificationManager
private

◆ $userFactory

UserFactory MediaWiki\Watchlist\WatchlistManager::$userFactory
private

◆ $watchedItemStore

WatchedItemStoreInterface MediaWiki\Watchlist\WatchlistManager::$watchedItemStore
private

◆ $wikiPageFactory

WikiPageFactory MediaWiki\Watchlist\WatchlistManager::$wikiPageFactory
private

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Watchlist\WatchlistManager::CONSTRUCTOR_OPTIONS
Initial value:
= [
'UseEnotif',
'ShowUpdatedMarker',
]
Access: internal
For use by ServiceWiring

Definition at line 57 of file WatchlistManager.php.


The documentation for this class was generated from the following file: