Split parser related files to have one class in one file
[lhc/web/wiklou.git] / includes / watcheditem / NoWriteWatchedItemStore.php
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.
7 *
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.
12 *
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
17 *
18 * @file
19 * @ingroup Watchlist
20 */
21 use MediaWiki\Linker\LinkTarget;
22 use Wikimedia\Rdbms\DBReadOnlyError;
23
24 /**
25 * @internal
26 * @since 1.31
27 */
28 class NoWriteWatchedItemStore implements WatchedItemStoreInterface {
29
30 /**
31 * @var WatchedItemStoreInterface
32 */
33 private $actualStore;
34
35 const DB_READONLY_ERROR = 'The watchlist is currently readonly.';
36
37 /**
38 * Initialy set WatchedItemStore that will be used in cases where writing is not needed.
39 * @param WatchedItemStoreInterface $actualStore
40 */
41 public function __construct( WatchedItemStoreInterface $actualStore ) {
42 $this->actualStore = $actualStore;
43 }
44
45 public function countWatchedItems( User $user ) {
46 return $this->actualStore->countWatchedItems( $user );
47 }
48
49 public function countWatchers( LinkTarget $target ) {
50 return $this->actualStore->countWatchers( $target );
51 }
52
53 public function countVisitingWatchers( LinkTarget $target, $threshold ) {
54 return $this->actualStore->countVisitingWatchers( $target, $threshold );
55 }
56
57 public function countWatchersMultiple( array $targets, array $options = [] ) {
58 return $this->actualStore->countVisitingWatchersMultiple( $targets, $options );
59 }
60
61 public function countVisitingWatchersMultiple(
62 array $targetsWithVisitThresholds,
63 $minimumWatchers = null
64 ) {
65 return $this->actualStore->countVisitingWatchersMultiple(
66 $targetsWithVisitThresholds,
67 $minimumWatchers
68 );
69 }
70
71 public function getWatchedItem( User $user, LinkTarget $target ) {
72 return $this->actualStore->getWatchedItem( $user, $target );
73 }
74
75 public function loadWatchedItem( User $user, LinkTarget $target ) {
76 return $this->actualStore->loadWatchedItem( $user, $target );
77 }
78
79 public function getWatchedItemsForUser( User $user, array $options = [] ) {
80 return $this->actualStore->getWatchedItemsForUser( $user, $options );
81 }
82
83 public function isWatched( User $user, LinkTarget $target ) {
84 return $this->actualStore->isWatched( $user, $target );
85 }
86
87 public function getNotificationTimestampsBatch( User $user, array $targets ) {
88 return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
89 }
90
91 public function countUnreadNotifications( User $user, $unreadLimit = null ) {
92 return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
93 }
94
95 public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
96 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
97 }
98
99 public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
100 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
101 }
102
103 public function addWatch( User $user, LinkTarget $target ) {
104 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
105 }
106
107 public function addWatchBatchForUser( User $user, array $targets ) {
108 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
109 }
110
111 public function removeWatch( User $user, LinkTarget $target ) {
112 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
113 }
114
115 public function setNotificationTimestampsForUser(
116 User $user,
117 $timestamp,
118 array $targets = []
119 ) {
120 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
121 }
122
123 public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) {
124 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
125 }
126
127 public function resetAllNotificationTimestampsForUser( User $user ) {
128 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
129 }
130
131 public function resetNotificationTimestamp(
132 User $user,
133 Title $title,
134 $force = '',
135 $oldid = 0
136 ) {
137 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
138 }
139
140 public function clearUserWatchedItems( User $user ) {
141 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
142 }
143
144 public function clearUserWatchedItemsUsingJobQueue( User $user ) {
145 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
146 }
147
148 public function removeWatchBatchForUser( User $user, array $titles ) {
149 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
150 }
151
152 public function getLatestNotificationTimestamp( $timestamp, User $user, LinkTarget $target ) {
153 return wfTimestampOrNull( TS_MW, $timestamp );
154 }
155 }