|
MediaWiki master
|
Storage layer class for WatchedItems. More...
Inherits MediaWiki\Watchlist\WatchedItemStoreInterface.

Public Member Functions | ||||||||||
| __construct (ServiceOptions $options, ILBFactory $lbFactory, JobQueueGroup $queueGroup, BagOStuff $stash, HashBagOStuff $cache, ReadOnlyMode $readOnlyMode, NamespaceInfo $nsInfo, RevisionLookup $revisionLookup, LinkBatchFactory $linkBatchFactory, WatchlistLabelStore $labelStore,) | ||||||||||
| addLabels (UserIdentity $user, array $targets, array $labels) | ||||||||||
Add a labels to a set of watchlist items.The same labels are applied to each item. Ignore existing labels, and labels that the user does not own.
| ||||||||||
| addWatch (UserIdentity $user, PageReference $target, ?string $expiry=null) | ||||||||||
| addWatchBatchForUser (UserIdentity $user, array $targets, ?string $expiry=null) | ||||||||||
| Add multiple items to the user's watchlist. | ||||||||||
| clearUserWatchedItems (UserIdentity $user) | ||||||||||
| Deletes ALL watched items for the given user when under $updateRowsPerQuery entries exist. | ||||||||||
| clearUserWatchedItemsUsingJobQueue (UserIdentity $user) | ||||||||||
| Queues a job that will clear the users watchlist using the Job Queue. | ||||||||||
| countExpired () | ||||||||||
Get the number of watchlist items that expire before the current time.
| ||||||||||
| countUnreadNotifications (UserIdentity $user, $unreadLimit=null) | ||||||||||
| countVisitingWatchers (PageReference $target, $threshold) | ||||||||||
| countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null) | ||||||||||
| countWatchedItems (UserIdentity $user) | ||||||||||
| countWatchers (PageReference $target) | ||||||||||
| countWatchersMultiple (array $targets, array $options=[]) | ||||||||||
| duplicateAllAssociatedEntries (PageReference $oldTarget, PageReference $newTarget) | ||||||||||
| duplicateEntry (PageReference $oldTarget, PageReference $newTarget) | ||||||||||
| getLatestNotificationTimestamp ( $timestamp, UserIdentity $user, PageReference $target) | ||||||||||
| getMaxId () | ||||||||||
| getNotificationTimestampsBatch (UserIdentity $user, array $targets) | ||||||||||
| getWatchedItem (UserIdentity $user, PageReference $target) | ||||||||||
| getWatchedItemsForUser (UserIdentity $user, array $options=[]) | ||||||||||
| isTempWatched (UserIdentity $user, PageReference $target) | ||||||||||
| Check if the user is temporarily watching the page. | ||||||||||
| isWatched (UserIdentity $user, PageReference $target) | ||||||||||
| loadWatchedItem (UserIdentity $user, PageReference $target) | ||||||||||
| loadWatchedItemsBatch (UserIdentity $user, array $targets) | ||||||||||
| maybeEnqueueWatchlistExpiryJob () | ||||||||||
Probabilistically add a job to purge the expired watchlist items, if watchlist expiration is enabled, based on the value of $wgWatchlistPurgeRate.
| ||||||||||
| mustClearWatchedItemsUsingJobQueue (UserIdentity $user) | ||||||||||
| Does the size of the users watchlist require clearUserWatchedItemsUsingJobQueue() to be used instead of clearUserWatchedItems(). | ||||||||||
| overrideDeferredUpdatesAddCallableUpdateCallback (callable $callback) | ||||||||||
| Overrides the DeferredUpdates::addCallableUpdate callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined. | ||||||||||
| removeExpired (int $limit, bool $deleteOrphans=false) | ||||||||||
Remove some number of expired watchlist items.
| ||||||||||
| removeLabels (UserIdentity $user, array $targets, array $labels) | ||||||||||
Remove labels from a set of watchlist items.The same labels are removed from each item. Ignore missing label members.
| ||||||||||
| removeWatch (UserIdentity $user, PageReference $target) | ||||||||||
| removeWatchBatchForUser (UserIdentity $user, array $titles) | ||||||||||
| resetAllNotificationTimestampsForUser (UserIdentity $user, $timestamp=null) | ||||||||||
| Schedule a DeferredUpdate that sets all of the "last viewed" timestamps for a given user to the same value. | ||||||||||
| resetNotificationTimestamp (UserIdentity $user, PageReference $title, $force='', $oldid=0) | ||||||||||
| setNotificationTimestampsForUser (UserIdentity $user, $timestamp, array $targets=[]) | ||||||||||
| Set the "last viewed" timestamps for certain titles on a user's watchlist. | ||||||||||
| updateNotificationTimestamp (UserIdentity $editor, PageReference $target, $timestamp) | ||||||||||
| Update wl_notificationtimestamp for all watching users except the editor. | ||||||||||
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
| Public Attributes inherited from MediaWiki\Watchlist\WatchedItemStoreInterface | |
| const | SORT_ASC = 'ASC' |
| const | SORT_DESC = 'DESC' |
Storage layer class for WatchedItems.
Database interaction & caching TODO caching should be factored out into a CachingWatchedItemStore class
Definition at line 43 of file WatchedItemStore.php.
| MediaWiki\Watchlist\WatchedItemStore::__construct | ( | ServiceOptions | $options, |
| ILBFactory | $lbFactory, | ||
| JobQueueGroup | $queueGroup, | ||
| BagOStuff | $stash, | ||
| HashBagOStuff | $cache, | ||
| ReadOnlyMode | $readOnlyMode, | ||
| NamespaceInfo | $nsInfo, | ||
| RevisionLookup | $revisionLookup, | ||
| LinkBatchFactory | $linkBatchFactory, | ||
| WatchlistLabelStore | $labelStore ) |
Definition at line 138 of file WatchedItemStore.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), MediaWiki\MainConfigNames\EnableWatchlistLabels, MediaWiki\Config\ServiceOptions\get(), MediaWiki\MainConfigNames\UpdateRowsPerQuery, MediaWiki\MainConfigNames\WatchlistExpiry, MediaWiki\MainConfigNames\WatchlistExpiryMaxDuration, and MediaWiki\MainConfigNames\WatchlistPurgeRate.
| MediaWiki\Watchlist\WatchedItemStore::addLabels | ( | UserIdentity | $user, |
| array | $targets, | ||
| array | $labels ) |
Add a labels to a set of watchlist items.The same labels are applied to each item. Ignore existing labels, and labels that the user does not own.
| UserIdentity | $user | |
| PageReference[] | $targets | |
| (WatchlistLabel|int)[] | $labels The label objects or IDs |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1832 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::addWatch | ( | UserIdentity | $user, |
| PageReference | $target, | ||
| ?string | $expiry = null ) |
| UserIdentity | $user | |
| PageReference | $target | |
| string | null | $expiry | Optional expiry in any format acceptable to wfTimestamp(). null will not create an expiry, or leave it unchanged should one already exist. |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 951 of file WatchedItemStore.php.
References addWatchBatchForUser(), and loadWatchedItem().
| MediaWiki\Watchlist\WatchedItemStore::addWatchBatchForUser | ( | UserIdentity | $user, |
| array | $targets, | ||
| ?string | $expiry = null ) |
Add multiple items to the user's watchlist.
If you know you're adding a single page (and/or its talk page) use self::addWatch(), since it will add the WatchedItem to the process cache.
| UserIdentity | $user | |
| PageReference[] | $targets | |
| string | null | $expiry | Optional expiry in a format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist. |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 992 of file WatchedItemStore.php.
References if.
Referenced by addWatch().
| MediaWiki\Watchlist\WatchedItemStore::clearUserWatchedItems | ( | UserIdentity | $user | ) |
Deletes ALL watched items for the given user when under $updateRowsPerQuery entries exist.
| UserIdentity | $user |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 298 of file WatchedItemStore.php.
References if, and mustClearWatchedItemsUsingJobQueue().
| MediaWiki\Watchlist\WatchedItemStore::clearUserWatchedItemsUsingJobQueue | ( | UserIdentity | $user | ) |
Queues a job that will clear the users watchlist using the Job Queue.
| UserIdentity | $user |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 374 of file WatchedItemStore.php.
References $job, getMaxId(), and MediaWiki\Watchlist\ClearUserWatchlistJob\newForUser().
| MediaWiki\Watchlist\WatchedItemStore::countExpired | ( | ) |
Get the number of watchlist items that expire before the current time.
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1763 of file WatchedItemStore.php.
| MediaWiki\Watchlist\WatchedItemStore::countUnreadNotifications | ( | UserIdentity | $user, |
| $unreadLimit = null ) |
| UserIdentity | $user | |
| int | null | $unreadLimit |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1534 of file WatchedItemStore.php.
References MediaWiki\User\UserIdentity\getId().
| MediaWiki\Watchlist\WatchedItemStore::countVisitingWatchers | ( | PageReference | $target, |
| $threshold ) |
| PageReference | $target | |
| string | int | $threshold |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 452 of file WatchedItemStore.php.
References return.
| MediaWiki\Watchlist\WatchedItemStore::countVisitingWatchersMultiple | ( | array | $targetsWithVisitThresholds, |
| $minimumWatchers = null ) |
| array | $targetsWithVisitThresholds | array of pairs (PageReference, last visit threshold) |
| int | null | $minimumWatchers |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 566 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::countWatchedItems | ( | UserIdentity | $user | ) |
| UserIdentity | $user |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 412 of file WatchedItemStore.php.
References return.
Referenced by mustClearWatchedItemsUsingJobQueue().
| MediaWiki\Watchlist\WatchedItemStore::countWatchers | ( | PageReference | $target | ) |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 430 of file WatchedItemStore.php.
References return.
| MediaWiki\Watchlist\WatchedItemStore::countWatchersMultiple | ( | array | $targets, |
| array | $options = [] ) |
| PageReference[] | $targets | |
| array | $options | Supported options are:
|
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 527 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::duplicateAllAssociatedEntries | ( | PageReference | $oldTarget, |
| PageReference | $newTarget ) |
| PageReference | $oldTarget | |
| PageReference | $newTarget |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1565 of file WatchedItemStore.php.
References duplicateEntry(), MediaWiki\Page\PageReference\getDBkey(), and MediaWiki\Page\PageReference\getNamespace().
| MediaWiki\Watchlist\WatchedItemStore::duplicateEntry | ( | PageReference | $oldTarget, |
| PageReference | $newTarget ) |
| PageReference | $oldTarget | |
| PageReference | $newTarget |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1597 of file WatchedItemStore.php.
References MediaWiki\Page\PageReference\getDBkey(), and MediaWiki\Page\PageReference\getNamespace().
Referenced by duplicateAllAssociatedEntries().
| MediaWiki\Watchlist\WatchedItemStore::getLatestNotificationTimestamp | ( | $timestamp, | |
| UserIdentity | $user, | ||
| PageReference | $target ) |
| string | null | $timestamp | |
| UserIdentity | $user | |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1215 of file WatchedItemStore.php.
References wfTimestampOrNull().
| MediaWiki\Watchlist\WatchedItemStore::getMaxId | ( | ) |
Definition at line 399 of file WatchedItemStore.php.
References return.
Referenced by clearUserWatchedItemsUsingJobQueue().
| MediaWiki\Watchlist\WatchedItemStore::getNotificationTimestampsBatch | ( | UserIdentity | $user, |
| array | $targets ) |
| UserIdentity | $user | |
| PageReference[] | $targets |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 896 of file WatchedItemStore.php.
| MediaWiki\Watchlist\WatchedItemStore::getWatchedItem | ( | UserIdentity | $user, |
| PageReference | $target ) |
| UserIdentity | $user | |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 650 of file WatchedItemStore.php.
References MediaWiki\User\UserIdentity\isRegistered(), and loadWatchedItem().
Referenced by isTempWatched(), isWatched(), and resetNotificationTimestamp().
| MediaWiki\Watchlist\WatchedItemStore::getWatchedItemsForUser | ( | UserIdentity | $user, |
| array | $options = [] ) |
| UserIdentity | $user | |
| array | $options | Supported options are:
|
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 727 of file WatchedItemStore.php.
References MediaWiki\Watchlist\WatchedItemStoreInterface\SORT_ASC.
| MediaWiki\Watchlist\WatchedItemStore::isTempWatched | ( | UserIdentity | $user, |
| PageReference | $target ) |
Check if the user is temporarily watching the page.
| UserIdentity | $user | |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 884 of file WatchedItemStore.php.
References getWatchedItem().
| MediaWiki\Watchlist\WatchedItemStore::isWatched | ( | UserIdentity | $user, |
| PageReference | $target ) |
| UserIdentity | $user | |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 873 of file WatchedItemStore.php.
References getWatchedItem(), and return.
| MediaWiki\Watchlist\WatchedItemStore::loadWatchedItem | ( | UserIdentity | $user, |
| PageReference | $target ) |
| UserIdentity | $user | |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 668 of file WatchedItemStore.php.
References loadWatchedItemsBatch().
Referenced by addWatch(), and getWatchedItem().
| MediaWiki\Watchlist\WatchedItemStore::loadWatchedItemsBatch | ( | UserIdentity | $user, |
| array | $targets ) |
| UserIdentity | $user | |
| PageReference[] | $targets |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 679 of file WatchedItemStore.php.
References MediaWiki\User\UserIdentity\isRegistered().
Referenced by loadWatchedItem().
| MediaWiki\Watchlist\WatchedItemStore::maybeEnqueueWatchlistExpiryJob | ( | ) |
Probabilistically add a job to purge the expired watchlist items, if watchlist expiration is enabled, based on the value of $wgWatchlistPurgeRate.
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 382 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::mustClearWatchedItemsUsingJobQueue | ( | UserIdentity | $user | ) |
Does the size of the users watchlist require clearUserWatchedItemsUsingJobQueue() to be used instead of clearUserWatchedItems().
| UserIdentity | $user |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 339 of file WatchedItemStore.php.
References countWatchedItems(), and return.
Referenced by clearUserWatchedItems().
| MediaWiki\Watchlist\WatchedItemStore::overrideDeferredUpdatesAddCallableUpdateCallback | ( | callable | $callback | ) |
Overrides the DeferredUpdates::addCallableUpdate callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
| callable | $callback |
Definition at line 181 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::removeExpired | ( | int | $limit, |
| bool | $deleteOrphans = false ) |
Remove some number of expired watchlist items.
| int | $limit | The number of items to remove. |
| bool | $deleteOrphans | Whether to also delete watchlist_expiry rows that have no related watchlist rows (because not all code knows about the expiry table yet). This runs two extra queries, so is only done from the purgeExpiredWatchlistItems.php maintenance script. |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1775 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::removeLabels | ( | UserIdentity | $user, |
| array | $targets, | ||
| array | $labels ) |
Remove labels from a set of watchlist items.The same labels are removed from each item. Ignore missing label members.
| UserIdentity | $user | |
| PageReference[] | $targets | |
| (WatchlistLabel|int)[] | $labels |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1874 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::removeWatch | ( | UserIdentity | $user, |
| PageReference | $target ) |
| UserIdentity | $user | |
| PageReference | $target |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1144 of file WatchedItemStore.php.
References removeWatchBatchForUser(), and return.
| MediaWiki\Watchlist\WatchedItemStore::removeWatchBatchForUser | ( | UserIdentity | $user, |
| array | $titles ) |
| UserIdentity | $user | |
| PageReference[] | $titles |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 475 of file WatchedItemStore.php.
References if.
Referenced by removeWatch().
| MediaWiki\Watchlist\WatchedItemStore::resetAllNotificationTimestampsForUser | ( | UserIdentity | $user, |
| $timestamp = null ) |
Schedule a DeferredUpdate that sets all of the "last viewed" timestamps for a given user to the same value.
| UserIdentity | $user | |
| string | int | null | $timestamp | Value to set all timestamps to, null to clear them |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1243 of file WatchedItemStore.php.
References $job, MediaWiki\User\UserIdentity\getId(), and MediaWiki\User\UserIdentity\isRegistered().
| MediaWiki\Watchlist\WatchedItemStore::resetNotificationTimestamp | ( | UserIdentity | $user, |
| PageReference | $title, | ||
| $force = '', | |||
| $oldid = 0 ) |
| UserIdentity | $user | |
| PageReference | $title | |
| string | $force | |
| int | $oldid |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1339 of file WatchedItemStore.php.
References getWatchedItem(), and if.
| MediaWiki\Watchlist\WatchedItemStore::setNotificationTimestampsForUser | ( | UserIdentity | $user, |
| $timestamp, | |||
| array | $targets = [] ) |
Set the "last viewed" timestamps for certain titles on a user's watchlist.
If the $targets parameter is omitted or set to [], this method simply wraps resetAllNotificationTimestampsForUser(), and in that case you should instead call that method directly; support for omitting $targets is for backwards compatibility.
If $targets is omitted or set to [], timestamps will be updated for every title on the user's watchlist, and this will be done through a DeferredUpdate. If $targets is a non-empty array, only the specified titles will be updated, and this will be done immediately (not deferred).
| UserIdentity | $user | |
| string | int | $timestamp | Value to set the "last viewed" timestamp to (null to clear) |
| PageReference[] | $targets | Titles to set the timestamp for; [] means the entire watchlist |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1165 of file WatchedItemStore.php.
References if.
| MediaWiki\Watchlist\WatchedItemStore::updateNotificationTimestamp | ( | UserIdentity | $editor, |
| PageReference | $target, | ||
| $timestamp ) |
Update wl_notificationtimestamp for all watching users except the editor.
| UserIdentity | $editor | |
| PageReference | $target | |
| string | int | $timestamp |
Implements MediaWiki\Watchlist\WatchedItemStoreInterface.
Definition at line 1271 of file WatchedItemStore.php.
| const MediaWiki\Watchlist\WatchedItemStore::CONSTRUCTOR_OPTIONS |
Definition at line 48 of file WatchedItemStore.php.