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( $targets, $options );
63 public function countVisitingWatchersMultiple(
64 array $targetsWithVisitThresholds,
65 $minimumWatchers = null
67 return $this->actualStore
->countVisitingWatchersMultiple(
68 $targetsWithVisitThresholds,
73 public function getWatchedItem( UserIdentity
$user, LinkTarget
$target ) {
74 return $this->actualStore
->getWatchedItem( $user, $target );
77 public function loadWatchedItem( UserIdentity
$user, LinkTarget
$target ) {
78 return $this->actualStore
->loadWatchedItem( $user, $target );
81 public function getWatchedItemsForUser( UserIdentity
$user, array $options = [] ) {
82 return $this->actualStore
->getWatchedItemsForUser( $user, $options );
85 public function isWatched( UserIdentity
$user, LinkTarget
$target ) {
86 return $this->actualStore
->isWatched( $user, $target );
89 public function getNotificationTimestampsBatch( UserIdentity
$user, array $targets ) {
90 return $this->actualStore
->getNotificationTimestampsBatch( $user, $targets );
93 public function countUnreadNotifications( UserIdentity
$user, $unreadLimit = null ) {
94 return $this->actualStore
->countUnreadNotifications( $user, $unreadLimit );
97 public function duplicateAllAssociatedEntries( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
98 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
101 public function duplicateEntry( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
102 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
105 public function addWatch( UserIdentity
$user, LinkTarget
$target ) {
106 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
109 public function addWatchBatchForUser( UserIdentity
$user, array $targets ) {
110 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
113 public function removeWatch( UserIdentity
$user, LinkTarget
$target ) {
114 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
117 public function setNotificationTimestampsForUser(
122 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
125 public function updateNotificationTimestamp(
126 UserIdentity
$editor, LinkTarget
$target, $timestamp
128 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
131 public function resetAllNotificationTimestampsForUser( UserIdentity
$user ) {
132 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
135 public function resetNotificationTimestamp(
141 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
144 public function clearUserWatchedItems( UserIdentity
$user ) {
145 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
148 public function clearUserWatchedItemsUsingJobQueue( UserIdentity
$user ) {
149 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
152 public function removeWatchBatchForUser( UserIdentity
$user, array $titles ) {
153 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
156 public function getLatestNotificationTimestamp(
157 $timestamp, UserIdentity
$user, LinkTarget
$target
159 return wfTimestampOrNull( TS_MW
, $timestamp );