3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 namespace MediaWiki\Watchlist
;
24 use MediaWiki\User\UserIdentity
;
25 use Wikimedia\Rdbms\DBReadOnlyError
;
30 * @phan-file-suppress PhanPluginNeverReturnMethod
32 class NoWriteWatchedItemStore
implements WatchedItemStoreInterface
{
34 private WatchedItemStoreInterface
$actualStore;
36 private const DB_READONLY_ERROR
= 'The watchlist is currently readonly.';
39 * Initially set WatchedItemStore that will be used in cases where writing is not needed.
41 public function __construct( WatchedItemStoreInterface
$actualStore ) {
42 $this->actualStore
= $actualStore;
46 public function countWatchedItems( UserIdentity
$user ) {
47 return $this->actualStore
->countWatchedItems( $user );
51 public function countWatchers( $target ) {
52 return $this->actualStore
->countWatchers( $target );
56 public function countVisitingWatchers( $target, $threshold ) {
57 return $this->actualStore
->countVisitingWatchers( $target, $threshold );
61 public function countWatchersMultiple( array $targets, array $options = [] ) {
62 return $this->actualStore
->countWatchersMultiple(
69 public function countVisitingWatchersMultiple(
70 array $targetsWithVisitThresholds,
71 $minimumWatchers = null
73 return $this->actualStore
->countVisitingWatchersMultiple(
74 $targetsWithVisitThresholds,
80 public function getWatchedItem( UserIdentity
$user, $target ) {
81 return $this->actualStore
->getWatchedItem( $user, $target );
85 public function loadWatchedItem( UserIdentity
$user, $target ) {
86 return $this->actualStore
->loadWatchedItem( $user, $target );
90 public function loadWatchedItemsBatch( UserIdentity
$user, array $targets ) {
91 return $this->actualStore
->loadWatchedItemsBatch( $user, $targets );
95 public function getWatchedItemsForUser( UserIdentity
$user, array $options = [] ) {
96 return $this->actualStore
->getWatchedItemsForUser( $user, $options );
100 public function isWatched( UserIdentity
$user, $target ) {
101 return $this->actualStore
->isWatched( $user, $target );
105 public function isTempWatched( UserIdentity
$user, $target ): bool {
106 return $this->actualStore
->isTempWatched( $user, $target );
110 public function getNotificationTimestampsBatch( UserIdentity
$user, array $targets ) {
111 return $this->actualStore
->getNotificationTimestampsBatch( $user, $targets );
115 public function countUnreadNotifications( UserIdentity
$user, $unreadLimit = null ) {
116 return $this->actualStore
->countUnreadNotifications( $user, $unreadLimit );
120 public function duplicateAllAssociatedEntries( $oldTarget, $newTarget ) {
121 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
125 public function duplicateEntry( $oldTarget, $newTarget ) {
126 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
130 public function addWatch( UserIdentity
$user, $target, ?
string $expiry = null ) {
131 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
135 public function addWatchBatchForUser(
138 ?
string $expiry = null
140 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
144 public function removeWatch( UserIdentity
$user, $target ) {
145 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
149 public function setNotificationTimestampsForUser(
154 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
158 public function updateNotificationTimestamp(
159 UserIdentity
$editor, $target, $timestamp
161 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
165 public function resetAllNotificationTimestampsForUser( UserIdentity
$user, $timestamp = null ) {
166 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
170 public function resetNotificationTimestamp(
176 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
180 public function clearUserWatchedItems( UserIdentity
$user ) {
181 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
185 public function mustClearWatchedItemsUsingJobQueue( UserIdentity
$user ): bool {
186 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
190 public function clearUserWatchedItemsUsingJobQueue( UserIdentity
$user ) {
191 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
195 public function maybeEnqueueWatchlistExpiryJob(): void
{
196 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
200 public function removeWatchBatchForUser( UserIdentity
$user, array $targets ) {
201 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
205 public function getLatestNotificationTimestamp(
206 $timestamp, UserIdentity
$user, $target
208 return wfTimestampOrNull( TS_MW
, $timestamp );
212 public function countExpired(): int {
213 return $this->actualStore
->countExpired();
217 public function removeExpired( int $limit, bool $deleteOrphans = false ): void
{
218 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
221 /** @deprecated class alias since 1.43 */
222 class_alias( NoWriteWatchedItemStore
::class, 'NoWriteWatchedItemStore' );