29 private $watchlistExpiryEnabled;
32 private $watchlistMaxDuration;
37 private function initServices() {
54 if ( !$watchOptions ) {
65 ParamValidator::PARAM_DEFAULT =>
'preferences',
66 ParamValidator::PARAM_TYPE => $watchOptions,
70 if ( $this->watchlistExpiryEnabled ) {
71 $result[
'watchlistexpiry'] = [
72 ParamValidator::PARAM_TYPE =>
'expiry',
73 ExpiryDef::PARAM_MAX => $this->watchlistMaxDuration,
74 ExpiryDef::PARAM_USE_MAX =>
true,
94 ?
string $userOption =
null,
95 ?
string $expiry =
null
98 $this->watchlistManager->setWatch( $value, $user, $page, $expiry );
114 ?
string $userOption =
null
116 $this->initServices();
117 $userWatching = $this->watchlistManager->isWatchedIgnoringRights( $user, $page );
119 switch ( $watchlist ) {
128 if ( $userWatching ) {
132 if ( $user->
isBot() ) {
133 return $userWatching;
136 if ( $userOption ===
null ) {
137 return $this->userOptionsLookup->getBoolOption( $user,
'watchdefault' ) ||
138 ( $this->userOptionsLookup->getBoolOption( $user,
'watchcreations' ) && !$page->
exists() );
142 return $this->userOptionsLookup->getBoolOption( $user, $userOption );
146 return $userWatching;
163 string $userOption =
'watchdefault-expiry'
165 $watchlistExpiry = null;
166 if ( $this->watchlistExpiryEnabled ) {
168 $watchlistExpiry = $params[
'watchlistexpiry'] ??
null;
169 if ( $user && $watchlistExpiry ===
null ) {
170 $watchlistExpiry = ExpiryDef::normalizeExpiry(
171 $this->userOptionsLookup->getOption( $user, $userOption )
173 } elseif ( $watchlistExpiry ===
null ) {
194 $watchedItem = $store->getWatchedItem( $user, $page );
196 if ( $watchedItem ) {
197 $expiry = $watchedItem->getExpiry();
199 if ( $expiry !==
null ) {
209class_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.