MediaWiki REL1_33
WatchedItemStoreInterface Interface Reference
Inheritance diagram for WatchedItemStoreInterface:

Public Member Functions

 addWatch (User $user, LinkTarget $target)
 Must be called separately for Subject & Talk namespaces.
 
 addWatchBatchForUser (User $user, array $targets)
 
 clearUserWatchedItems (User $user)
 Queues a job that will clear the users watchlist using the Job Queue.
 
 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)
 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.
 
 getLatestNotificationTimestamp ( $timestamp, User $user, LinkTarget $target)
 Convert $timestamp to TS_MW or return null if the page was visited since then by $user.
 
 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.
 
 removeWatch (User $user, LinkTarget $target)
 Removes an entry for the User watching the LinkTarget Must be called separately for Subject & Talk namespaces.
 
 removeWatchBatchForUser (User $user, array $targets)
 
 resetAllNotificationTimestampsForUser (User $user)
 Reset all watchlist notificaton timestamps for a user using the job queue.
 
 resetNotificationTimestamp (User $user, Title $title, $force='', $oldid=0)
 Reset the notification timestamp of this entry.
 
 setNotificationTimestampsForUser (User $user, $timestamp, array $targets=[])
 
 updateNotificationTimestamp (User $editor, LinkTarget $target, $timestamp)
 

Public Attributes

const SORT_ASC = 'ASC'
 
const SORT_DESC = 'DESC'
 

Detailed Description

Author
Addshore
Since
1.31 interface created. WatchedItemStore implementation available since 1.27

Definition at line 28 of file WatchedItemStoreInterface.php.

Member Function Documentation

◆ addWatch()

WatchedItemStoreInterface::addWatch ( User  $user,
LinkTarget  $target 
)

Must be called separately for Subject & Talk namespaces.

Since
1.31
Parameters
User$user
LinkTarget$target

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ addWatchBatchForUser()

WatchedItemStoreInterface::addWatchBatchForUser ( User  $user,
array  $targets 
)
Since
1.31
Parameters
User$user
LinkTarget[]$targets
Returns
bool success

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ clearUserWatchedItems()

WatchedItemStoreInterface::clearUserWatchedItems ( User  $user)

Queues a job that will clear the users watchlist using the Job Queue.

Since
1.31
Parameters
User$user

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ clearUserWatchedItemsUsingJobQueue()

WatchedItemStoreInterface::clearUserWatchedItemsUsingJobQueue ( User  $user)

Queues a job that will clear the users watchlist using the Job Queue.

Since
1.31
Parameters
User$user

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ countUnreadNotifications()

WatchedItemStoreInterface::countUnreadNotifications ( User  $user,
  $unreadLimit = null 
)
Since
1.31
Parameters
User$user
int | null$unreadLimit
Returns
int|bool The number of unread notifications true if greater than or equal to $unreadLimit

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ countVisitingWatchers()

WatchedItemStoreInterface::countVisitingWatchers ( LinkTarget  $target,
  $threshold 
)

Number of page watchers who also visited a "recent" edit.

Since
1.31
Parameters
LinkTarget$target
mixed$thresholdtimestamp accepted by wfTimestamp
Returns
int
Exceptions
DBUnexpectedError
MWException

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ countVisitingWatchersMultiple()

WatchedItemStoreInterface::countVisitingWatchersMultiple ( array  $targetsWithVisitThresholds,
  $minimumWatchers = null 
)

Number of watchers of each page who have visited recent edits to that page.

Since
1.31
Parameters
array$targetsWithVisitThresholdsarray of pairs (LinkTarget $target, mixed $threshold), $threshold is:
  • a timestamp of the recent edit if $target exists (format accepted by wfTimestamp)
  • null if $target doesn't exist
int | null$minimumWatchers
Returns
array multi-dimensional like $return[$namespaceId][$titleString] = $watchers, where $watchers is an int:
  • if the page exists, number of users watching who have visited the page recently
  • if the page doesn't exist, number of users that have the page on their watchlist
  • 0 means there are no visiting watchers or their number is below the minimumWatchers option (if passed).

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ countWatchedItems()

WatchedItemStoreInterface::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.

Since
1.31
Parameters
User$user
Returns
int

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ countWatchers()

WatchedItemStoreInterface::countWatchers ( LinkTarget  $target)
Since
1.31
Parameters
LinkTarget$target
Returns
int

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ countWatchersMultiple()

WatchedItemStoreInterface::countWatchersMultiple ( array  $targets,
array  $options = [] 
)
Since
1.31
Parameters
LinkTarget[]$targets
array$optionsAllowed keys: 'minimumWatchers' => int
Returns
array multi dimensional like $return[$namespaceId][$titleString] = int $watchers All targets will be present in the result. 0 either means no watchers or the number of watchers was below the minimumWatchers option if passed.

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ duplicateAllAssociatedEntries()

