MediaWiki REL1_34
|
Storage layer class for WatchedItems. More...
Public Member Functions | |
__construct (ILBFactory $lbFactory, JobQueueGroup $queueGroup, BagOStuff $stash, HashBagOStuff $cache, ReadOnlyMode $readOnlyMode, $updateRowsPerQuery, NamespaceInfo $nsInfo, RevisionLookup $revisionLookup) | |
addWatch (UserIdentity $user, LinkTarget $target) | |
addWatchBatchForUser (UserIdentity $user, array $targets) | |
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. | |
countUnreadNotifications (UserIdentity $user, $unreadLimit=null) | |
countVisitingWatchers (LinkTarget $target, $threshold) | |
countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null) | |
countWatchedItems (UserIdentity $user) | |
countWatchers (LinkTarget $target) | |
countWatchersMultiple (array $targets, array $options=[]) | |
duplicateAllAssociatedEntries (LinkTarget $oldTarget, LinkTarget $newTarget) | |
duplicateEntry (LinkTarget $oldTarget, LinkTarget $newTarget) | |
getLatestNotificationTimestamp ( $timestamp, UserIdentity $user, LinkTarget $target) | |
Convert $timestamp to TS_MW or return null if the page was visited since then by $user. | |
getMaxId () | |
getNotificationTimestampsBatch (UserIdentity $user, array $targets) | |
getWatchedItem (UserIdentity $user, LinkTarget $target) | |
getWatchedItemsForUser (UserIdentity $user, array $options=[]) | |
isWatched (UserIdentity $user, LinkTarget $target) | |
loadWatchedItem (UserIdentity $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. | |
removeWatch (UserIdentity $user, LinkTarget $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, LinkTarget $title, $force='', $oldid=0) | |
setNotificationTimestampsForUser (UserIdentity $user, $timestamp, array $targets=[]) | |
Set the "last viewed" timestamps for certain titles on a user's watchlist. | |
setStatsdDataFactory (StatsdDataFactoryInterface $stats) | |
updateNotificationTimestamp (UserIdentity $editor, LinkTarget $target, $timestamp) | |
Public Member Functions inherited from WatchedItemStoreInterface | |
resetAllNotificationTimestampsForUser (UserIdentity $user) | |
Reset all watchlist notificaton timestamps for a user using the job queue. | |
Private Member Functions | |
cache (WatchedItem $item) | |
dbCond (UserIdentity $user, LinkTarget $target) | |
Return an array of conditions to select or update the appropriate database row. | |
getCached (UserIdentity $user, LinkTarget $target) | |
getCacheKey (UserIdentity $user, LinkTarget $target) | |
getConnectionRef ( $dbIndex) | |
getNotificationTimestamp (UserIdentity $user, LinkTarget $title, $item, $force, $oldid) | |
getPageSeenKey (LinkTarget $target) | |
getPageSeenTimestamps (UserIdentity $user) | |
getPageSeenTimestampsKey (UserIdentity $user) | |
getTitleDbKeysGroupedByNamespace (array $titles) | |
getVisitingWatchersCondition (IDatabase $db, array $targetsWithVisitThresholds) | |
Generates condition for the query used in a batch count visiting watchers. | |
uncache (UserIdentity $user, LinkTarget $target) | |
uncacheAllItemsForUser (UserIdentity $user) | |
uncacheLinkTarget (LinkTarget $target) | |
uncacheTitlesForUser (UserIdentity $user, array $titles) | |
uncacheUser (UserIdentity $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 |
NamespaceInfo | $nsInfo |
JobQueueGroup | $queueGroup |
ReadOnlyMode | $readOnlyMode |
RevisionLookup | $revisionLookup |
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 21 of file WatchedItemStore.php.
WatchedItemStore::__construct | ( | ILBFactory | $lbFactory, |
JobQueueGroup | $queueGroup, | ||
BagOStuff | $stash, | ||
HashBagOStuff | $cache, | ||
ReadOnlyMode | $readOnlyMode, | ||
$updateRowsPerQuery, | |||
NamespaceInfo | $nsInfo, | ||
RevisionLookup | $revisionLookup | ||
) |
ILBFactory | $lbFactory | |
JobQueueGroup | $queueGroup | |
BagOStuff | $stash | |
HashBagOStuff | $cache | |
ReadOnlyMode | $readOnlyMode | |
int | $updateRowsPerQuery | |
NamespaceInfo | $nsInfo | |
RevisionLookup | $revisionLookup |
Definition at line 101 of file WatchedItemStore.php.
References $cache, $lbFactory, $nsInfo, $queueGroup, $readOnlyMode, $revisionLookup, $stash, $updateRowsPerQuery, cache(), and Wikimedia\Rdbms\ILBFactory\getMainLB().
WatchedItemStore::addWatch | ( | UserIdentity | $user, |
LinkTarget | $target | ||
) |
UserIdentity | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 720 of file WatchedItemStore.php.
References addWatchBatchForUser().
WatchedItemStore::addWatchBatchForUser | ( | UserIdentity | $user, |
array | $targets | ||
) |
UserIdentity | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 730 of file WatchedItemStore.php.
References cache(), DB_MASTER, getConnectionRef(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\isRegistered(), and uncache().
Referenced by addWatch().
|
private |
Definition at line 166 of file WatchedItemStore.php.
References cache(), getCacheKey(), WatchedItem\getLinkTarget(), and WatchedItem\getUserIdentity().
Referenced by __construct(), addWatchBatchForUser(), cache(), getCached(), getCacheKey(), loadWatchedItem(), uncache(), uncacheAllItemsForUser(), uncacheLinkTarget(), and uncacheUser().
WatchedItemStore::clearUserWatchedItems | ( | UserIdentity | $user | ) |
Deletes ALL watched items for the given user when under $updateRowsPerQuery entries exist.
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 254 of file WatchedItemStore.php.
References countWatchedItems(), DB_MASTER, MediaWiki\User\UserIdentity\getId(), and uncacheAllItemsForUser().
WatchedItemStore::clearUserWatchedItemsUsingJobQueue | ( | UserIdentity | $user | ) |
Queues a job that will clear the users watchlist using the Job Queue.
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 301 of file WatchedItemStore.php.
References $job, getMaxId(), and ClearUserWatchlistJob\newForUser().
WatchedItemStore::countUnreadNotifications | ( | UserIdentity | $user, |
$unreadLimit = null |
|||
) |
UserIdentity | $user | |
int | null | $unreadLimit |
Implements WatchedItemStoreInterface.
Definition at line 1168 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, getConnectionRef(), and MediaWiki\User\UserIdentity\getId().
WatchedItemStore::countVisitingWatchers | ( | LinkTarget | $target, |
$threshold | |||
) |
LinkTarget | $target | |
string | int | $threshold |
Implements WatchedItemStoreInterface.
Definition at line 365 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 468 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, getConnectionRef(), and getVisitingWatchersCondition().
WatchedItemStore::countWatchedItems | ( | UserIdentity | $user | ) |
UserIdentity | $user |
Implements WatchedItemStoreInterface.
Definition at line 325 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, getConnectionRef(), and MediaWiki\User\UserIdentity\getId().
Referenced by clearUserWatchedItems().
WatchedItemStore::countWatchers | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 344 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 432 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, and getConnectionRef().
|
private |
Return an array of conditions to select or update the appropriate database row.
UserIdentity | $user | |
LinkTarget | $target |
Definition at line 227 of file WatchedItemStore.php.
References MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\User\UserIdentity\getId(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by loadWatchedItem().
WatchedItemStore::duplicateAllAssociatedEntries | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget | ||
) |
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Implements WatchedItemStoreInterface.
Definition at line 1200 of file WatchedItemStore.php.
References duplicateEntry().
WatchedItemStore::duplicateEntry | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget | ||
) |
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Implements WatchedItemStoreInterface.
Definition at line 1217 of file WatchedItemStore.php.
References DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by duplicateAllAssociatedEntries().
|
private |
UserIdentity | $user | |
LinkTarget | $target |
Definition at line 214 of file WatchedItemStore.php.
References cache(), and getCacheKey().
Referenced by getNotificationTimestampsBatch(), and getWatchedItem().
|
private |
Definition at line 158 of file WatchedItemStore.php.
References cache(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\User\UserIdentity\getId(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by cache(), getCached(), and uncache().
|
private |
int | $dbIndex | DB_MASTER or DB_REPLICA |
Definition at line 240 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, | |
UserIdentity | $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 |
UserIdentity | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 861 of file WatchedItemStore.php.
References getPageSeenTimestamps(), and wfTimestampOrNull().
Referenced by getNotificationTimestampsBatch(), getWatchedItemsForUser(), and loadWatchedItem().
WatchedItemStore::getMaxId | ( | ) |
Definition at line 310 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, and getConnectionRef().
Referenced by clearUserWatchedItemsUsingJobQueue().
|
private |
UserIdentity | $user | |
LinkTarget | $title | |
WatchedItem | $item | |
bool | $force | |
int | bool | $oldid | The ID of the last revision that the user viewed |
Definition at line 1109 of file WatchedItemStore.php.
References $title, getNotificationTimestamp(), and loadWatchedItem().
Referenced by getNotificationTimestamp().
WatchedItemStore::getNotificationTimestampsBatch | ( | UserIdentity | $user, |
array | $targets | ||
) |
UserIdentity | $user | |
LinkTarget[] | $targets |
Implements WatchedItemStoreInterface.
Definition at line 667 of file WatchedItemStore.php.
References $dbr, $res, DB_REPLICA, getCached(), getConnectionRef(), MediaWiki\User\UserIdentity\getId(), getLatestNotificationTimestamp(), and MediaWiki\User\UserIdentity\isRegistered().
|
private |
LinkTarget | $target |
Definition at line 1097 of file WatchedItemStore.php.
Referenced by resetNotificationTimestamp().
|
private |
UserIdentity | $user |
Definition at line 1069 of file WatchedItemStore.php.
References getPageSeenTimestampsKey().
Referenced by getLatestNotificationTimestamp().
|
private |
UserIdentity | $user |
Definition at line 1085 of file WatchedItemStore.php.
References MediaWiki\User\UserIdentity\getId().
Referenced by getPageSeenTimestamps(), resetNotificationTimestamp(), and uncacheUser().
|
private |
LinkTarget[] | $titles |
Definition at line 1262 of file WatchedItemStore.php.
References $title.
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 513 of file WatchedItemStore.php.
References Wikimedia\Rdbms\IDatabase\addQuotes(), LIST_AND, LIST_OR, Wikimedia\Rdbms\IDatabase\makeList(), and Wikimedia\Rdbms\IDatabase\timestamp().
Referenced by countVisitingWatchersMultiple().
WatchedItemStore::getWatchedItem | ( | UserIdentity | $user, |
LinkTarget | $target | ||
) |
UserIdentity | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 556 of file WatchedItemStore.php.
References getCached(), MediaWiki\User\UserIdentity\isRegistered(), and loadWatchedItem().
Referenced by isWatched().
WatchedItemStore::getWatchedItemsForUser | ( | UserIdentity | $user, |
array | $options = [] |
||
) |
UserIdentity | $user | |
array | $options |
Implements WatchedItemStoreInterface.
Definition at line 611 of file WatchedItemStore.php.
References $res, DB_MASTER, DB_REPLICA, getConnectionRef(), MediaWiki\User\UserIdentity\getId(), and getLatestNotificationTimestamp().
WatchedItemStore::isWatched | ( | UserIdentity | $user, |
LinkTarget | $target | ||
) |
UserIdentity | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 657 of file WatchedItemStore.php.
References getWatchedItem().
WatchedItemStore::loadWatchedItem | ( | UserIdentity | $user, |
LinkTarget | $target | ||
) |
UserIdentity | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 576 of file WatchedItemStore.php.
References $dbr, cache(), DB_REPLICA, dbCond(), getConnectionRef(), getLatestNotificationTimestamp(), and MediaWiki\User\UserIdentity\isRegistered().
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 145 of file WatchedItemStore.php.
References $deferredUpdatesAddCallableUpdateCallback.
WatchedItemStore::removeWatch | ( | UserIdentity | $user, |
LinkTarget | $target | ||
) |
UserIdentity | $user | |
LinkTarget | $target |
Implements WatchedItemStoreInterface.
Definition at line 790 of file WatchedItemStore.php.
References removeWatchBatchForUser().
WatchedItemStore::removeWatchBatchForUser | ( | UserIdentity | $user, |
array | $titles | ||
) |
UserIdentity | $user | |
LinkTarget[] | $titles |
Implements WatchedItemStoreInterface.
Definition at line 388 of file WatchedItemStore.php.
References DB_MASTER, getConnectionRef(), MediaWiki\User\UserIdentity\getId(), getTitleDbKeysGroupedByNamespace(), MediaWiki\User\UserIdentity\isRegistered(), and uncacheTitlesForUser().
Referenced by removeWatch().
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 |
Definition at line 887 of file WatchedItemStore.php.
References $job, MediaWiki\User\UserIdentity\getId(), and MediaWiki\User\UserIdentity\isRegistered().
Referenced by setNotificationTimestampsForUser().
WatchedItemStore::resetNotificationTimestamp | ( | UserIdentity | $user, |
LinkTarget | $title, | ||
$force = '' , |
|||
$oldid = 0 |
|||
) |
UserIdentity | $user | |
LinkTarget | $title | |
string | $force | |
int | $oldid |
Implements WatchedItemStoreInterface.
Definition at line 975 of file WatchedItemStore.php.
References $cache, $job, $title, MediaWiki\User\UserIdentity\getId(), getPageSeenKey(), getPageSeenTimestampsKey(), MediaWiki\User\UserIdentity\isRegistered(), loadWatchedItem(), User\newFromId(), uncache(), and wfTimestamp().
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 811 of file WatchedItemStore.php.
References DB_MASTER, getConnectionRef(), MediaWiki\User\UserIdentity\getId(), getTitleDbKeysGroupedByNamespace(), MediaWiki\User\UserIdentity\isRegistered(), resetAllNotificationTimestampsForUser(), and uncacheUser().
WatchedItemStore::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $stats | ) |
StatsdDataFactoryInterface | $stats |
Implements StatsdAwareInterface.
Definition at line 130 of file WatchedItemStore.php.
References $stats.
|
private |
Definition at line 175 of file WatchedItemStore.php.
References cache(), getCacheKey(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\User\UserIdentity\getId(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by addWatchBatchForUser(), resetNotificationTimestamp(), and uncacheTitlesForUser().
|
private |
Definition at line 270 of file WatchedItemStore.php.
References cache(), and MediaWiki\User\UserIdentity\getId().
Referenced by clearUserWatchedItems().
|
private |
Definition at line 181 of file WatchedItemStore.php.
References cache(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by updateNotificationTimestamp().
|
private |
UserIdentity | $user | |
LinkTarget[] | $titles |
Definition at line 1275 of file WatchedItemStore.php.
References $title, and uncache().
Referenced by removeWatchBatchForUser().
|
private |
Definition at line 192 of file WatchedItemStore.php.
References cache(), MediaWiki\User\UserIdentity\getId(), and getPageSeenTimestampsKey().
Referenced by setNotificationTimestampsForUser().
WatchedItemStore::updateNotificationTimestamp | ( | UserIdentity | $editor, |
LinkTarget | $target, | ||
$timestamp | |||
) |
UserIdentity | $editor | |
LinkTarget | $target | |
string | int | $timestamp |
Implements WatchedItemStoreInterface.
Definition at line 915 of file WatchedItemStore.php.
References DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\User\UserIdentity\getId(), MediaWiki\Linker\LinkTarget\getNamespace(), and uncacheLinkTarget().
|
private |
Definition at line 51 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 64 of file WatchedItemStore.php.
|
private |
Definition at line 69 of file WatchedItemStore.php.
Referenced by overrideDeferredUpdatesAddCallableUpdateCallback().
|
private |
Definition at line 56 of file WatchedItemStore.php.
|
private |
Definition at line 26 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 31 of file WatchedItemStore.php.
|
private |
Definition at line 79 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 36 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 46 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 84 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 41 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 89 of file WatchedItemStore.php.
Referenced by setStatsdDataFactory().
|
private |
Definition at line 74 of file WatchedItemStore.php.
Referenced by __construct().