MediaWiki REL1_32
|
Storage layer class for WatchedItems. More...
Public Member Functions | |
__construct (ILBFactory $lbFactory, 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 |
ILBFactory | $lbFactory |
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 | ( | ILBFactory | $lbFactory, |
HashBagOStuff | $cache, | ||
ReadOnlyMode | $readOnlyMode, | ||
$updateRowsPerQuery ) |
ILBFactory | $lbFactory | |
HashBagOStuff | $cache | |
ReadOnlyMode | $readOnlyMode | |
int | $updateRowsPerQuery |
Definition at line 75 of file WatchedItemStore.php.
References $cache, $lbFactory, $readOnlyMode, $updateRowsPerQuery, cache, and Wikimedia\Rdbms\ILBFactory\getMainLB().
WatchedItemStore::addWatch | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 659 of file WatchedItemStore.php.
References addWatchBatchForUser().
User | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 669 of file WatchedItemStore.php.
References $rows, cache, DB_MASTER, getConnectionRef(), and uncache().
Referenced by addWatch().
|
private |
Definition at line 155 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 240 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 287 of file WatchedItemStore.php.
References $job, getMaxId(), and ClearUserWatchlistJob\newForUser().
WatchedItemStore::countUnreadNotifications | ( | User | $user, |
$unreadLimit = null ) |
User | $user | |
int | null | $unreadLimit |
Implements WatchedItemStoreInterface.
Definition at line 958 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 352 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 412 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, getConnectionRef(), getVisitingWatchersCondition(), and list.
WatchedItemStore::countWatchedItems | ( | User | $user | ) |
User | $user |
Implements WatchedItemStoreInterface.
Definition at line 312 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItems().
WatchedItemStore::countWatchers | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 331 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
LinkTarget[] | $targets | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 376 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 212 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 993 of file WatchedItemStore.php.
References duplicateEntry().
WatchedItemStore::duplicateEntry | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget ) |
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Implements WatchedItemStoreInterface.
Definition at line 1006 of file WatchedItemStore.php.
References DB_MASTER, and getConnectionRef().
Referenced by duplicateAllAssociatedEntries().
|
private |
User | $user | |
LinkTarget | $target |
Definition at line 199 of file WatchedItemStore.php.
References cache, and getCacheKey().
Referenced by getNotificationTimestampsBatch(), and getWatchedItem().
|
private |
Definition at line 147 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 226 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 297 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItemsUsingJobQueue().
|
private |
Definition at line 905 of file WatchedItemStore.php.
References getNotificationTimestamp(), and loadWatchedItem().
Referenced by getNotificationTimestamp().
User | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 608 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 457 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 500 of file WatchedItemStore.php.
References getCached(), and loadWatchedItem().
Referenced by isWatched().
User | $user | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 554 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 598 of file WatchedItemStore.php.
References getWatchedItem().
WatchedItemStore::loadWatchedItem | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 520 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 111 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 134 of file WatchedItemStore.php.
References $revisionGetTimestampFromIdCallback.
WatchedItemStore::removeWatch | ( | User | $user, |
LinkTarget | $target ) |
User | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 721 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 779 of file WatchedItemStore.php.
References $job.
Implements WatchedItemStoreInterface.
Definition at line 866 of file WatchedItemStore.php.
References $job, loadWatchedItem(), and uncache().
User | $user | |
string | int | $timestamp | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 749 of file WatchedItemStore.php.
References $batch, $success, DB_MASTER, getConnectionRef(), and uncacheUser().
WatchedItemStore::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $stats | ) |
StatsdDataFactoryInterface | $stats |
Implements StatsdAwareInterface.
Definition at line 96 of file WatchedItemStore.php.
References $stats.
|
private |
Definition at line 164 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 256 of file WatchedItemStore.php.
References cache.
Referenced by clearUserWatchedItems().
|
private |
Definition at line 170 of file WatchedItemStore.php.
References cache, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by updateNotificationTimestamp().
|
private |
Definition at line 181 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 808 of file WatchedItemStore.php.
References $editor, $fname, DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and uncacheLinkTarget().
|
private |
Definition at line 39 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 47 of file WatchedItemStore.php.
|
private |
Definition at line 52 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.
|
private |
Definition at line 34 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 57 of file WatchedItemStore.php.
Referenced by overrideRevisionGetTimestampFromIdCallback().
|
private |
Definition at line 67 of file WatchedItemStore.php.
Referenced by setStatsdDataFactory().
|
private |
Definition at line 62 of file WatchedItemStore.php.
Referenced by __construct().