WatchedItemStoreInterface::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.

Since
1.31
Parameters
LinkTarget$oldTarget
LinkTarget$newTarget

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ duplicateEntry()

WatchedItemStoreInterface::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

Since
1.31
Parameters
LinkTarget$oldTarget
LinkTarget$newTarget

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ getLatestNotificationTimestamp()

WatchedItemStoreInterface::getLatestNotificationTimestamp (   $timestamp,
User  $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

Parameters
string | null$timestampValue of wl_notificationtimestamp from the DB
User$user
LinkTarget$target
Returns
string TS_MW timestamp or null

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ getNotificationTimestampsBatch()

WatchedItemStoreInterface::getNotificationTimestampsBatch ( User  $user,
array  $targets 
)
Since
1.31
Parameters
User$user
LinkTarget[]$targets
Returns
array multi-dimensional like $return[$namespaceId][$titleString] = $timestamp, where $timestamp is:
  • string|null value of wl_notificationtimestamp,
  • false if $target is not watched by $user.

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ getWatchedItem()

WatchedItemStoreInterface::getWatchedItem ( User  $user,
LinkTarget  $target 
)

Get an item (may be cached)

Since
1.31
Parameters
User$user
LinkTarget$target
Returns
WatchedItem|false

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ getWatchedItemsForUser()

WatchedItemStoreInterface::getWatchedItemsForUser ( User  $user,
array  $options = [] 
)
Since
1.31
Parameters
User$user
array$optionsAllowed keys: 'forWrite' => bool defaults to false 'sort' => string optional sorting by namespace ID and title one of the self::SORT_* constants
Returns
WatchedItem[]

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ isWatched()

WatchedItemStoreInterface::isWatched ( User  $user,
LinkTarget  $target 
)

Must be called separately for Subject & Talk namespaces.

Since
1.31
Parameters
User$user
LinkTarget$target
Returns
bool

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ loadWatchedItem()

WatchedItemStoreInterface::loadWatchedItem ( User  $user,
LinkTarget  $target 
)

Loads an item from the db.

Since
1.31
Parameters
User$user
LinkTarget$target
Returns
WatchedItem|false

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ removeWatch()

WatchedItemStoreInterface::removeWatch ( User  $user,
LinkTarget  $target 
)

Removes an entry for the User watching the LinkTarget Must be called separately for Subject & Talk namespaces.

Since
1.31
Parameters
User$user
LinkTarget$target
Returns
bool success
Exceptions
DBUnexpectedError
MWException

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ removeWatchBatchForUser()

WatchedItemStoreInterface::removeWatchBatchForUser ( User  $user,
array  $targets 
)
Since
1.32
Parameters
User$user
LinkTarget[]$targets
Returns
bool success

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ resetAllNotificationTimestampsForUser()

WatchedItemStoreInterface::resetAllNotificationTimestampsForUser ( User  $user)

Reset all watchlist notificaton timestamps for a user using the job queue.

Since
1.31
Parameters
User$userThe user to reset the timestamps for

Implemented in NoWriteWatchedItemStore.

◆ resetNotificationTimestamp()

WatchedItemStoreInterface::resetNotificationTimestamp ( User  $user,
Title  $title,
  $force = '',
  $oldid = 0 
)

Reset the notification timestamp of this entry.

Since
1.31
Parameters
User$user
Title$title
string$forceWhether 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$oldidThe revision id being viewed. If not given or 0, latest revision is assumed.
Returns
bool success Whether a job was enqueued

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ setNotificationTimestampsForUser()

WatchedItemStoreInterface::setNotificationTimestampsForUser ( User  $user,
  $timestamp,
array  $targets = [] 
)
Since
1.31
Parameters
User$userThe user to set the timestamps for
string | null$timestampSet the update timestamp to this value
LinkTarget[]$targetsList of targets to update. Default to all targets
Returns
bool success

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

◆ updateNotificationTimestamp()

WatchedItemStoreInterface::updateNotificationTimestamp ( User  $editor,
LinkTarget  $target,
  $timestamp 
)
Since
1.31
Parameters
User$editorThe editor that triggered the update. Their notification timestamp will not be updated(they have already seen it)
LinkTarget$targetThe target to update timestamps for
string$timestampSet the update timestamp to this value
Returns
int[] Array of user IDs the timestamp has been updated for

Implemented in NoWriteWatchedItemStore, and WatchedItemStore.

Member Data Documentation

◆ SORT_ASC

const WatchedItemStoreInterface::SORT_ASC = 'ASC'

◆ SORT_DESC

const WatchedItemStoreInterface::SORT_DESC = 'DESC'
Since
1.31

Definition at line 38 of file WatchedItemStoreInterface.php.

Referenced by ApiQueryWatchlistRaw\run().


The documentation for this interface was generated from the following file: