Merge "Update searchdisabled message with docs and better link target"
[mediawiki.git] / includes / watchlist / NoWriteWatchedItemStore.php
blob2d2c3db81f8819ad0aa6da8e0a3fe34381421ea6
1 <?php
2 /**
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
18 * @file
19 * @ingroup Watchlist
22 namespace MediaWiki\Watchlist;
24 use MediaWiki\User\UserIdentity;
25 use Wikimedia\Rdbms\DBReadOnlyError;
27 /**
28 * @internal
29 * @since 1.31
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.';
38 /**
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;
45 /** @inheritDoc */
46 public function countWatchedItems( UserIdentity $user ) {
47 return $this->actualStore->countWatchedItems( $user );
50 /** @inheritDoc */
51 public function countWatchers( $target ) {
52 return $this->actualStore->countWatchers( $target );
55 /** @inheritDoc */
56 public function countVisitingWatchers( $target, $threshold ) {
57 return $this->actualStore->countVisitingWatchers( $target, $threshold );
60 /** @inheritDoc */
61 public function countWatchersMultiple( array $targets, array $options = [] ) {
62 return $this->actualStore->countWatchersMultiple(
63 $targets,
64 $options
68 /** @inheritDoc */
69 public function countVisitingWatchersMultiple(
70 array $targetsWithVisitThresholds,
71 $minimumWatchers = null
72 ) {
73 return $this->actualStore->countVisitingWatchersMultiple(
74 $targetsWithVisitThresholds,
75 $minimumWatchers
79 /** @inheritDoc */
80 public function getWatchedItem( UserIdentity $user, $target ) {
81 return $this->actualStore->getWatchedItem( $user, $target );
84 /** @inheritDoc */
85 public function loadWatchedItem( UserIdentity $user, $target ) {
86 return $this->actualStore->loadWatchedItem( $user, $target );
89 /** @inheritDoc */
90 public function loadWatchedItemsBatch( UserIdentity $user, array $targets ) {
91 return $this->actualStore->loadWatchedItemsBatch( $user, $targets );
94 /** @inheritDoc */
95 public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) {
96 return $this->actualStore->getWatchedItemsForUser( $user, $options );
99 /** @inheritDoc */
100 public function isWatched( UserIdentity $user, $target ) {
101 return $this->actualStore->isWatched( $user, $target );
104 /** @inheritDoc */
105 public function isTempWatched( UserIdentity $user, $target ): bool {
106 return $this->actualStore->isTempWatched( $user, $target );
109 /** @inheritDoc */
110 public function getNotificationTimestampsBatch( UserIdentity $user, array $targets ) {
111 return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
114 /** @inheritDoc */
115 public function countUnreadNotifications( UserIdentity $user, $unreadLimit = null ) {
116 return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
119 /** @inheritDoc */
120 public function duplicateAllAssociatedEntries( $oldTarget, $newTarget ) {
121 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
124 /** @inheritDoc */
125 public function duplicateEntry( $oldTarget, $newTarget ) {
126 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
129 /** @inheritDoc */
130 public function addWatch( UserIdentity $user, $target, ?string $expiry = null ) {
131 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
134 /** @inheritDoc */
135 public function addWatchBatchForUser(
136 UserIdentity $user,
137 array $targets,
138 ?string $expiry = null
140 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
143 /** @inheritDoc */
144 public function removeWatch( UserIdentity $user, $target ) {
145 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
148 /** @inheritDoc */
149 public function setNotificationTimestampsForUser(
150 UserIdentity $user,
151 $timestamp,
152 array $targets = []
154 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
157 /** @inheritDoc */
158 public function updateNotificationTimestamp(
159 UserIdentity $editor, $target, $timestamp
161 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
164 /** @inheritDoc */
165 public function resetAllNotificationTimestampsForUser( UserIdentity $user, $timestamp = null ) {
166 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
169 /** @inheritDoc */
170 public function resetNotificationTimestamp(
171 UserIdentity $user,
172 $title,
173 $force = '',
174 $oldid = 0
176 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
179 /** @inheritDoc */
180 public function clearUserWatchedItems( UserIdentity $user ) {
181 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
184 /** @inheritDoc */
185 public function mustClearWatchedItemsUsingJobQueue( UserIdentity $user ): bool {
186 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
189 /** @inheritDoc */
190 public function clearUserWatchedItemsUsingJobQueue( UserIdentity $user ) {
191 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
194 /** @inheritDoc */
195 public function maybeEnqueueWatchlistExpiryJob(): void {
196 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
199 /** @inheritDoc */
200 public function removeWatchBatchForUser( UserIdentity $user, array $targets ) {
201 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
204 /** @inheritDoc */
205 public function getLatestNotificationTimestamp(
206 $timestamp, UserIdentity $user, $target
208 return wfTimestampOrNull( TS_MW, $timestamp );
211 /** @inheritDoc */
212 public function countExpired(): int {
213 return $this->actualStore->countExpired();
216 /** @inheritDoc */
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' );