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
38 const DB_READONLY_ERROR
= 'The watchlist is currently readonly.';
41 * Initialy set WatchedItemStore that will be used in cases where writing is not needed.
42 * @param WatchedItemStoreInterface $actualStore
44 public function __construct( WatchedItemStoreInterface
$actualStore ) {
45 $this->actualStore
= $actualStore;
48 public function countWatchedItems( User
$user ) {
49 return $this->actualStore
->countWatchedItems( $user );
52 public function countWatchers( LinkTarget
$target ) {
53 return $this->actualStore
->countWatchers( $target );
56 public function countVisitingWatchers( LinkTarget
$target, $threshold ) {
57 return $this->actualStore
->countVisitingWatchers( $target, $threshold );
60 public function countWatchersMultiple( array $targets, array $options = [] ) {
61 return $this->actualStore
->countVisitingWatchersMultiple( $targets, $options );
64 public function countVisitingWatchersMultiple(
65 array $targetsWithVisitThresholds,
66 $minimumWatchers = null
68 return $this->actualStore
->countVisitingWatchersMultiple(
69 $targetsWithVisitThresholds,
74 public function getWatchedItem( User
$user, LinkTarget
$target ) {
75 return $this->actualStore
->getWatchedItem( $user, $target );
78 public function loadWatchedItem( User
$user, LinkTarget
$target ) {
79 return $this->actualStore
->loadWatchedItem( $user, $target );
82 public function getWatchedItemsForUser( User
$user, array $options = [] ) {
83 return $this->actualStore
->getWatchedItemsForUser( $user, $options );
86 public function isWatched( User
$user, LinkTarget
$target ) {
87 return $this->actualStore
->isWatched( $user, $target );
90 public function getNotificationTimestampsBatch( User
$user, array $targets ) {
91 return $this->actualStore
->getNotificationTimestampsBatch( $user, $targets );
94 public function countUnreadNotifications( User
$user, $unreadLimit = null ) {
95 return $this->actualStore
->countUnreadNotifications( $user, $unreadLimit );
98 public function duplicateAllAssociatedEntries( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
99 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
102 public function duplicateEntry( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
103 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
106 public function addWatch( User
$user, LinkTarget
$target ) {
107 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
110 public function addWatchBatchForUser( User
$user, array $targets ) {
111 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
114 public function removeWatch( User
$user, LinkTarget
$target ) {
115 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
118 public function setNotificationTimestampsForUser(
123 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
126 public function updateNotificationTimestamp( User
$editor, LinkTarget
$target, $timestamp ) {
127 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
130 public function resetAllNotificationTimestampsForUser( User
$user ) {
131 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
134 public function resetNotificationTimestamp(
140 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
143 public function clearUserWatchedItems( User
$user ) {
144 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
147 public function clearUserWatchedItemsUsingJobQueue( User
$user ) {
148 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
151 public function removeWatchBatchForUser( User
$user, array $titles ) {
152 throw new DBReadOnlyError( null, self
::DB_READONLY_ERROR
);
155 public function getLatestNotificationTimestamp( $timestamp, User
$user, LinkTarget
$target ) {
156 return wfTimestampOrNull( TS_MW
, $timestamp );