MediaWiki REL1_27
|
Storage layer class for WatchedItems. More...
Public Member Functions | |
__construct (LoadBalancer $loadBalancer, HashBagOStuff $cache) | |
addWatch (User $user, LinkTarget $target) | |
Must be called separately for Subject & Talk namespaces. | |
addWatchBatchForUser (User $user, array $targets) | |
countUnreadNotifications (User $user, $unreadLimit=null) | |
countVisitingWatchers (LinkTarget $target, $threshold) | |
Number of page watchers who also visited a "recent" edit. | |
countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null) | |
Number of watchers of each page who have visited recent edits to that page. | |
countWatchedItems (User $user) | |
Count the number of individual items that are watched by the user. | |
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. | |
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. | |
getNotificationTimestampsBatch (User $user, array $targets) | |
getWatchedItem (User $user, LinkTarget $target) | |
Get an item (may be cached) | |
getWatchedItemsForUser (User $user, array $options=[]) | |
isWatched (User $user, LinkTarget $target) | |
Must be called separately for Subject & Talk namespaces. | |
loadWatchedItem (User $user, LinkTarget $target) | |
Loads an item from the db. | |
overrideDeferredUpdatesAddCallableUpdateCallback ( $callback) | |
Overrides the DeferredUpdates::addCallableUpdate callback This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined. | |
overrideRevisionGetTimestampFromIdCallback ( $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) | |
Removes the an entry for the User watching the LinkTarget Must be called separately for Subject & Talk namespaces. | |
resetNotificationTimestamp (User $user, Title $title, $force='', $oldid=0) | |
Reset the notification timestamp of this entry. | |
setStatsdDataFactory (StatsdDataFactoryInterface $stats) | |
Sets a StatsdDataFactory instance on the object. | |
updateNotificationTimestamp (User $editor, LinkTarget $target, $timestamp) | |
Static Public Member Functions | |
static | getDefaultInstance () |
static | overrideDefaultInstance (WatchedItemStore $store=null) |
Overrides the default instance of this class This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined. | |
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. | |
getCached (User $user, LinkTarget $target) | |
getCacheKey (User $user, LinkTarget $target) | |
getConnection ( $slaveOrMaster) | |
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. | |
reuseConnection ( $connection) | |
uncache (User $user, LinkTarget $target) | |
uncacheLinkTarget (LinkTarget $target) | |
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 |
callable null | $revisionGetTimestampFromIdCallback |
StatsdDataFactoryInterface | $stats |
Static Private Attributes | |
static self null | $instance |
Storage layer class for WatchedItems.
Database interaction.
Definition at line 15 of file WatchedItemStore.php.
WatchedItemStore::__construct | ( | LoadBalancer | $loadBalancer, |
HashBagOStuff | $cache | ||
) |
LoadBalancer | $loadBalancer | |
HashBagOStuff | $cache |
Definition at line 62 of file WatchedItemStore.php.
References $cache, $loadBalancer, and cache.
WatchedItemStore::addWatch | ( | User | $user, |
LinkTarget | $target | ||
) |
Must be called separately for Subject & Talk namespaces.
User | $user | |
LinkTarget | $target |
Definition at line 641 of file WatchedItemStore.php.
References addWatchBatchForUser().
User | $user | |
LinkTarget[] | $targets |
Definition at line 651 of file WatchedItemStore.php.
References $user, as, DB_MASTER, getConnection(), reuseConnection(), and uncache().
Referenced by addWatch().
|
private |
Definition at line 176 of file WatchedItemStore.php.
References $user, cache, getCacheKey(), WatchedItem\getLinkTarget(), and WatchedItem\getUser().
WatchedItemStore::countUnreadNotifications | ( | User | $user, |
$unreadLimit = null |
|||
) |
User | $user | |
int | $unreadLimit |
Definition at line 873 of file WatchedItemStore.php.
References $dbr, $user, DB_SLAVE, getConnection(), and reuseConnection().
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 302 of file WatchedItemStore.php.
References $dbr, DB_SLAVE, getConnection(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and reuseConnection().
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 382 of file WatchedItemStore.php.
References $dbr, $res, as, DB_SLAVE, getConnection(), getVisitingWatchersCondition(), list, and reuseConnection().
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 256 of file WatchedItemStore.php.
References $dbr, $user, DB_SLAVE, getConnection(), and reuseConnection().
WatchedItemStore::countWatchers | ( | LinkTarget | $target | ) |
LinkTarget | $target |
Definition at line 276 of file WatchedItemStore.php.
References $dbr, DB_SLAVE, getConnection(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and reuseConnection().
LinkTarget[] | $targets | |
array | $options | Allowed keys: 'minimumWatchers' => int |
Definition at line 330 of file WatchedItemStore.php.
References $dbr, $options, $res, as, DB_SLAVE, getConnection(), and reuseConnection().
|
private |
Return an array of conditions to select or update the appropriate database row.
User | $user | |
LinkTarget | $target |
Definition at line 221 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 913 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 931 of file WatchedItemStore.php.
References as, DB_MASTER, getConnection(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), and reuseConnection().
Referenced by duplicateAllAssociatedEntries().
|
private |
User | $user | |
LinkTarget | $target |
Definition at line 208 of file WatchedItemStore.php.
References cache, and getCacheKey().
Referenced by getNotificationTimestampsBatch(), and getWatchedItem().
|
private |
Definition at line 168 of file WatchedItemStore.php.
References $user, cache, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by cache(), getCached(), and uncache().
|
private |
int | $slaveOrMaster | DB_MASTER or DB_SLAVE |
MWException |
Definition at line 235 of file WatchedItemStore.php.
Referenced by addWatchBatchForUser(), countUnreadNotifications(), countVisitingWatchers(), countVisitingWatchersMultiple(), countWatchedItems(), countWatchers(), countWatchersMultiple(), duplicateEntry(), getNotificationTimestampsBatch(), getWatchedItemsForUser(), loadWatchedItem(), removeWatch(), and updateNotificationTimestamp().
|
static |
Definition at line 157 of file WatchedItemStore.php.
References $instance, RequestContext\getMain(), and wfGetLB().
Referenced by User\addWatch(), WatchedItem\batchAddWatch(), SpecialEditWatchlist\cleanupWatchlist(), User\clearNotification(), SpecialWatchlist\countItems(), WatchedItem\duplicateEntries(), ApiQueryUserInfo\getCurrentUserInfo(), Title\getNotificationTimestamp(), WatchedItem\getNotificationTimestamp(), ApiQueryInfo\getVisitingWatcherInfo(), ApiQueryInfo\getWatchedInfo(), ApiQueryInfo\getWatcherInfo(), SpecialEditWatchlist\getWatchlist(), SpecialEditWatchlist\getWatchlistInfo(), User\isWatched(), MovePage\move(), EmailNotification\notifyOnPageChange(), SpecialRecentChanges\outputChangesList(), SpecialWatchlist\outputChangesList(), InfoAction\pageCounts(), User\removeWatch(), WatchedItem\resetNotificationTimestamp(), WatchedItemStoreIntegrationTest\testDuplicateAllAssociatedEntries(), WatchedItemStoreUnitTest\testGetDefaultInstance(), WatchedItemStoreUnitTest\testOverrideDefaultInstance(), WatchedItemStoreIntegrationTest\testUpdateAndResetNotificationTimestamp(), WatchedItemStoreIntegrationTest\testWatchAndUnWatchItem(), SpecialEditWatchlist\unwatchTitles(), EmailNotification\updateWatchlistTimestamp(), and SpecialEditWatchlist\watchTitles().
|
private |
Definition at line 819 of file WatchedItemStore.php.
References $title, getNotificationTimestamp(), loadWatchedItem(), and TS_MW.
Referenced by getNotificationTimestamp().
User | $user | |
LinkTarget[] | $targets |
Definition at line 589 of file WatchedItemStore.php.
References $dbr, $res, $user, as, DB_SLAVE, getCached(), getConnection(), and reuseConnection().
|
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 424 of file WatchedItemStore.php.
References IDatabase\addQuotes(), as, list, LIST_AND, LIST_OR, IDatabase\makeList(), and IDatabase\timestamp().
Referenced by countVisitingWatchersMultiple().
WatchedItemStore::getWatchedItem | ( | User | $user, |
LinkTarget | $target | ||
) |
Get an item (may be cached)
User | $user | |
LinkTarget | $target |
Definition at line 469 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 529 of file WatchedItemStore.php.
References $options, $res, $user, as, DB_MASTER, DB_SLAVE, false, getConnection(), and reuseConnection().
WatchedItemStore::isWatched | ( | User | $user, |
LinkTarget | $target | ||
) |
Must be called separately for Subject & Talk namespaces.
User | $user | |
LinkTarget | $target |
Definition at line 576 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 491 of file WatchedItemStore.php.
References $dbr, $user, cache, DB_SLAVE, dbCond(), getConnection(), and reuseConnection().
Referenced by getNotificationTimestamp(), getWatchedItem(), and resetNotificationTimestamp().
|
static |
Overrides the default instance of this class This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
If this method is used it MUST also be called with null after a test to ensure a new default instance is created next time getDefaultInstance is called.
WatchedItemStore | null | $store |
MWException |
Definition at line 140 of file WatchedItemStore.php.
References $instance, and use.
Referenced by WatchedItemUnitTest\testBatchAddWatch(), WatchedItemUnitTest\testDuplicateEntries(), WatchedItemUnitTest\testFromUserTitle(), and WatchedItemUnitTest\testResetNotificationTimestamp().
WatchedItemStore::overrideDeferredUpdatesAddCallableUpdateCallback | ( | $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 88 of file WatchedItemStore.php.
References $deferredUpdatesAddCallableUpdateCallback, and use.
WatchedItemStore::overrideRevisionGetTimestampFromIdCallback | ( | $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 113 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 697 of file WatchedItemStore.php.
References $success, $user, DB_MASTER, getConnection(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), reuseConnection(), 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 780 of file WatchedItemStore.php.
References $job, $title, $user, loadWatchedItem(), uncache(), and use.
|
private |
DatabaseBase | $connection |
MWException |
Definition at line 244 of file WatchedItemStore.php.
Referenced by addWatchBatchForUser(), countUnreadNotifications(), countVisitingWatchers(), countVisitingWatchersMultiple(), countWatchedItems(), countWatchers(), countWatchersMultiple(), duplicateEntry(), getNotificationTimestampsBatch(), getWatchedItemsForUser(), loadWatchedItem(), removeWatch(), and updateNotificationTimestamp().
WatchedItemStore::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $statsFactory | ) |
Sets a StatsdDataFactory instance on the object.
StatsdDataFactoryInterface | $statsFactory |
Implements StatsdAwareInterface.
Definition at line 73 of file WatchedItemStore.php.
References $stats.
|
private |
Definition at line 185 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 191 of file WatchedItemStore.php.
References as, cache, MediaWiki\Linker\LinkTarget\getDBkey(), and MediaWiki\Linker\LinkTarget\getNamespace().
Referenced by updateNotificationTimestamp().
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 727 of file WatchedItemStore.php.
References $editor, $fname, $res, $timestamp, as, DB_MASTER, getConnection(), MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), reuseConnection(), uncacheLinkTarget(), and use.
|
private |
Definition at line 28 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 36 of file WatchedItemStore.php.
|
private |
Definition at line 41 of file WatchedItemStore.php.
Referenced by overrideDeferredUpdatesAddCallableUpdateCallback().
|
staticprivate |
Definition at line 56 of file WatchedItemStore.php.
Referenced by getDefaultInstance(), and overrideDefaultInstance().
|
private |
Definition at line 23 of file WatchedItemStore.php.
Referenced by __construct().
|
private |
Definition at line 46 of file WatchedItemStore.php.
Referenced by overrideRevisionGetTimestampFromIdCallback().
|
private |
Definition at line 51 of file WatchedItemStore.php.
Referenced by setStatsdDataFactory().
const WatchedItemStore::SORT_ASC = 'ASC' |
Definition at line 18 of file WatchedItemStore.php.
Referenced by SpecialEditWatchlist\getWatchlistInfo(), and WatchedItemStoreUnitTest\testGetWatchedItemsForUser_optionsAndEmptyResult().
const WatchedItemStore::SORT_DESC = 'DESC' |
Definition at line 17 of file WatchedItemStore.php.