29 private $watchlistExpiryEnabled;
32 private $watchlistMaxDuration;
38 private function initServices() {
56 if ( !$watchOptions ) {
67 ParamValidator::PARAM_DEFAULT =>
'preferences',
68 ParamValidator::PARAM_TYPE => $watchOptions,
72 if ( $this->watchlistExpiryEnabled ) {
73 $result[
'watchlistexpiry'] = [
74 ParamValidator::PARAM_TYPE =>
'expiry',
75 ExpiryDef::PARAM_MAX => $this->watchlistMaxDuration,
76 ExpiryDef::PARAM_USE_MAX =>
true,
96 ?
string $userOption =
null,
97 ?
string $expiry =
null
100 $this->watchlistManager->setWatch( $value, $user, $page, $expiry );
116 ?
string $userOption =
null
118 $this->initServices();
119 $userWatching = $this->watchlistManager->isWatchedIgnoringRights( $user, $page );
121 switch ( $watchlist ) {
130 if ( $userWatching ) {
134 if ( $user->
isBot() ) {
135 return $userWatching;
138 if ( $userOption ===
null ) {
139 return $this->userOptionsLookup->getBoolOption( $user,
'watchdefault' ) ||
140 ( $this->userOptionsLookup->getBoolOption( $user,
'watchcreations' ) && !$page->
exists() );
144 return $this->userOptionsLookup->getBoolOption( $user, $userOption );
148 return $userWatching;
167 string $userOption =
'watchdefault-expiry'
169 $watchlistExpiry = null;
170 if ( $this->watchlistExpiryEnabled ) {
173 $watchlistExpiry = $params[
'watchlistexpiry'] ??
null;
175 if ( $user && $page && $watchlistExpiry ===
null && $this->watchedItemStore->isWatched( $user, $page ) ) {
179 if ( $user && $watchlistExpiry ===
null ) {
180 $watchlistExpiry = ExpiryDef::normalizeExpiry(
181 $this->userOptionsLookup->getOption( $user, $userOption )
202 $watchedItem = $store->getWatchedItem( $user, $page );
204 if ( $watchedItem ) {
205 $expiry = $watchedItem->getExpiry();
207 if ( $expiry !==
null ) {
217class_alias( ApiWatchlistTrait::class,
'ApiWatchlistTrait' );
if(!defined('MW_SETUP_CALLBACK'))
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...
Interface for objects (potentially) representing an editable wiki page.
exists()
Checks if the page currently exists.