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
21 use MediaWiki\Linker\LinkTarget
;
22 use Wikimedia\Rdbms\DBReadOnlyError
;
28 class NoWriteWatchedItemStore
implements WatchedItemStoreInterface
{
31 * @var WatchedItemStoreInterface
35 const DB_READONLY_ERROR
= 'The watchlist is currently readonly.';
38 * Initialy set WatchedItemStore that will be used in cases where writing is not needed.
39 * @param WatchedItemStoreInterface $actualStore
41 public function __construct( WatchedItemStoreInterface
$actualStore ) {
42 $this->actualStore
= $actualStore;
45 public function countWatchedItems( User
$user ) {
46 return $this->actualStore
->countWatchedItems( $user );
49 public function countWatchers( LinkTarget
$target ) {
50 return $this->actualStore
->countWatchers( $target );
53 public function countVisitingWatchers( LinkTarget
$target, $threshold ) {
54 return $this->actualStore
->countVisitingWatchers( $target, $threshold );
57 public function countWatchersMultiple( array $targets, array $options = [] ) {
58 return $this->actualStore
->countVisitingWatchersMultiple( $targets, $options );
61 public function countVisitingWatchersMultiple(
62 array $targetsWithVisitThresholds,
63 $minimumWatchers = null
65 return $this->actualStore
->countVisitingWatchersMultiple(
66 $targetsWithVisitThresholds,
71 public function getWatchedItem( User
$user, LinkTarget
$target ) {
72 return $this->actualStore
->getWatchedItem( $user, $target );
75 public function loadWatchedItem( User
$user, LinkTarget
$target ) {
76 return $this->actualStore
->loadWatchedItem( $user, $target );
79 public function getWatchedItemsForUser( User
$user, array $options = [] ) {
80 return $this->actualStore
->getWatchedItemsForUser( $user, $options );
83 public function isWatched( User
$user, LinkTarget
$target ) {
84 return $this->actualStore
->isWatched( $user, $target );
87 public function getNotificationTimestampsBatch( User
$user, array $targets ) {
88 return $this->actualStore
->getNotificationTimestampsBatch( $user, $targets );
91 public function countUnreadNotifications( User
$user, $unreadLimit = null ) {
92 return $this->actualStore
->countUnreadNotifications( $user, $unreadLimit );
95 public function duplicateAllAssociatedEntries( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
96 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
99 public function duplicateEntry( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
100 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
103 public function addWatch( User
$user, LinkTarget
$target ) {
104 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
107 public function addWatchBatchForUser( User
$user, array $targets ) {
108 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
111 public function removeWatch( User
$user, LinkTarget
$target ) {
112 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
115 public function setNotificationTimestampsForUser(
120 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
123 public function updateNotificationTimestamp( User
$editor, LinkTarget
$target, $timestamp ) {
124 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
127 public function resetAllNotificationTimestampsForUser( User
$user ) {
128 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
131 public function resetNotificationTimestamp(
137 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
140 public function clearUserWatchedItems( User
$user ) {
141 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
144 public function clearUserWatchedItemsUsingJobQueue( User
$user ) {
145 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
148 public function removeWatchBatchForUser( User
$user, array $titles ) {
149 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);