MediaWiki REL1_33
|
Storage layer class for WatchedItems. More...
Public Member Functions | |
__construct (ILBFactory $lbFactory, JobQueueGroup $queueGroup, BagOStuff $stash, HashBagOStuff $cache, ReadOnlyMode $readOnlyMode, $updateRowsPerQuery) | |
addWatch (User $user, LinkTarget $target) | |
addWatchBatchForUser (User $user, array $targets) | |
clearUserWatchedItems (User $user) | |
Deletes ALL watched items for the given user when under $updateRowsPerQuery entries exist. | |
clearUserWatchedItemsUsingJobQueue (User $user) | |
Queues a job that will clear the users watchlist using the Job Queue. | |
countUnreadNotifications (User $user, $unreadLimit=null) | |
countVisitingWatchers (LinkTarget $target, $threshold) | |
countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null) | |
countWatchedItems (User $user) | |
countWatchers (LinkTarget $target) | |
countWatchersMultiple (array $targets, array $options=[]) | |
duplicateAllAssociatedEntries (LinkTarget $oldTarget, LinkTarget $newTarget) | |
duplicateEntry (LinkTarget $oldTarget, LinkTarget $newTarget) | |
getLatestNotificationTimestamp ( $timestamp, User $user, LinkTarget $target) | |
Convert $timestamp to TS_MW or return null if the page was visited since then by $user. | |
getMaxId () | |
getNotificationTimestampsBatch (User $user, array $targets) | |
getWatchedItem (User $user, LinkTarget $target) | |
getWatchedItemsForUser (User $user, array $options=[]) | |
isWatched (User $user, LinkTarget $target) | |
loadWatchedItem (User $user, LinkTarget $target) | |
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. | |
overrideRevisionGetTimestampFromIdCallback (callable $callback) | |
Overrides the Revision::getTimestampFromId callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined. | |
removeWatch (User $user, LinkTarget $target) | |
removeWatchBatchForUser (User $user, array $titles) | |
resetAllNotificationTimestampsForUser (User $user, $timestamp=null) | |
Schedule a DeferredUpdate that sets all of the "last viewed" timestamps for a given user to the same value. | |
resetNotificationTimestamp (User $user, Title $title, $force='', $oldid=0) | |
setNotificationTimestampsForUser (User $user, $timestamp, array $targets=[]) | |
Set the "last viewed" timestamps for certain titles on a user's watchlist. | |
setStatsdDataFactory (StatsdDataFactoryInterface $stats) | |
updateNotificationTimestamp (User $editor, LinkTarget $target, $timestamp) | |
Public Member Functions inherited from WatchedItemStoreInterface | |
resetAllNotificationTimestampsForUser (User $user) | |
Reset all watchlist notificaton timestamps for a user using the job queue. | |
Private Member Functions | |
cache (WatchedItem $item) | |
dbCond (User $user, LinkTarget $target) | |
Return an array of conditions to select or update the appropriate database row. | |
getCached (User $user, LinkTarget $target) | |
getCacheKey (User $user, LinkTarget $target) | |
getConnectionRef ( $dbIndex) | |
getNotificationTimestamp (User $user, Title $title, $item, $force, $oldid) | |
getPageSeenKey (LinkTarget $target) | |
getPageSeenTimestamps (User $user) | |
getPageSeenTimestampsKey (User $user) | |
getTitleDbKeysGroupedByNamespace (array $titles) | |
getVisitingWatchersCondition (IDatabase $db, array $targetsWithVisitThresholds) | |
Generates condition for the query used in a batch count visiting watchers. | |
uncache (User $user, LinkTarget $target) | |
uncacheAllItemsForUser (User $user) | |
uncacheLinkTarget (LinkTarget $target) | |
uncacheTitlesForUser (User $user, array $titles) | |
uncacheUser (User $user) | |
Private Attributes | |
HashBagOStuff | $cache |
array[] | $cacheIndex = [] |
Looks like $cacheIndex[Namespace ID][Target DB Key][User Id] => 'key' The index is needed so that on mass changes all relevant items can be un-cached. | |
callable null | $deferredUpdatesAddCallableUpdateCallback |
HashBagOStuff | $latestUpdateCache |
ILBFactory | $lbFactory |
LoadBalancer | $loadBalancer |
JobQueueGroup | $queueGroup |
ReadOnlyMode | $readOnlyMode |
callable null | $revisionGetTimestampFromIdCallback |
BagOStuff | $stash |
StatsdDataFactoryInterface | $stats |
int | $updateRowsPerQuery |
Additional Inherited Members | |
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 19 of file WatchedItemStore.php.
WatchedItemStore::__construct | ( | ILBFactory | $lbFactory, |
JobQueueGroup | $queueGroup, | ||
BagOStuff | $stash, | ||
HashBagOStuff | $cache, | ||
ReadOnlyMode | $readOnlyMode, | ||
$updateRowsPerQuery ) |
ILBFactory | $lbFactory | |
JobQueueGroup | $queueGroup | |
BagOStuff | $stash | |
HashBagOStuff | $cache | |
ReadOnlyMode | $readOnlyMode | |
int | $updateRowsPerQuery |
Definition at line 92 of file WatchedItemStore.php.
References $cache, $lbFactory, $queueGroup, $readOnlyMode, $stash, $updateRowsPerQuery, cache, and Wikimedia\Rdbms\ILBFactory\getMainLB().
WatchedItemStore::addWatch | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
MWException |
Implements WatchedItemStoreInterface.
Definition at line 735 of file WatchedItemStore.php.
References addWatchBatchForUser().
User | $user | |
LinkTarget[] | $targets |
MWException |
Implements WatchedItemStoreInterface.
Definition at line 746 of file WatchedItemStore.php.
References $rows, and(), cache, DB_MASTER, getConnectionRef(), and uncache().
Referenced by addWatch().
|
private |
Definition at line 178 of file WatchedItemStore.php.
References cache, and getCacheKey().
WatchedItemStore::clearUserWatchedItems | ( | User | $user | ) |
Deletes ALL watched items for the given user when under $updateRowsPerQuery entries exist.
User | $user |
Implements WatchedItemStoreInterface.
Definition at line 267 of file WatchedItemStore.php.
References countWatchedItems(), DB_MASTER, and uncacheAllItemsForUser().
WatchedItemStore::clearUserWatchedItemsUsingJobQueue | ( | User | $user | ) |
Queues a job that will clear the users watchlist using the Job Queue.
User | $user |
Implements WatchedItemStoreInterface.
Definition at line 314 of file WatchedItemStore.php.
References $job, getMaxId(), and ClearUserWatchlistJob\newForUser().
User | $user | |
int | null | $unreadLimit |
Implements WatchedItemStoreInterface.
Definition at line 1145 of file WatchedItemStore.php.
References $dbr, and(), DB_REPLICA, and getConnectionRef().
WatchedItemStore::countVisitingWatchers | ( | LinkTarget | $target, |
$threshold ) |
LinkTarget | $target | |
string | int | $threshold |
Implements WatchedItemStoreInterface.
Definition at line 378 of file WatchedItemStore.php.
References $dbr, and(), DB_REPLICA, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
WatchedItemStore::countVisitingWatchersMultiple | ( | array | $targetsWithVisitThresholds, |
$minimumWatchers = null ) |
array | $targetsWithVisitThresholds | |
int | null | $minimumWatchers |
Implements WatchedItemStoreInterface.
Definition at line 482 of file WatchedItemStore.php.
References $dbr, $res, and(), DB_REPLICA, getConnectionRef(), getVisitingWatchersCondition(), and list.
WatchedItemStore::countWatchedItems | ( | User | $user | ) |
User | $user |
Implements WatchedItemStoreInterface.
Definition at line 338 of file WatchedItemStore.php.
References $dbr, and(), DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItems().
WatchedItemStore::countWatchers | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 357 of file WatchedItemStore.php.
References $dbr, and(), DB_REPLICA, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
LinkTarget[] | $targets | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 446 of file WatchedItemStore.php.
References $dbr, $options, $res, and(), DB_REPLICA, and getConnectionRef().
|
private |
Return an array of conditions to select or update the appropriate database row.
User | $user | |
LinkTarget | $target |
Definition at line 239 of file WatchedItemStore.php.
References MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by loadWatchedItem().
WatchedItemStore::duplicateAllAssociatedEntries | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget ) |
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Implements WatchedItemStoreInterface.
Definition at line 1177 of file WatchedItemStore.php.
References duplicateEntry().
WatchedItemStore::duplicateEntry | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget ) |
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Implements WatchedItemStoreInterface.
Definition at line 1190 of file WatchedItemStore.php.
References and(), DB_MASTER, and getConnectionRef().
Referenced by duplicateAllAssociatedEntries().
|
private |
User | $user | |
LinkTarget | $target |
Definition at line 226 of file WatchedItemStore.php.
References cache, and getCacheKey().
Referenced by getNotificationTimestampsBatch(), and getWatchedItem().
|
private |
Definition at line 170 of file WatchedItemStore.php.
References cache, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by cache(), getCached(), and uncache().
|
private |
int | $dbIndex | DB_MASTER or DB_REPLICA |
MWException |
Definition at line 253 of file WatchedItemStore.php.
Referenced by addWatchBatchForUser(), countUnreadNotifications(), countVisitingWatchers(), countVisitingWatchersMultiple(), countWatchedItems(), countWatchers(), countWatchersMultiple(), duplicateEntry(), getMaxId(), getNotificationTimestampsBatch(), getWatchedItemsForUser(), loadWatchedItem(), removeWatchBatchForUser(), setNotificationTimestampsForUser(), and updateNotificationTimestamp().
WatchedItemStore::getLatestNotificationTimestamp | ( | $timestamp, | |
User | $user, | ||
LinkTarget | $target ) |
Convert $timestamp to TS_MW or return null if the page was visited since then by $user.
Use this only on single-user methods (having higher read-after-write expectations) and not in places involving arbitrary batches of different users
Usage of this method should be limited to WatchedItem* classes
string | null | $timestamp | Value of wl_notificationtimestamp from the DB |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 876 of file WatchedItemStore.php.
References getPageSeenTimestamps(), and wfTimestampOrNull().
Referenced by getNotificationTimestampsBatch(), and loadWatchedItem().
WatchedItemStore::getMaxId | ( | ) |
Definition at line 323 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItemsUsingJobQueue().
|
private |
Definition at line 1092 of file WatchedItemStore.php.
References and(), getNotificationTimestamp(), and loadWatchedItem().
Referenced by getNotificationTimestamp().
User | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 681 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, getCached(), getConnectionRef(), and getLatestNotificationTimestamp().
|
private |
LinkTarget | $target |
Definition at line 1088 of file WatchedItemStore.php.
Referenced by resetNotificationTimestamp().
|
private |
User | $user |
Definition at line 1060 of file WatchedItemStore.php.
References getPageSeenTimestampsKey().
Referenced by getLatestNotificationTimestamp().
|
private |
User | $user |
Definition at line 1076 of file WatchedItemStore.php.
Referenced by getPageSeenTimestamps(), resetNotificationTimestamp(), and uncacheUser().
|
private |
LinkTarget[] | $titles |
Definition at line 1235 of file WatchedItemStore.php.
References $rows, and $titles.
Referenced by removeWatchBatchForUser(), and setNotificationTimestampsForUser().
|
private |
Generates condition for the query used in a batch count visiting watchers.
IDatabase | $db | |
array | $targetsWithVisitThresholds | array of pairs (LinkTarget, last visit threshold) |
Definition at line 527 of file WatchedItemStore.php.
References Wikimedia\Rdbms\IDatabase\addQuotes(), list, LIST_AND, LIST_OR, Wikimedia\Rdbms\IDatabase\makeList(), and Wikimedia\Rdbms\IDatabase\timestamp().
Referenced by countVisitingWatchersMultiple().
WatchedItemStore::getWatchedItem | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 570 of file WatchedItemStore.php.
References and(), getCached(), and loadWatchedItem().
Referenced by isWatched().
User | $user | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 625 of file WatchedItemStore.php.
References $options, $res, and(), DB_MASTER, DB_REPLICA, false, and getConnectionRef().
WatchedItemStore::isWatched | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 671 of file WatchedItemStore.php.
References getWatchedItem().
WatchedItemStore::loadWatchedItem | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 590 of file WatchedItemStore.php.
References $dbr, and(), cache, DB_REPLICA, dbCond(), getConnectionRef(), and getLatestNotificationTimestamp().
Referenced by getNotificationTimestamp(), getWatchedItem(), and resetNotificationTimestamp().
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 |
MWException |
Definition at line 134 of file WatchedItemStore.php.
References $deferredUpdatesAddCallableUpdateCallback, and and().
WatchedItemStore::overrideRevisionGetTimestampFromIdCallback | ( | callable | $callback | ) |
Overrides the Revision::getTimestampFromId callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
callable | $callback |
MWException |
Definition at line 157 of file WatchedItemStore.php.
References $revisionGetTimestampFromIdCallback, and and().
WatchedItemStore::removeWatch | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
MWException |
Implements WatchedItemStoreInterface.
Definition at line 807 of file WatchedItemStore.php.
References removeWatchBatchForUser().
User | $user | |
TitleValue[] | $titles |
MWException |
Implements WatchedItemStoreInterface.
Definition at line 402 of file WatchedItemStore.php.
References $rows, $titles, and(), DB_MASTER, getConnectionRef(), getTitleDbKeysGroupedByNamespace(), and uncacheTitlesForUser().
Referenced by removeWatch().
Schedule a DeferredUpdate that sets all of the "last viewed" timestamps for a given user to the same value.
User | $user | |
string | int | null | $timestamp | Value to set all timestamps to, null to clear them |
Definition at line 900 of file WatchedItemStore.php.
Referenced by setNotificationTimestampsForUser().
Implements WatchedItemStoreInterface.
Definition at line 987 of file WatchedItemStore.php.
References $cache, $job, $time, $value, and(), getPageSeenKey(), getPageSeenTimestampsKey(), loadWatchedItem(), uncache(), and wfTimestamp().
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).
User | $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 828 of file WatchedItemStore.php.
References $rows, and(), DB_MASTER, getConnectionRef(), getTitleDbKeysGroupedByNamespace(), resetAllNotificationTimestampsForUser(), and uncacheUser().
WatchedItemStore::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $stats | ) |
StatsdDataFactoryInterface | $stats |
Implements StatsdAwareInterface.
Definition at line 119 of file WatchedItemStore.php.
References $stats.
|
private |
Definition at line 187 of file WatchedItemStore.php.
References and(), cache, getCacheKey(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by addWatchBatchForUser(), resetNotificationTimestamp(), and uncacheTitlesForUser().
|
private |
Definition at line 283 of file WatchedItemStore.php.
Referenced by clearUserWatchedItems().
|
private |
Definition at line 193 of file WatchedItemStore.php.
References and(), cache, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by updateNotificationTimestamp().
Definition at line 1248 of file WatchedItemStore.php.
References $titles, and uncache().
Referenced by removeWatchBatchForUser().
|
private |
Definition at line 204 of file WatchedItemStore.php.
References and(), cache, and getPageSeenTimestampsKey().
Referenced by setNotificationTimestampsForUser().
WatchedItemStore::updateNotificationTimestamp | ( | User | $editor, |
LinkTarget | $target, | ||
$timestamp ) |
User | $editor | |
LinkTarget | $target | |
string | int | $timestamp |
Implements WatchedItemStoreInterface.
Definition at line 929 of file WatchedItemStore.php.
References $editor, $fname, and(), DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and uncacheLinkTarget().
|
private |
Definition at line 49 of file WatchedItemStore.php.
Referenced by __construct(), and resetNotificationTimestamp().
|
private |
Looks like $cacheIndex[Namespace ID][Target DB Key][User Id] => 'key' The index is needed so that on mass changes all relevant items can be un-cached.
For example: Clearing a users watchlist of all items or updating notification timestamps for all users watching a single target.
Definition at line 62 of file WatchedItemStore.php.
|
private |
Definition at line 67 of file WatchedItemStore.php.
Referenced by overrideDeferredUpdatesAddCallableUpdateCallback().
|
private |
Definition at line 54 of file WatchedItemStore.php.
|
private |
Definition at line 24 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 29 of file WatchedItemStore.php.
|
private |
Definition at line 34 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 44 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 72 of file WatchedItemStore.php.
Referenced by overrideRevisionGetTimestampFromIdCallback().
|
private |
Definition at line 39 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 82 of file WatchedItemStore.php.
Referenced by setStatsdDataFactory().
|
private |
Definition at line 77 of file WatchedItemStore.php.
Referenced by __construct().