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 use MediaWiki\Linker\LinkTarget
;
23 use MediaWiki\User\UserIdentity
;
24 use Wikimedia\Rdbms\DBReadOnlyError
;
30 class NoWriteWatchedItemStore
implements WatchedItemStoreInterface
{
33 * @var WatchedItemStoreInterface
37 const DB_READONLY_ERROR
= 'The watchlist is currently readonly.';
40 * Initialy set WatchedItemStore that will be used in cases where writing is not needed.
41 * @param WatchedItemStoreInterface $actualStore
43 public function __construct( WatchedItemStoreInterface
$actualStore ) {
44 $this->actualStore
= $actualStore;
47 public function countWatchedItems( UserIdentity
$user ) {
48 return $this->actualStore
->countWatchedItems( $user );
51 public function countWatchers( LinkTarget
$target ) {
52 return $this->actualStore
->countWatchers( $target );
55 public function countVisitingWatchers( LinkTarget
$target, $threshold ) {
56 return $this->actualStore
->countVisitingWatchers( $target, $threshold );
59 public function countWatchersMultiple( array $targets, array $options = [] ) {
60 return $this->actualStore
->countVisitingWatchersMultiple(
62 $options['minimumWatchers'] ??
null
66 public function countVisitingWatchersMultiple(
67 array $targetsWithVisitThresholds,
68 $minimumWatchers = null
70 return $this->actualStore
->countVisitingWatchersMultiple(
71 $targetsWithVisitThresholds,
76 public function getWatchedItem( UserIdentity
$user, LinkTarget
$target ) {
77 return $this->actualStore
->getWatchedItem( $user, $target );
80 public function loadWatchedItem( UserIdentity
$user, LinkTarget
$target ) {
81 return $this->actualStore
->loadWatchedItem( $user, $target );
84 public function getWatchedItemsForUser( UserIdentity
$user, array $options = [] ) {
85 return $this->actualStore
->getWatchedItemsForUser( $user, $options );
88 public function isWatched( UserIdentity
$user, LinkTarget
$target ) {
89 return $this->actualStore
->isWatched( $user, $target );
92 public function getNotificationTimestampsBatch( UserIdentity
$user, array $targets ) {
93 return $this->actualStore
->getNotificationTimestampsBatch( $user, $targets );
96 public function countUnreadNotifications( UserIdentity
$user, $unreadLimit = null ) {
97 return $this->actualStore
->countUnreadNotifications( $user, $unreadLimit );
100 public function duplicateAllAssociatedEntries( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
101 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
104 public function duplicateEntry( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
105 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
108 public function addWatch( UserIdentity
$user, LinkTarget
$target ) {
109 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
112 public function addWatchBatchForUser( UserIdentity
$user, array $targets ) {
113 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
116 public function removeWatch( UserIdentity
$user, LinkTarget
$target ) {
117 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
120 public function setNotificationTimestampsForUser(
125 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
128 public function updateNotificationTimestamp(
129 UserIdentity
$editor, LinkTarget
$target, $timestamp
131 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
134 public function resetAllNotificationTimestampsForUser( UserIdentity
$user ) {
135 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
138 public function resetNotificationTimestamp(
144 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
147 public function clearUserWatchedItems( UserIdentity
$user ) {
148 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
151 public function clearUserWatchedItemsUsingJobQueue( UserIdentity
$user ) {
152 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
155 public function removeWatchBatchForUser( UserIdentity
$user, array $titles ) {
156 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
159 public function getLatestNotificationTimestamp(
160 $timestamp, UserIdentity
$user, LinkTarget
$target
162 return wfTimestampOrNull( TS_MW
, $timestamp );