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