MediaWiki
1.30.2
|
Storage layer class for WatchedItems. More...
Public Member Functions | |
__construct (LoadBalancer $loadBalancer, HashBagOStuff $cache, ReadOnlyMode $readOnlyMode) | |
addWatch (User $user, LinkTarget $target) | |
Must be called separately for Subject & Talk namespaces. More... | |
addWatchBatchForUser (User $user, array $targets) | |
countUnreadNotifications (User $user, $unreadLimit=null) | |
countVisitingWatchers (LinkTarget $target, $threshold) | |
Number of page watchers who also visited a "recent" edit. More... | |
countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null) | |
Number of watchers of each page who have visited recent edits to that page. More... | |
countWatchedItems (User $user) | |
Count the number of individual items that are watched by the user. More... | |
countWatchers (LinkTarget $target) | |
countWatchersMultiple (array $targets, array $options=[]) | |
duplicateAllAssociatedEntries (LinkTarget $oldTarget, LinkTarget $newTarget) | |
Check if the given title already is watched by the user, and if so add a watch for the new title. More... | |
duplicateEntry (LinkTarget $oldTarget, LinkTarget $newTarget) | |
Check if the given title already is watched by the user, and if so add a watch for the new title. More... | |
getNotificationTimestampsBatch (User $user, array $targets) | |
getWatchedItem (User $user, LinkTarget $target) | |
Get an item (may be cached) More... | |
getWatchedItemsForUser (User $user, array $options=[]) | |
isWatched (User $user, LinkTarget $target) | |
Must be called separately for Subject & Talk namespaces. More... | |
loadWatchedItem (User $user, LinkTarget $target) | |
Loads an item from the db. More... | |
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. More... | |
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. More... | |
removeWatch (User $user, LinkTarget $target) | |
Removes the an entry for the User watching the LinkTarget Must be called separately for Subject & Talk namespaces. More... | |
resetNotificationTimestamp (User $user, Title $title, $force='', $oldid=0) | |
Reset the notification timestamp of this entry. More... | |
setNotificationTimestampsForUser (User $user, $timestamp, array $targets=[]) | |
setStatsdDataFactory (StatsdDataFactoryInterface $stats) | |
Sets a StatsdDataFactory instance on the object. More... | |
updateNotificationTimestamp (User $editor, LinkTarget $target, $timestamp) | |
Public Attributes | |
const | SORT_ASC = 'ASC' |
const | SORT_DESC = 'DESC' |
Private Member Functions | |
cache (WatchedItem $item) | |
dbCond (User $user, LinkTarget $target) | |
Return an array of conditions to select or update the appropriate database row. More... | |
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. More... | |
uncache (User $user, LinkTarget $target) | |
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. More... | |
callable null | $deferredUpdatesAddCallableUpdateCallback |
LoadBalancer | $loadBalancer |
ReadOnlyMode | $readOnlyMode |
callable null | $revisionGetTimestampFromIdCallback |
StatsdDataFactoryInterface | $stats |
Storage layer class for WatchedItems.
Database interaction.
Uses database because this uses User::isAnon
Database
Definition at line 23 of file WatchedItemStore.php.
WatchedItemStore::__construct | ( | LoadBalancer | $loadBalancer, |
HashBagOStuff | $cache, | ||
ReadOnlyMode | $readOnlyMode | ||
) |
LoadBalancer | $loadBalancer | |
HashBagOStuff | $cache | |
ReadOnlyMode | $readOnlyMode |
Definition at line 71 of file WatchedItemStore.php.
References $cache, $loadBalancer, $readOnlyMode, and cache().
WatchedItemStore::addWatch | ( | User | $user, |
LinkTarget | $target | ||
) |
Must be called separately for Subject & Talk namespaces.
User | $user | |
LinkTarget | $target |
Definition at line 602 of file WatchedItemStore.php.
References addWatchBatchForUser().
User | $user | |
LinkTarget[] | $targets |
Definition at line 612 of file WatchedItemStore.php.
References $rows, $user, as, cache(), DB_MASTER, getConnectionRef(), and uncache().
Referenced by addWatch().
|
private |
Definition at line 143 of file WatchedItemStore.php.
References $user, getCacheKey(), WatchedItem\getLinkTarget(), and WatchedItem\getUser().
Referenced by __construct(), addWatchBatchForUser(), getCached(), getCacheKey(), loadWatchedItem(), uncache(), uncacheLinkTarget(), and uncacheUser().
WatchedItemStore::countUnreadNotifications | ( | User | $user, |
$unreadLimit = null |
|||
) |
User | $user | |
int | $unreadLimit |
Definition at line 893 of file WatchedItemStore.php.
References $dbr, $user, DB_REPLICA, and getConnectionRef().
WatchedItemStore::countVisitingWatchers | ( | LinkTarget | $target, |
$threshold | |||
) |
Number of page watchers who also visited a "recent" edit.
LinkTarget | $target | |
mixed | $threshold | timestamp accepted by wfTimestamp |
DBUnexpectedError | |
MWException |
Definition at line 270 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
WatchedItemStore::countVisitingWatchersMultiple | ( | array | $targetsWithVisitThresholds, |
$minimumWatchers = null |
|||
) |
Number of watchers of each page who have visited recent edits to that page.
array | $targetsWithVisitThresholds | array of pairs (LinkTarget $target, mixed $threshold), $threshold is:
|
int | null | $minimumWatchers |
Definition at line 347 of file WatchedItemStore.php.
References $dbr, $res, as, DB_REPLICA, getConnectionRef(), getVisitingWatchersCondition(), and list.
WatchedItemStore::countWatchedItems | ( | User | $user | ) |
Count the number of individual items that are watched by the user.
If a subject and corresponding talk page are watched this will return 2.
User | $user |
Definition at line 226 of file WatchedItemStore.php.
References $dbr, $user, DB_REPLICA, and getConnectionRef().
WatchedItemStore::countWatchers | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Definition at line 245 of file WatchedItemStore.php.
References $dbr, DB_REPLICA, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
LinkTarget[] | $targets | |
array | $options | Allowed keys: 'minimumWatchers' => int |
Definition at line 297 of file WatchedItemStore.php.
References $dbr, $options, $res, as, 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 200 of file WatchedItemStore.php.
References $user, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by loadWatchedItem().
WatchedItemStore::duplicateAllAssociatedEntries | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget | ||
) |
Check if the given title already is watched by the user, and if so add a watch for the new title.
To be used for page renames and such.
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Definition at line 932 of file WatchedItemStore.php.
References duplicateEntry(), and Title\newFromLinkTarget().
WatchedItemStore::duplicateEntry | ( | LinkTarget | $oldTarget, |
LinkTarget | $newTarget | ||
) |
Check if the given title already is watched by the user, and if so add a watch for the new title.
To be used for page renames and such. This must be called separately for Subject and Talk pages
LinkTarget | $oldTarget | |
LinkTarget | $newTarget |
Definition at line 950 of file WatchedItemStore.php.
References as, DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by duplicateAllAssociatedEntries().
|
private |
User | $user | |
LinkTarget | $target |
Definition at line 187 of file WatchedItemStore.php.
References cache(), and getCacheKey().
Referenced by getNotificationTimestampsBatch(), and getWatchedItem().
|
private |
Definition at line 135 of file WatchedItemStore.php.
References $user, cache(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and string.
Referenced by cache(), getCached(), and uncache().
|
private |
int | $dbIndex | DB_MASTER or DB_REPLICA |
MWException |
Definition at line 214 of file WatchedItemStore.php.
Referenced by addWatchBatchForUser(), countUnreadNotifications(), countVisitingWatchers(), countVisitingWatchersMultiple(), countWatchedItems(), countWatchers(), countWatchersMultiple(), duplicateEntry(), getNotificationTimestampsBatch(), getWatchedItemsForUser(), loadWatchedItem(), removeWatch(), setNotificationTimestampsForUser(), and updateNotificationTimestamp().
|
private |
Definition at line 839 of file WatchedItemStore.php.
References $title, and loadWatchedItem().
Referenced by resetNotificationTimestamp().
User | $user | |
LinkTarget[] | $targets |
Definition at line 550 of file WatchedItemStore.php.
References $dbr, $res, $user, as, 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 387 of file WatchedItemStore.php.
References Wikimedia\Rdbms\IDatabase\addQuotes(), as, list, LIST_AND, LIST_OR, Wikimedia\Rdbms\IDatabase\makeList(), and Wikimedia\Rdbms\IDatabase\timestamp().
Referenced by countVisitingWatchersMultiple().
WatchedItemStore::getWatchedItem | ( | User | $user, |
LinkTarget | $target | ||
) |
Get an item (may be cached)
User | $user | |
LinkTarget | $target |
Definition at line 432 of file WatchedItemStore.php.
References $user, getCached(), and loadWatchedItem().
Referenced by isWatched().
User | $user | |
array | $options | Allowed keys: 'forWrite' => bool defaults to false 'sort' => string optional sorting by namespace ID and title one of the self::SORT_* constants |
Definition at line 491 of file WatchedItemStore.php.
References $options, $res, $user, as, DB_MASTER, DB_REPLICA, false, and getConnectionRef().
WatchedItemStore::isWatched | ( | User | $user, |
LinkTarget | $target | ||
) |
Must be called separately for Subject & Talk namespaces.
User | $user | |
LinkTarget | $target |
Definition at line 537 of file WatchedItemStore.php.
References getWatchedItem().
WatchedItemStore::loadWatchedItem | ( | User | $user, |
LinkTarget | $target | ||
) |
Loads an item from the db.
User | $user | |
LinkTarget | $target |
Definition at line 454 of file WatchedItemStore.php.
References $dbr, $user, 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 99 of file WatchedItemStore.php.
References $deferredUpdatesAddCallableUpdateCallback, and use.
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 122 of file WatchedItemStore.php.
References $revisionGetTimestampFromIdCallback, and use.
WatchedItemStore::removeWatch | ( | User | $user, |
LinkTarget | $target | ||
) |
Removes the an entry for the User watching the LinkTarget Must be called separately for Subject & Talk namespaces.
User | $user | |
LinkTarget | $target |
DBUnexpectedError | |
MWException |
Definition at line 669 of file WatchedItemStore.php.
References $success, $user, DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and uncache().
Reset the notification timestamp of this entry.
User | $user | |
Title | $title | |
string | $force | Whether to force the write query to be executed even if the page is not watched or the notification timestamp is already NULL. 'force' in order to force |
int | $oldid | The revision id being viewed. If not given or 0, latest revision is assumed. |
Definition at line 800 of file WatchedItemStore.php.
References $job, $title, $user, getNotificationTimestamp(), loadWatchedItem(), uncache(), and use.
User | $user | The user to set the timestamp for |
string | null | $timestamp | Set the update timestamp to this value |
LinkTarget[] | $targets | List of targets to update. Default to all targets |
Definition at line 697 of file WatchedItemStore.php.
References $batch, $success, $user, DB_MASTER, getConnectionRef(), and uncacheUser().
WatchedItemStore::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $statsFactory | ) |
Sets a StatsdDataFactory instance on the object.
StatsdDataFactoryInterface | $statsFactory |
Implements StatsdAwareInterface.
Definition at line 84 of file WatchedItemStore.php.
References $stats.
|
private |
Definition at line 152 of file WatchedItemStore.php.
References $user, cache(), getCacheKey(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by addWatchBatchForUser(), removeWatch(), and resetNotificationTimestamp().
|
private |
Definition at line 158 of file WatchedItemStore.php.
References as, cache(), MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by updateNotificationTimestamp().
|
private |
Definition at line 169 of file WatchedItemStore.php.
References $user, as, and cache().
Referenced by setNotificationTimestampsForUser().
WatchedItemStore::updateNotificationTimestamp | ( | User | $editor, |
LinkTarget | $target, | ||
$timestamp | |||
) |
User | $editor | The editor that triggered the update. Their notification timestamp will not be updated(they have already seen it) |
LinkTarget | $target | The target to update timestamps for |
string | $timestamp | Set the update timestamp to this value |
Definition at line 735 of file WatchedItemStore.php.
References $editor, $fname, $wgUpdateRowsPerQuery, DeferredUpdates\addCallableUpdate(), as, captcha-old\count, DB_MASTER, getConnectionRef(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), global, DeferredUpdates\POSTSEND, uncacheLinkTarget(), and use.
|
private |
Definition at line 41 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 49 of file WatchedItemStore.php.
|
private |
Definition at line 54 of file WatchedItemStore.php.
Referenced by overrideDeferredUpdatesAddCallableUpdateCallback().
|
private |
Definition at line 31 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 36 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 59 of file WatchedItemStore.php.
Referenced by overrideRevisionGetTimestampFromIdCallback().
|
private |
Definition at line 64 of file WatchedItemStore.php.
Referenced by setStatsdDataFactory().
const WatchedItemStore::SORT_ASC = 'ASC' |
Definition at line 26 of file WatchedItemStore.php.
Referenced by SpecialEditWatchlist\getWatchlistInfo(), ApiQueryWatchlistRaw\run(), and WatchedItemStoreUnitTest\testGetWatchedItemsForUser_optionsAndEmptyResult().
const WatchedItemStore::SORT_DESC = 'DESC' |
Definition at line 25 of file WatchedItemStore.php.
Referenced by ApiQueryWatchlistRaw\run().