Merge "Provide command to adjust phpunit.xml for code coverage"
[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(
61 $targets,
62 $options['minimumWatchers'] ?? null
63 );
64 }
65
66 public function countVisitingWatchersMultiple(
67 array $targetsWithVisitThresholds,
68 $minimumWatchers = null
69 ) {
70 return $this->actualStore->countVisitingWatchersMultiple(
71 $targetsWithVisitThresholds,
72 $minimumWatchers
73 );
74 }
75
76 public function getWatchedItem( UserIdentity $user, LinkTarget $target ) {
77 return $this->actualStore->getWatchedItem( $user, $target );
78 }
79
80 public function loadWatchedItem( UserIdentity $user, LinkTarget $target ) {
81 return $this->actualStore->loadWatchedItem( $user, $target );
82 }
83
84 public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) {
85 return $this->actualStore->getWatchedItemsForUser( $user, $options );
86 }
87
88 public function isWatched( UserIdentity $user, LinkTarget $target ) {
89 return $this->actualStore->isWatched( $user, $target );
90 }
91
92 public function getNotificationTimestampsBatch( UserIdentity $user, array $targets ) {
93 return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
94 }
95
96 public function countUnreadNotifications( UserIdentity $user, $unreadLimit = null ) {
97 return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
98 }
99
100 public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
101 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
102 }
103
104 public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
105 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
106 }
107
108 public function addWatch( UserIdentity $user, LinkTarget $target ) {
109 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
110 }
111
112 public function addWatchBatchForUser( UserIdentity $user, array $targets ) {
113 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
114 }
115
116 public function removeWatch( UserIdentity $user, LinkTarget $target ) {
117 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
118 }
119
120 public function setNotificationTimestampsForUser(
121 UserIdentity $user,
122 $timestamp,
123 array $targets = []
124 ) {
125 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
126 }
127
128 public function updateNotificationTimestamp(
129 UserIdentity $editor, LinkTarget $target, $timestamp
130 ) {
131 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
132 }
133
134 public function resetAllNotificationTimestampsForUser( UserIdentity $user ) {
135 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
136 }
137
138 public function resetNotificationTimestamp(
139 UserIdentity $user,
140 LinkTarget $title,
141 $force = '',
142 $oldid = 0
143 ) {
144 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
145 }
146
147 public function clearUserWatchedItems( UserIdentity $user ) {
148 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
149 }
150
151 public function clearUserWatchedItemsUsingJobQueue( UserIdentity $user ) {
152 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
153 }
154
155 public function removeWatchBatchForUser( UserIdentity $user, array $titles ) {
156 throw new DBReadOnlyError( null, self::DB_READONLY_ERROR );
157 }
158
159 public function getLatestNotificationTimestamp(
160 $timestamp, UserIdentity $user, LinkTarget $target
161 ) {
162 return wfTimestampOrNull( TS_MW, $timestamp );
163 }
164 }