MediaWiki  master
NoWriteWatchedItemStore.php
Go to the documentation of this file.
1 <?php
25 
31 
35  private $actualStore;
36 
37  private const DB_READONLY_ERROR = 'The watchlist is currently readonly.';
38 
44  $this->actualStore = $actualStore;
45  }
46 
47  public function countWatchedItems( UserIdentity $user ) {
48  return $this->actualStore->countWatchedItems( $user );
49  }
50 
51  public function countWatchers( LinkTarget $target ) {
52  return $this->actualStore->countWatchers( $target );
53  }
54 
55  public function countVisitingWatchers( LinkTarget $target, $threshold ) {
56  return $this->actualStore->countVisitingWatchers( $target, $threshold );
57  }
58 
59  public function countWatchersMultiple( array $targets, array $options = [] ) {
60  return $this->actualStore->countVisitingWatchersMultiple(
61  $targets,
62  $options['minimumWatchers'] ?? null
63  );
64  }
65 
67  array $targetsWithVisitThresholds,
68  $minimumWatchers = null
69  ) {
70  return $this->actualStore->countVisitingWatchersMultiple(
71  $targetsWithVisitThresholds,
72  $minimumWatchers
73  );
74  }
75 
76  public function getWatchedItem( UserIdentity $user, LinkTarget $target ) {
77  return $this->actualStore->getWatchedItem( $user, $target );
78  }
79 
80  public function loadWatchedItem( UserIdentity $user, LinkTarget $target ) {
81  return $this->actualStore->loadWatchedItem( $user, $target );
82  }
83 
84  public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) {
85  return $this->actualStore->getWatchedItemsForUser( $user, $options );
86  }
87 
88  public function isWatched( UserIdentity $user, LinkTarget $target ) {
89  return $this->actualStore->isWatched( $user, $target );
90  }
91 
92  public function isTempWatched( UserIdentity $user, LinkTarget $target ): bool {
93  return $this->actualStore->isTempWatched( $user, $target );
94  }
95 
96  public function getNotificationTimestampsBatch( UserIdentity $user, array $targets ) {
97  return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
98  }
99 
100  public function countUnreadNotifications( UserIdentity $user, $unreadLimit = null ) {
101  return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
102  }
103 
104  public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
105  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
106  }
107 
108  public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
109  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
110  }
111 
112  public function addWatch( UserIdentity $user, LinkTarget $target, ?string $expiry = null ) {
113  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
114  }
115 
116  public function addWatchBatchForUser(
117  UserIdentity $user,
118  array $targets,
119  ?string $expiry = null
120  ) {
121  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
122  }
123 
124  public function removeWatch( UserIdentity $user, LinkTarget $target ) {
125  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
126  }
127 
129  UserIdentity $user,
130  $timestamp,
131  array $targets = []
132  ) {
133  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
134  }
135 
137  UserIdentity $editor, LinkTarget $target, $timestamp
138  ) {
139  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
140  }
141 
142  public function resetAllNotificationTimestampsForUser( UserIdentity $user, $timestamp = null ) {
143  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
144  }
145 
146  public function resetNotificationTimestamp(
147  UserIdentity $user,
149  $force = '',
150  $oldid = 0
151  ) {
152  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
153  }
154 
155  public function clearUserWatchedItems( UserIdentity $user ) {
156  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
157  }
158 
159  public function mustClearWatchedItemsUsingJobQueue( UserIdentity $user ): bool {
160  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
161  }
162 
164  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
165  }
166 
167  public function enqueueWatchlistExpiryJob( float $watchlistPurgeRate ): void {
168  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
169  }
170 
171  public function removeWatchBatchForUser( UserIdentity $user, array $titles ) {
172  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
173  }
174 
176  $timestamp, UserIdentity $user, LinkTarget $target
177  ) {
178  return wfTimestampOrNull( TS_MW, $timestamp );
179  }
180 
181  public function countExpired(): int {
182  return $this->actualStore->countExpired();
183  }
184 
185  public function removeExpired( int $limit, bool $deleteOrphans = false ): void {
186  throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
187  }
188 }
NoWriteWatchedItemStore\isWatched
isWatched(UserIdentity $user, LinkTarget $target)
Must be called separately for Subject & Talk namespaces.
Definition: NoWriteWatchedItemStore.php:88
NoWriteWatchedItemStore\loadWatchedItem
loadWatchedItem(UserIdentity $user, LinkTarget $target)
Loads an item from the db.
Definition: NoWriteWatchedItemStore.php:80
NoWriteWatchedItemStore\clearUserWatchedItems
clearUserWatchedItems(UserIdentity $user)
Synchronously clear the users watchlist.
Definition: NoWriteWatchedItemStore.php:155
NoWriteWatchedItemStore\removeWatchBatchForUser
removeWatchBatchForUser(UserIdentity $user, array $titles)
Definition: NoWriteWatchedItemStore.php:171
NoWriteWatchedItemStore\getWatchedItemsForUser
getWatchedItemsForUser(UserIdentity $user, array $options=[])
Definition: NoWriteWatchedItemStore.php:84
NoWriteWatchedItemStore\resetNotificationTimestamp
resetNotificationTimestamp(UserIdentity $user, LinkTarget $title, $force='', $oldid=0)
Reset the notification timestamp of this entry.
Definition: NoWriteWatchedItemStore.php:146
NoWriteWatchedItemStore\countVisitingWatchers
countVisitingWatchers(LinkTarget $target, $threshold)
Number of page watchers who also visited a "recent" edit.
Definition: NoWriteWatchedItemStore.php:55
NoWriteWatchedItemStore\duplicateEntry
duplicateEntry(LinkTarget $oldTarget, LinkTarget $newTarget)
Check if the given title already is watched by the user, and if so add a watch for the new title.
Definition: NoWriteWatchedItemStore.php:108
NoWriteWatchedItemStore\removeExpired
removeExpired(int $limit, bool $deleteOrphans=false)
Remove some number of expired watchlist items.
Definition: NoWriteWatchedItemStore.php:185
NoWriteWatchedItemStore\resetAllNotificationTimestampsForUser
resetAllNotificationTimestampsForUser(UserIdentity $user, $timestamp=null)
Reset all watchlist notificaton timestamps for a user using the job queue.
Definition: NoWriteWatchedItemStore.php:142
NoWriteWatchedItemStore\mustClearWatchedItemsUsingJobQueue
mustClearWatchedItemsUsingJobQueue(UserIdentity $user)
Does the size of the users watchlist require clearUserWatchedItemsUsingJobQueue() to be used instead ...
Definition: NoWriteWatchedItemStore.php:159
NoWriteWatchedItemStore\duplicateAllAssociatedEntries
duplicateAllAssociatedEntries(LinkTarget $oldTarget, LinkTarget $newTarget)
Check if the given title already is watched by the user, and if so add a watch for the new title.
Definition: NoWriteWatchedItemStore.php:104
NoWriteWatchedItemStore\getNotificationTimestampsBatch
getNotificationTimestampsBatch(UserIdentity $user, array $targets)
Definition: NoWriteWatchedItemStore.php:96
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:32
NoWriteWatchedItemStore\countWatchersMultiple
countWatchersMultiple(array $targets, array $options=[])
Definition: NoWriteWatchedItemStore.php:59
NoWriteWatchedItemStore\__construct
__construct(WatchedItemStoreInterface $actualStore)
Initialy set WatchedItemStore that will be used in cases where writing is not needed.
Definition: NoWriteWatchedItemStore.php:43
NoWriteWatchedItemStore\$actualStore
WatchedItemStoreInterface $actualStore
Definition: NoWriteWatchedItemStore.php:35
NoWriteWatchedItemStore\clearUserWatchedItemsUsingJobQueue
clearUserWatchedItemsUsingJobQueue(UserIdentity $user)
Queues a job that will clear the users watchlist using the Job Queue.
Definition: NoWriteWatchedItemStore.php:163
NoWriteWatchedItemStore\isTempWatched
isTempWatched(UserIdentity $user, LinkTarget $target)
Whether the page is only being watched temporarily (has expiry).
Definition: NoWriteWatchedItemStore.php:92
wfTimestampOrNull
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
Definition: GlobalFunctions.php:1822
$title
$title
Definition: testCompression.php:38
NoWriteWatchedItemStore\DB_READONLY_ERROR
const DB_READONLY_ERROR
Definition: NoWriteWatchedItemStore.php:37
Wikimedia\Rdbms\DBReadOnlyError
Definition: DBReadOnlyError.php:27
NoWriteWatchedItemStore\setNotificationTimestampsForUser
setNotificationTimestampsForUser(UserIdentity $user, $timestamp, array $targets=[])
Definition: NoWriteWatchedItemStore.php:128
NoWriteWatchedItemStore\countWatchedItems
countWatchedItems(UserIdentity $user)
Count the number of individual items that are watched by the user.
Definition: NoWriteWatchedItemStore.php:47
NoWriteWatchedItemStore\updateNotificationTimestamp
updateNotificationTimestamp(UserIdentity $editor, LinkTarget $target, $timestamp)
Definition: NoWriteWatchedItemStore.php:136
NoWriteWatchedItemStore\removeWatch
removeWatch(UserIdentity $user, LinkTarget $target)
Removes an entry for the UserIdentity watching the LinkTarget Must be called separately for Subject &...
Definition: NoWriteWatchedItemStore.php:124
NoWriteWatchedItemStore\getLatestNotificationTimestamp
getLatestNotificationTimestamp( $timestamp, UserIdentity $user, LinkTarget $target)
Convert $timestamp to TS_MW or return null if the page was visited since then by $user.
Definition: NoWriteWatchedItemStore.php:175
NoWriteWatchedItemStore\countWatchers
countWatchers(LinkTarget $target)
Definition: NoWriteWatchedItemStore.php:51
NoWriteWatchedItemStore\countExpired
countExpired()
Get the number of watchlist items that expire before the current time.
Definition: NoWriteWatchedItemStore.php:181
NoWriteWatchedItemStore\countVisitingWatchersMultiple
countVisitingWatchersMultiple(array $targetsWithVisitThresholds, $minimumWatchers=null)
Number of watchers of each page who have visited recent edits to that page.
Definition: NoWriteWatchedItemStore.php:66
NoWriteWatchedItemStore\addWatch
addWatch(UserIdentity $user, LinkTarget $target, ?string $expiry=null)
Must be called separately for Subject & Talk namespaces.
Definition: NoWriteWatchedItemStore.php:112
NoWriteWatchedItemStore\addWatchBatchForUser
addWatchBatchForUser(UserIdentity $user, array $targets, ?string $expiry=null)
Definition: NoWriteWatchedItemStore.php:116
NoWriteWatchedItemStore\enqueueWatchlistExpiryJob
enqueueWatchlistExpiryJob(float $watchlistPurgeRate)
Probabilistically add a job to purge the expired watchlist items.
Definition: NoWriteWatchedItemStore.php:167
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
WatchedItemStoreInterface
Definition: WatchedItemStoreInterface.php:30
NoWriteWatchedItemStore\countUnreadNotifications
countUnreadNotifications(UserIdentity $user, $unreadLimit=null)
Definition: NoWriteWatchedItemStore.php:100
NoWriteWatchedItemStore
Definition: NoWriteWatchedItemStore.php:30
NoWriteWatchedItemStore\getWatchedItem
getWatchedItem(UserIdentity $user, LinkTarget $target)
Get an item (may be cached)
Definition: NoWriteWatchedItemStore.php:76