Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
67.57% |
25 / 37 |
|
61.29% |
19 / 31 |
CRAP | |
0.00% |
0 / 1 |
NoWriteWatchedItemStore | |
67.57% |
25 / 37 |
|
61.29% |
19 / 31 |
63.78 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
countWatchedItems | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
countWatchers | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
countVisitingWatchers | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
countWatchersMultiple | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
countVisitingWatchersMultiple | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getWatchedItem | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
loadWatchedItem | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
loadWatchedItemsBatch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getWatchedItemsForUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isWatched | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isTempWatched | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getNotificationTimestampsBatch | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
countUnreadNotifications | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
duplicateAllAssociatedEntries | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
duplicateEntry | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addWatch | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addWatchBatchForUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
removeWatch | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNotificationTimestampsForUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
updateNotificationTimestamp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
resetAllNotificationTimestampsForUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
resetNotificationTimestamp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
clearUserWatchedItems | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
mustClearWatchedItemsUsingJobQueue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
clearUserWatchedItemsUsingJobQueue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
maybeEnqueueWatchlistExpiryJob | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeWatchBatchForUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLatestNotificationTimestamp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
countExpired | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeExpired | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
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\User\UserIdentity; |
23 | use Wikimedia\Rdbms\DBReadOnlyError; |
24 | |
25 | /** |
26 | * @internal |
27 | * @since 1.31 |
28 | * @phan-file-suppress PhanPluginNeverReturnMethod |
29 | */ |
30 | class NoWriteWatchedItemStore implements WatchedItemStoreInterface { |
31 | |
32 | private WatchedItemStoreInterface $actualStore; |
33 | |
34 | private const DB_READONLY_ERROR = 'The watchlist is currently readonly.'; |
35 | |
36 | /** |
37 | * Initially set WatchedItemStore that will be used in cases where writing is not needed. |
38 | * @param WatchedItemStoreInterface $actualStore |
39 | */ |
40 | public function __construct( WatchedItemStoreInterface $actualStore ) { |
41 | $this->actualStore = $actualStore; |
42 | } |
43 | |
44 | /** @inheritDoc */ |
45 | public function countWatchedItems( UserIdentity $user ) { |
46 | return $this->actualStore->countWatchedItems( $user ); |
47 | } |
48 | |
49 | /** @inheritDoc */ |
50 | public function countWatchers( $target ) { |
51 | return $this->actualStore->countWatchers( $target ); |
52 | } |
53 | |
54 | /** @inheritDoc */ |
55 | public function countVisitingWatchers( $target, $threshold ) { |
56 | return $this->actualStore->countVisitingWatchers( $target, $threshold ); |
57 | } |
58 | |
59 | /** @inheritDoc */ |
60 | public function countWatchersMultiple( array $targets, array $options = [] ) { |
61 | return $this->actualStore->countWatchersMultiple( |
62 | $targets, |
63 | $options |
64 | ); |
65 | } |
66 | |
67 | /** @inheritDoc */ |
68 | public function countVisitingWatchersMultiple( |
69 | array $targetsWithVisitThresholds, |
70 | $minimumWatchers = null |
71 | ) { |
72 | return $this->actualStore->countVisitingWatchersMultiple( |
73 | $targetsWithVisitThresholds, |
74 | $minimumWatchers |
75 | ); |
76 | } |
77 | |
78 | /** @inheritDoc */ |
79 | public function getWatchedItem( UserIdentity $user, $target ) { |
80 | return $this->actualStore->getWatchedItem( $user, $target ); |
81 | } |
82 | |
83 | /** @inheritDoc */ |
84 | public function loadWatchedItem( UserIdentity $user, $target ) { |
85 | return $this->actualStore->loadWatchedItem( $user, $target ); |
86 | } |
87 | |
88 | /** @inheritDoc */ |
89 | public function loadWatchedItemsBatch( UserIdentity $user, array $targets ) { |
90 | return $this->actualStore->loadWatchedItemsBatch( $user, $targets ); |
91 | } |
92 | |
93 | /** @inheritDoc */ |
94 | public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) { |
95 | return $this->actualStore->getWatchedItemsForUser( $user, $options ); |
96 | } |
97 | |
98 | /** @inheritDoc */ |
99 | public function isWatched( UserIdentity $user, $target ) { |
100 | return $this->actualStore->isWatched( $user, $target ); |
101 | } |
102 | |
103 | /** @inheritDoc */ |
104 | public function isTempWatched( UserIdentity $user, $target ): bool { |
105 | return $this->actualStore->isTempWatched( $user, $target ); |
106 | } |
107 | |
108 | /** @inheritDoc */ |
109 | public function getNotificationTimestampsBatch( UserIdentity $user, array $targets ) { |
110 | return $this->actualStore->getNotificationTimestampsBatch( $user, $targets ); |
111 | } |
112 | |
113 | /** @inheritDoc */ |
114 | public function countUnreadNotifications( UserIdentity $user, $unreadLimit = null ) { |
115 | return $this->actualStore->countUnreadNotifications( $user, $unreadLimit ); |
116 | } |
117 | |
118 | /** @inheritDoc */ |
119 | public function duplicateAllAssociatedEntries( $oldTarget, $newTarget ) { |
120 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
121 | } |
122 | |
123 | /** @inheritDoc */ |
124 | public function duplicateEntry( $oldTarget, $newTarget ) { |
125 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
126 | } |
127 | |
128 | /** @inheritDoc */ |
129 | public function addWatch( UserIdentity $user, $target, ?string $expiry = null ) { |
130 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
131 | } |
132 | |
133 | /** @inheritDoc */ |
134 | public function addWatchBatchForUser( |
135 | UserIdentity $user, |
136 | array $targets, |
137 | ?string $expiry = null |
138 | ) { |
139 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
140 | } |
141 | |
142 | /** @inheritDoc */ |
143 | public function removeWatch( UserIdentity $user, $target ) { |
144 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
145 | } |
146 | |
147 | /** @inheritDoc */ |
148 | public function setNotificationTimestampsForUser( |
149 | UserIdentity $user, |
150 | $timestamp, |
151 | array $targets = [] |
152 | ) { |
153 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
154 | } |
155 | |
156 | /** @inheritDoc */ |
157 | public function updateNotificationTimestamp( |
158 | UserIdentity $editor, $target, $timestamp |
159 | ) { |
160 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
161 | } |
162 | |
163 | /** @inheritDoc */ |
164 | public function resetAllNotificationTimestampsForUser( UserIdentity $user, $timestamp = null ) { |
165 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
166 | } |
167 | |
168 | /** @inheritDoc */ |
169 | public function resetNotificationTimestamp( |
170 | UserIdentity $user, |
171 | $title, |
172 | $force = '', |
173 | $oldid = 0 |
174 | ) { |
175 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
176 | } |
177 | |
178 | /** @inheritDoc */ |
179 | public function clearUserWatchedItems( UserIdentity $user ) { |
180 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
181 | } |
182 | |
183 | /** @inheritDoc */ |
184 | public function mustClearWatchedItemsUsingJobQueue( UserIdentity $user ): bool { |
185 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
186 | } |
187 | |
188 | /** @inheritDoc */ |
189 | public function clearUserWatchedItemsUsingJobQueue( UserIdentity $user ) { |
190 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
191 | } |
192 | |
193 | /** @inheritDoc */ |
194 | public function maybeEnqueueWatchlistExpiryJob(): void { |
195 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
196 | } |
197 | |
198 | /** @inheritDoc */ |
199 | public function removeWatchBatchForUser( UserIdentity $user, array $targets ) { |
200 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
201 | } |
202 | |
203 | /** @inheritDoc */ |
204 | public function getLatestNotificationTimestamp( |
205 | $timestamp, UserIdentity $user, $target |
206 | ) { |
207 | return wfTimestampOrNull( TS_MW, $timestamp ); |
208 | } |
209 | |
210 | /** @inheritDoc */ |
211 | public function countExpired(): int { |
212 | return $this->actualStore->countExpired(); |
213 | } |
214 | |
215 | /** @inheritDoc */ |
216 | public function removeExpired( int $limit, bool $deleteOrphans = false ): void { |
217 | throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); |
218 | } |
219 | } |