MediaWiki master
|
Storage layer class for WatchedItems. More...
Inherits WatchedItemStoreInterface.
Public Member Functions | |||||||
__construct (ServiceOptions $options, ILBFactory $lbFactory, JobQueueGroup $queueGroup, BagOStuff $stash, HashBagOStuff $cache, ReadOnlyMode $readOnlyMode, NamespaceInfo $nsInfo, RevisionLookup $revisionLookup, LinkBatchFactory $linkBatchFactory, StatsFactory $statsFactory) | |||||||
addWatch (UserIdentity $user, $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 ( $target, $threshold) | |||||||
countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null) | |||||||
countWatchedItems (UserIdentity $user) | |||||||
countWatchers ( $target) | |||||||
countWatchersMultiple (array $targets, array $options=[]) | |||||||
duplicateAllAssociatedEntries ( $oldTarget, $newTarget) | |||||||
duplicateEntry ( $oldTarget, $newTarget) | |||||||
getLatestNotificationTimestamp ( $timestamp, UserIdentity $user, $target) | |||||||
getMaxId () | |||||||
getNotificationTimestampsBatch (UserIdentity $user, array $targets) | |||||||
getWatchedItem (UserIdentity $user, $target) | |||||||
getWatchedItemsForUser (UserIdentity $user, array $options=[]) | |||||||
isTempWatched (UserIdentity $user, $target) | |||||||
Check if the user is temporarily watching the page. | |||||||
isWatched (UserIdentity $user, $target) | |||||||
loadWatchedItem (UserIdentity $user, $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) | |||||||
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.
| |||||||
removeWatch (UserIdentity $user, $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, $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, $target, $timestamp) | |||||||
Update wl_notificationtimestamp for all watching users except the editor. | |||||||
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
Public Attributes inherited from 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 36 of file WatchedItemStore.php.
WatchedItemStore::__construct | ( | ServiceOptions | $options, |
ILBFactory | $lbFactory, | ||
JobQueueGroup | $queueGroup, | ||
BagOStuff | $stash, | ||
HashBagOStuff | $cache, | ||
ReadOnlyMode | $readOnlyMode, | ||
NamespaceInfo | $nsInfo, | ||
RevisionLookup | $revisionLookup, | ||
LinkBatchFactory | $linkBatchFactory, | ||
StatsFactory | $statsFactory ) |
ServiceOptions | $options | |
ILBFactory | $lbFactory | |
JobQueueGroup | $queueGroup | |
BagOStuff | $stash | |
HashBagOStuff | $cache | |
ReadOnlyMode | $readOnlyMode | |
NamespaceInfo | $nsInfo | |
RevisionLookup | $revisionLookup | |
LinkBatchFactory | $linkBatchFactory | |
StatsFactory | $statsFactory |
Definition at line 140 of file WatchedItemStore.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and MediaWiki\Config\ServiceOptions\get().
WatchedItemStore::addWatch | ( | UserIdentity | $user, |
$target, | |||
?string | $expiry = null ) |
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
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 WatchedItemStoreInterface.
Definition at line 998 of file WatchedItemStore.php.
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 | |
LinkTarget[] | $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 WatchedItemStoreInterface.
Definition at line 1034 of file WatchedItemStore.php.
WatchedItemStore::clearUserWatchedItems | ( | UserIdentity | $user | ) |
Deletes ALL watched items for the given user when under $updateRowsPerQuery entries exist.
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 317 of file WatchedItemStore.php.
WatchedItemStore::clearUserWatchedItemsUsingJobQueue | ( | UserIdentity | $user | ) |
Queues a job that will clear the users watchlist using the Job Queue.
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 400 of file WatchedItemStore.php.
References $job.
WatchedItemStore::countExpired | ( | ) |
Get the number of watchlist items that expire before the current time.
Implements WatchedItemStoreInterface.
Definition at line 1799 of file WatchedItemStore.php.
WatchedItemStore::countUnreadNotifications | ( | UserIdentity | $user, |
$unreadLimit = null ) |
UserIdentity | $user | |
int | null | $unreadLimit |
Implements WatchedItemStoreInterface.
Definition at line 1604 of file WatchedItemStore.php.
References Wikimedia\Rdbms\SelectQueryBuilder\fetchRowCount(), MediaWiki\User\UserIdentity\getId(), Wikimedia\Rdbms\SelectQueryBuilder\limit(), and Wikimedia\Rdbms\SelectQueryBuilder\select().
WatchedItemStore::countVisitingWatchers | ( | $target, | |
$threshold ) |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
string | int | $threshold |
Implements WatchedItemStoreInterface.
Definition at line 478 of file WatchedItemStore.php.
WatchedItemStore::countVisitingWatchersMultiple | ( | array | $targetsWithVisitThresholds, |
$minimumWatchers = null ) |
array | $targetsWithVisitThresholds | array of LinkTarget[]|PageIdentity[] (not type hinted since it annoys phan) - deprecated passing LinkTarget[] since 1.36 |
int | null | $minimumWatchers |
Implements WatchedItemStoreInterface.
Definition at line 614 of file WatchedItemStore.php.
WatchedItemStore::countWatchedItems | ( | UserIdentity | $user | ) |
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 438 of file WatchedItemStore.php.
WatchedItemStore::countWatchers | ( | $target | ) |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 456 of file WatchedItemStore.php.
WatchedItemStore::countWatchersMultiple | ( | array | $targets, |
array | $options = [] ) |
LinkTarget[] | PageIdentity[] | $targets | deprecated passing LinkTarget[] since 1.36 |
array | $options | Supported options are:
|
Implements WatchedItemStoreInterface.
Definition at line 569 of file WatchedItemStore.php.
WatchedItemStore::duplicateAllAssociatedEntries | ( | $oldTarget, | |
$newTarget ) |
LinkTarget | PageIdentity | $oldTarget | deprecated passing LinkTarget since 1.36 |
LinkTarget | PageIdentity | $newTarget | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 1636 of file WatchedItemStore.php.
WatchedItemStore::duplicateEntry | ( | $oldTarget, | |
$newTarget ) |
LinkTarget | PageIdentity | $oldTarget | deprecated passing LinkTarget since 1.36 |
LinkTarget | PageIdentity | $newTarget | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 1654 of file WatchedItemStore.php.
References Wikimedia\Rdbms\IDatabase\newReplaceQueryBuilder().
WatchedItemStore::getLatestNotificationTimestamp | ( | $timestamp, | |
UserIdentity | $user, | ||
$target ) |
string | null | $timestamp | |
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 1276 of file WatchedItemStore.php.
References wfTimestampOrNull().
WatchedItemStore::getMaxId | ( | ) |
WatchedItemStore::getNotificationTimestampsBatch | ( | UserIdentity | $user, |
array | $targets ) |
UserIdentity | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 941 of file WatchedItemStore.php.
WatchedItemStore::getWatchedItem | ( | UserIdentity | $user, |
$target ) |
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 701 of file WatchedItemStore.php.
References MediaWiki\User\UserIdentity\isRegistered().
Referenced by WatchAction\__construct().
WatchedItemStore::getWatchedItemsForUser | ( | UserIdentity | $user, |
array | $options = [] ) |
UserIdentity | $user | |
array | $options | Supported options are:
|
Implements WatchedItemStoreInterface.
Definition at line 780 of file WatchedItemStore.php.
WatchedItemStore::isTempWatched | ( | UserIdentity | $user, |
$target ) |
Check if the user is temporarily watching the page.
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 929 of file WatchedItemStore.php.
WatchedItemStore::isWatched | ( | UserIdentity | $user, |
$target ) |
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 918 of file WatchedItemStore.php.
WatchedItemStore::loadWatchedItem | ( | UserIdentity | $user, |
$target ) |
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 727 of file WatchedItemStore.php.
WatchedItemStore::loadWatchedItemsBatch | ( | UserIdentity | $user, |
array | $targets ) |
UserIdentity | $user | |
LinkTarget[] | PageIdentity[] | $targets | deprecated passing LinkTarget[] since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 738 of file WatchedItemStore.php.
References MediaWiki\User\UserIdentity\isRegistered().
WatchedItemStore::maybeEnqueueWatchlistExpiryJob | ( | ) |
Probabilistically add a job to purge the expired watchlist items, if watchlist expiration is enabled, based on the value of $wgWatchlistPurgeRate.
Implements WatchedItemStoreInterface.
Definition at line 408 of file WatchedItemStore.php.
WatchedItemStore::mustClearWatchedItemsUsingJobQueue | ( | UserIdentity | $user | ) |
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 362 of file WatchedItemStore.php.
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 183 of file WatchedItemStore.php.
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 WatchedItemStoreInterface.
Definition at line 1812 of file WatchedItemStore.php.
References Wikimedia\Rdbms\IDatabase\newDeleteQueryBuilder().
WatchedItemStore::removeWatch | ( | UserIdentity | $user, |
$target ) |
UserIdentity | $user | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 1186 of file WatchedItemStore.php.
WatchedItemStore::removeWatchBatchForUser | ( | UserIdentity | $user, |
array | $titles ) |
UserIdentity | $user | |
LinkTarget[] | PageIdentity[] | $titles | deprecated passing LinkTarget[] since 1.36 |
Implements WatchedItemStoreInterface.
Definition at line 502 of file WatchedItemStore.php.
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 WatchedItemStoreInterface.
Definition at line 1304 of file WatchedItemStore.php.
References $job, MediaWiki\User\UserIdentity\getId(), and MediaWiki\User\UserIdentity\isRegistered().
WatchedItemStore::resetNotificationTimestamp | ( | UserIdentity | $user, |
$title, | |||
$force = '', | |||
$oldid = 0 ) |
UserIdentity | $user | |
LinkTarget | PageIdentity | $title | deprecated passing LinkTarget since 1.36 |
string | $force | |
int | $oldid |
Implements WatchedItemStoreInterface.
Definition at line 1402 of file WatchedItemStore.php.
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) |
LinkTarget[] | $targets | Titles to set the timestamp for; [] means the entire watchlist |
Implements WatchedItemStoreInterface.
Definition at line 1207 of file WatchedItemStore.php.
WatchedItemStore::updateNotificationTimestamp | ( | UserIdentity | $editor, |
$target, | |||
$timestamp ) |
Update wl_notificationtimestamp for all watching users except the editor.
UserIdentity | $editor | |
LinkTarget | PageIdentity | $target | deprecated passing LinkTarget since 1.36 |
string | int | $timestamp |
Implements WatchedItemStoreInterface.
Definition at line 1333 of file WatchedItemStore.php.
const WatchedItemStore::CONSTRUCTOR_OPTIONS |
Definition at line 41 of file WatchedItemStore.php.