MediaWiki REL1_31
|
Storage layer class for WatchedItems. More...
Public Member Functions | |
__construct (LoadBalancer $loadBalancer, 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) | |
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) | |
resetAllNotificationTimestampsForUser (User $user) | |
Reset all watchlist notificaton timestamps for a user using the job queue. | |
resetNotificationTimestamp (User $user, Title $title, $force='', $oldid=0) | |
setNotificationTimestampsForUser (User $user, $timestamp, array $targets=[]) | |
setStatsdDataFactory (StatsdDataFactoryInterface $stats) | |
updateNotificationTimestamp (User $editor, LinkTarget $target, $timestamp) | |
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) | |
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) | |
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 |
LoadBalancer | $loadBalancer |
ReadOnlyMode | $readOnlyMode |
callable null | $revisionGetTimestampFromIdCallback |
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 | ( | LoadBalancer | $loadBalancer, |
HashBagOStuff | $cache, | ||
ReadOnlyMode | $readOnlyMode, | ||
$updateRowsPerQuery ) |
LoadBalancer | $loadBalancer | |
HashBagOStuff | $cache | |
ReadOnlyMode | $readOnlyMode | |
int | $updateRowsPerQuery |
Definition at line 70 of file WatchedItemStore.php.
References $cache, $loadBalancer, $readOnlyMode, $updateRowsPerQuery, and cache.
WatchedItemStore::addWatch | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 653 of file WatchedItemStore.php.
References addWatchBatchForUser().
WatchedItemStore::addWatchBatchForUser | ( | User | $user, |
array | $targets ) |
User | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 663 of file WatchedItemStore.php.
References $rows, cache, DB_MASTER, getConnectionRef(), and uncache().
Referenced by addWatch().
|
private |
Definition at line 149 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 234 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 281 of file WatchedItemStore.php.
References $job, getMaxId(), ClearUserWatchlistJob\newForUser(), and JobQueueGroup\singleton().
WatchedItemStore::countUnreadNotifications | ( | User | $user, |
$unreadLimit = null ) |
User | $user | |
int | null | $unreadLimit |
Implements WatchedItemStoreInterface.
Definition at line 955 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
WatchedItemStore::countVisitingWatchers | ( | LinkTarget | $target, |
$threshold ) |
LinkTarget | $target | |
string | int | $threshold |
Implements WatchedItemStoreInterface.
Definition at line 346 of file WatchedItemStore.php.
References $dbr, 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 406 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, getConnectionRef(), getVisitingWatchersCondition(), and list.
WatchedItemStore::countWatchedItems | ( | User | $user | ) |
User | $user |
Implements WatchedItemStoreInterface.
Definition at line 306 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItems().
WatchedItemStore::countWatchers | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 325 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
WatchedItemStore::countWatchersMultiple | ( | array | $targets, |
array | $options = [] ) |
LinkTarget[] | $targets | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 370 of file WatchedItemStore.php.
References $dbr, $options, $res, 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 206 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 990 of file WatchedItemStore.php.
References duplicateEntry().
WatchedItemStore::duplicateEntry | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget ) |
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Implements WatchedItemStoreInterface.
Definition at line 1003 of file WatchedItemStore.php.
References DB_MASTER, and getConnectionRef().
Referenced by duplicateAllAssociatedEntries().
|
private |
User | $user | |
LinkTarget | $target |
Definition at line 193 of file WatchedItemStore.php.
References cache, and getCacheKey().
Referenced by getNotificationTimestampsBatch(), and getWatchedItem().
|
private |
Definition at line 141 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 220 of file WatchedItemStore.php.
Referenced by addWatchBatchForUser(), countUnreadNotifications(), countVisitingWatchers(), countVisitingWatchersMultiple(), countWatchedItems(), countWatchers(), countWatchersMultiple(), duplicateEntry(), getMaxId(), getNotificationTimestampsBatch(), getWatchedItemsForUser(), loadWatchedItem(), removeWatch(), setNotificationTimestampsForUser(), and updateNotificationTimestamp().
WatchedItemStore::getMaxId | ( | ) |
Definition at line 291 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItemsUsingJobQueue().
|
private |
Definition at line 902 of file WatchedItemStore.php.
References getNotificationTimestamp(), and loadWatchedItem().
Referenced by getNotificationTimestamp().
WatchedItemStore::getNotificationTimestampsBatch | ( | User | $user, |
array | $targets ) |
User | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 602 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, getCached(), getConnectionRef(), and wfTimestampOrNull().
|
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 451 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 494 of file WatchedItemStore.php.
References getCached(), and loadWatchedItem().
Referenced by isWatched().
WatchedItemStore::getWatchedItemsForUser | ( | User | $user, |
array | $options = [] ) |
User | $user | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 548 of file WatchedItemStore.php.
References $options, $res, DB_MASTER, DB_REPLICA, false, and getConnectionRef().
WatchedItemStore::isWatched | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 592 of file WatchedItemStore.php.
References getWatchedItem().
WatchedItemStore::loadWatchedItem | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 514 of file WatchedItemStore.php.
References $dbr, cache, DB_REPLICA, dbCond(), getConnectionRef(), and wfTimestampOrNull().
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 105 of file WatchedItemStore.php.
References $deferredUpdatesAddCallableUpdateCallback.
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 128 of file WatchedItemStore.php.
References $revisionGetTimestampFromIdCallback.
WatchedItemStore::removeWatch | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 715 of file WatchedItemStore.php.
References $success, DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and uncache().
WatchedItemStore::resetAllNotificationTimestampsForUser | ( | User | $user | ) |
Reset all watchlist notificaton timestamps for a user using the job queue.
User | $user | The user to reset the timestamps for |
Implements WatchedItemStoreInterface.
Definition at line 773 of file WatchedItemStore.php.
References $job.
Implements WatchedItemStoreInterface.
Definition at line 863 of file WatchedItemStore.php.
References $job, loadWatchedItem(), and uncache().
WatchedItemStore::setNotificationTimestampsForUser | ( | User | $user, |
$timestamp, | |||
array | $targets = [] ) |
User | $user | |
string | int | $timestamp | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 743 of file WatchedItemStore.php.
References $batch, $success, DB_MASTER, getConnectionRef(), and uncacheUser().
WatchedItemStore::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $stats | ) |
StatsdDataFactoryInterface | $stats |
Implements StatsdAwareInterface.
Definition at line 90 of file WatchedItemStore.php.
References $stats.
|
private |
Definition at line 158 of file WatchedItemStore.php.
References cache, getCacheKey(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by addWatchBatchForUser(), removeWatch(), and resetNotificationTimestamp().
|
private |
Definition at line 250 of file WatchedItemStore.php.
References cache.
Referenced by clearUserWatchedItems().
|
private |
Definition at line 164 of file WatchedItemStore.php.
References cache, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by updateNotificationTimestamp().
|
private |
Definition at line 175 of file WatchedItemStore.php.
References cache.
Referenced by setNotificationTimestampsForUser().
WatchedItemStore::updateNotificationTimestamp | ( | User | $editor, |
LinkTarget | $target, | ||
$timestamp ) |
User | $editor | |
LinkTarget | $target | |
string | int | $timestamp |
Implements WatchedItemStoreInterface.
Definition at line 802 of file WatchedItemStore.php.
References $editor, $fname, $wgUpdateRowsPerQuery, DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and uncacheLinkTarget().
|
private |
Definition at line 34 of file WatchedItemStore.php.
Referenced by __construct().
|
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 42 of file WatchedItemStore.php.
|
private |
Definition at line 47 of file WatchedItemStore.php.
Referenced by overrideDeferredUpdatesAddCallableUpdateCallback().
|
private |
Definition at line 24 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 29 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 52 of file WatchedItemStore.php.
Referenced by overrideRevisionGetTimestampFromIdCallback().
|
private |
Definition at line 62 of file WatchedItemStore.php.
Referenced by setStatsdDataFactory().
|
private |
Definition at line 57 of file WatchedItemStore.php.
Referenced by __construct().