MediaWiki  master
NoWriteWatchedItemStore.php
Go to the documentation of this file.
1 <?php
26 
33 
37  private $actualStore;
38 
39  private const DB_READONLY_ERROR = 'The watchlist is currently readonly.';
40 
46  $this->actualStore = $actualStore;
47  }
48 
49  public function countWatchedItems( UserIdentity $user ) {
50  return $this->actualStore->countWatchedItems( $user );
51  }
52 
57  public function countWatchers( $target ) {
58  return $this->actualStore->countWatchers( $target );
59  }
60 
67  public function countVisitingWatchers( $target, $threshold ) {
68  return $this->actualStore->countVisitingWatchers( $target, $threshold );
69  }
70 
79  public function countWatchersMultiple( array $targets, array $options = [] ) {
80  return $this->actualStore->countWatchersMultiple(
81  $targets,
82  $options
83  );
84  }
85 
103  array $targetsWithVisitThresholds,
104  $minimumWatchers = null
105  ) {
106  return $this->actualStore->countVisitingWatchersMultiple(
107  $targetsWithVisitThresholds,
108  $minimumWatchers
109  );
110  }
111 
117  public function getWatchedItem( UserIdentity $user, $target ) {
118  return $this->actualStore->getWatchedItem( $user, $target );
119  }
120 
126  public function loadWatchedItem( UserIdentity $user, $target ) {
127  return $this->actualStore->loadWatchedItem( $user, $target );
128  }
129 
135  public function loadWatchedItemsBatch( UserIdentity $user, array $targets ) {
136  return $this->actualStore->loadWatchedItemsBatch( $user, $targets );
137  }
138 
139  public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) {
140  return $this->actualStore->getWatchedItemsForUser( $user, $options );
141  }
142 
148  public function isWatched( UserIdentity $user, $target ) {
149  return $this->actualStore->isWatched( $user, $target );
150  }
151 
157  public function isTempWatched( UserIdentity $user, $target ): bool {
158  return $this->actualStore->isTempWatched( $user, $target );
159  }
160 
169  public function getNotificationTimestampsBatch( UserIdentity $user, array $targets ) {
170  return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
171  }
172 
173  public function countUnreadNotifications( UserIdentity $user, $unreadLimit = null ) {
174  return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
175  }
176 
181  public function duplicateAllAssociatedEntries( $oldTarget, $newTarget ) {
182  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
183  }
184 
189  public function duplicateEntry( $oldTarget, $newTarget ) {
190  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
191  }
192 
198  public function addWatch( UserIdentity $user, $target, ?string $expiry = null ) {
199  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
200  }
201 
210  public function addWatchBatchForUser(
211  UserIdentity $user,
212  array $targets,
213  ?string $expiry = null
214  ) {
215  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
216  }
217 
223  public function removeWatch( UserIdentity $user, $target ) {
224  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
225  }
226 
235  UserIdentity $user,
236  $timestamp,
237  array $targets = []
238  ) {
239  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
240  }
241 
249  UserIdentity $editor, $target, $timestamp
250  ) {
251  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
252  }
253 
254  public function resetAllNotificationTimestampsForUser( UserIdentity $user, $timestamp = null ) {
255  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
256  }
257 
265  public function resetNotificationTimestamp(
266  UserIdentity $user,
267  $title,
268  $force = '',
269  $oldid = 0
270  ) {
271  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
272  }
273 
274  public function clearUserWatchedItems( UserIdentity $user ) {
275  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
276  }
277 
278  public function mustClearWatchedItemsUsingJobQueue( UserIdentity $user ): bool {
279  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
280  }
281 
283  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
284  }
285 
286  public function maybeEnqueueWatchlistExpiryJob(): void {
287  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
288  }
289 
295  public function removeWatchBatchForUser( UserIdentity $user, array $targets ) {
296  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
297  }
298 
306  $timestamp, UserIdentity $user, $target
307  ) {
308  return wfTimestampOrNull( TS_MW, $timestamp );
309  }
310 
311  public function countExpired(): int {
312  return $this->actualStore->countExpired();
313  }
314 
315  public function removeExpired( int $limit, bool $deleteOrphans = false ): void {
316  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
317  }
318 }
Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition: PageIdentity.php:64
NoWriteWatchedItemStore\getLatestNotificationTimestamp
getLatestNotificationTimestamp( $timestamp, UserIdentity $user, $target)
Definition: NoWriteWatchedItemStore.php:305
NoWriteWatchedItemStore\clearUserWatchedItems
clearUserWatchedItems(UserIdentity $user)
Synchronously clear the users watchlist.
Definition: NoWriteWatchedItemStore.php:274
NoWriteWatchedItemStore\getWatchedItemsForUser
getWatchedItemsForUser(UserIdentity $user, array $options=[])
Definition: NoWriteWatchedItemStore.php:139
NoWriteWatchedItemStore\addWatch
addWatch(UserIdentity $user, $target, ?string $expiry=null)
Definition: NoWriteWatchedItemStore.php:198
NoWriteWatchedItemStore\removeExpired
removeExpired(int $limit, bool $deleteOrphans=false)
Remove some number of expired watchlist items.
Definition: NoWriteWatchedItemStore.php:315
NoWriteWatchedItemStore\resetAllNotificationTimestampsForUser
resetAllNotificationTimestampsForUser(UserIdentity $user, $timestamp=null)
Reset all watchlist notificaton timestamps for a user using the job queue.
Definition: NoWriteWatchedItemStore.php:254
NoWriteWatchedItemStore\mustClearWatchedItemsUsingJobQueue
mustClearWatchedItemsUsingJobQueue(UserIdentity $user)
Does the size of the users watchlist require clearUserWatchedItemsUsingJobQueue() to be used instead ...
Definition: NoWriteWatchedItemStore.php:278
NoWriteWatchedItemStore\getNotificationTimestampsBatch
getNotificationTimestampsBatch(UserIdentity $user, array $targets)
Definition: NoWriteWatchedItemStore.php:169
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
NoWriteWatchedItemStore\isTempWatched
isTempWatched(UserIdentity $user, $target)
Definition: NoWriteWatchedItemStore.php:157
NoWriteWatchedItemStore\countWatchersMultiple
countWatchersMultiple(array $targets, array $options=[])
Definition: NoWriteWatchedItemStore.php:79
NoWriteWatchedItemStore\maybeEnqueueWatchlistExpiryJob
maybeEnqueueWatchlistExpiryJob()
Probabilistically add a job to purge the expired watchlist items, if watchlist expiration is enabled,...
Definition: NoWriteWatchedItemStore.php:286
NoWriteWatchedItemStore\__construct
__construct(WatchedItemStoreInterface $actualStore)
Initially set WatchedItemStore that will be used in cases where writing is not needed.
Definition: NoWriteWatchedItemStore.php:45
NoWriteWatchedItemStore\removeWatch
removeWatch(UserIdentity $user, $target)
Definition: NoWriteWatchedItemStore.php:223
NoWriteWatchedItemStore\$actualStore
WatchedItemStoreInterface $actualStore
Definition: NoWriteWatchedItemStore.php:37
NoWriteWatchedItemStore\clearUserWatchedItemsUsingJobQueue
clearUserWatchedItemsUsingJobQueue(UserIdentity $user)
Queues a job that will clear the users watchlist using the Job Queue.
Definition: NoWriteWatchedItemStore.php:282
NoWriteWatchedItemStore\loadWatchedItem
loadWatchedItem(UserIdentity $user, $target)
Definition: NoWriteWatchedItemStore.php:126
wfTimestampOrNull
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
Definition: GlobalFunctions.php:1665
NoWriteWatchedItemStore\duplicateAllAssociatedEntries
duplicateAllAssociatedEntries( $oldTarget, $newTarget)
Definition: NoWriteWatchedItemStore.php:181
$title
$title
Definition: testCompression.php:38
NoWriteWatchedItemStore\DB_READONLY_ERROR
const DB_READONLY_ERROR
Definition: NoWriteWatchedItemStore.php:39
NoWriteWatchedItemStore\updateNotificationTimestamp
updateNotificationTimestamp(UserIdentity $editor, $target, $timestamp)
Definition: NoWriteWatchedItemStore.php:248
Wikimedia\Rdbms\DBReadOnlyError
Definition: DBReadOnlyError.php:28
NoWriteWatchedItemStore\setNotificationTimestampsForUser
setNotificationTimestampsForUser(UserIdentity $user, $timestamp, array $targets=[])
Definition: NoWriteWatchedItemStore.php:234
NoWriteWatchedItemStore\resetNotificationTimestamp
resetNotificationTimestamp(UserIdentity $user, $title, $force='', $oldid=0)
Definition: NoWriteWatchedItemStore.php:265
NoWriteWatchedItemStore\countWatchedItems
countWatchedItems(UserIdentity $user)
Count the number of individual items that are watched by the user.
Definition: NoWriteWatchedItemStore.php:49
NoWriteWatchedItemStore\loadWatchedItemsBatch
loadWatchedItemsBatch(UserIdentity $user, array $targets)
Definition: NoWriteWatchedItemStore.php:135
NoWriteWatchedItemStore\duplicateEntry
duplicateEntry( $oldTarget, $newTarget)
Definition: NoWriteWatchedItemStore.php:189
NoWriteWatchedItemStore\isWatched
isWatched(UserIdentity $user, $target)
Definition: NoWriteWatchedItemStore.php:148
NoWriteWatchedItemStore\getWatchedItem
getWatchedItem(UserIdentity $user, $target)
Definition: NoWriteWatchedItemStore.php:117
NoWriteWatchedItemStore\countVisitingWatchers
countVisitingWatchers( $target, $threshold)
Definition: NoWriteWatchedItemStore.php:67
NoWriteWatchedItemStore\countExpired
countExpired()
Get the number of watchlist items that expire before the current time.
Definition: NoWriteWatchedItemStore.php:311
NoWriteWatchedItemStore\countWatchers
countWatchers( $target)
Definition: NoWriteWatchedItemStore.php:57
NoWriteWatchedItemStore\countVisitingWatchersMultiple
countVisitingWatchersMultiple(array $targetsWithVisitThresholds, $minimumWatchers=null)
Definition: NoWriteWatchedItemStore.php:102
NoWriteWatchedItemStore\removeWatchBatchForUser
removeWatchBatchForUser(UserIdentity $user, array $targets)
Definition: NoWriteWatchedItemStore.php:295
NoWriteWatchedItemStore\addWatchBatchForUser
addWatchBatchForUser(UserIdentity $user, array $targets, ?string $expiry=null)
Definition: NoWriteWatchedItemStore.php:210
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
WatchedItemStoreInterface
Definition: WatchedItemStoreInterface.php:31
NoWriteWatchedItemStore\countUnreadNotifications
countUnreadNotifications(UserIdentity $user, $unreadLimit=null)
Definition: NoWriteWatchedItemStore.php:173
NoWriteWatchedItemStore
Definition: NoWriteWatchedItemStore.php:32