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