MediaWiki  master
NoWriteWatchedItemStore Class Reference
Inheritance diagram for NoWriteWatchedItemStore:
Collaboration diagram for NoWriteWatchedItemStore:

Public Member Functions

 __construct (WatchedItemStoreInterface $actualStore)
 Initialy set WatchedItemStore that will be used in cases where writing is not needed. More...
 
 addWatch (UserIdentity $user, LinkTarget $target)
 Must be called separately for Subject & Talk namespaces. More...
 
 addWatchBatchForUser (UserIdentity $user, array $targets)
 
 clearUserWatchedItems (UserIdentity $user)
 Queues a job that will clear the users watchlist using the Job Queue. More...
 
 clearUserWatchedItemsUsingJobQueue (UserIdentity $user)
 Queues a job that will clear the users watchlist using the Job Queue. More...
 
 countUnreadNotifications (UserIdentity $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 (UserIdentity $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...
 
 getLatestNotificationTimestamp ( $timestamp, UserIdentity $user, LinkTarget $target)
 Convert $timestamp to TS_MW or return null if the page was visited since then by $user. More...
 
 getNotificationTimestampsBatch (UserIdentity $user, array $targets)
 
 getWatchedItem (UserIdentity $user, LinkTarget $target)
 Get an item (may be cached) More...
 
 getWatchedItemsForUser (UserIdentity $user, array $options=[])
 
 isWatched (UserIdentity $user, LinkTarget $target)
 Must be called separately for Subject & Talk namespaces. More...
 
 loadWatchedItem (UserIdentity $user, LinkTarget $target)
 Loads an item from the db. More...
 
 removeWatch (UserIdentity $user, LinkTarget $target)
 Removes an entry for the UserIdentity watching the LinkTarget Must be called separately for Subject & Talk namespaces. More...
 
 removeWatchBatchForUser (UserIdentity $user, array $titles)
 
 resetAllNotificationTimestampsForUser (UserIdentity $user)
 Reset all watchlist notificaton timestamps for a user using the job queue. More...
 
 resetNotificationTimestamp (UserIdentity $user, LinkTarget $title, $force='', $oldid=0)
 Reset the notification timestamp of this entry. More...
 
 setNotificationTimestampsForUser (UserIdentity $user, $timestamp, array $targets=[])
 
 updateNotificationTimestamp (UserIdentity $editor, LinkTarget $target, $timestamp)
 

Public Attributes

const DB_READONLY_ERROR = 'The watchlist is currently readonly.'
 
- Public Attributes inherited from WatchedItemStoreInterface
const SORT_ASC = 'ASC'
 
const SORT_DESC = 'DESC'
 

Private Attributes

WatchedItemStoreInterface $actualStore
 

Detailed Description

Definition at line 30 of file NoWriteWatchedItemStore.php.

Constructor & Destructor Documentation

◆ __construct()

NoWriteWatchedItemStore::__construct ( WatchedItemStoreInterface  $actualStore)

Initialy set WatchedItemStore that will be used in cases where writing is not needed.

Parameters
WatchedItemStoreInterface$actualStore

Definition at line 43 of file NoWriteWatchedItemStore.php.

References $actualStore.

Member Function Documentation

◆ addWatch()

NoWriteWatchedItemStore::addWatch ( UserIdentity  $user,
LinkTarget  $target 
)

Must be called separately for Subject & Talk namespaces.

Since
1.31
Parameters
UserIdentity$user
LinkTarget$target

Implements WatchedItemStoreInterface.

Definition at line 105 of file NoWriteWatchedItemStore.php.

References null.

◆ addWatchBatchForUser()

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

Implements WatchedItemStoreInterface.

Definition at line 109 of file NoWriteWatchedItemStore.php.

References null.

◆ clearUserWatchedItems()

NoWriteWatchedItemStore::clearUserWatchedItems ( UserIdentity  $user)

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

Since
1.31
Parameters
UserIdentity$user

Implements WatchedItemStoreInterface.

Definition at line 144 of file NoWriteWatchedItemStore.php.

References null.

◆ clearUserWatchedItemsUsingJobQueue()

NoWriteWatchedItemStore::clearUserWatchedItemsUsingJobQueue ( UserIdentity  $user)

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

Since
1.31
Parameters
UserIdentity$user

Implements WatchedItemStoreInterface.

Definition at line 148 of file NoWriteWatchedItemStore.php.

References null.

◆ countUnreadNotifications()

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

Implements WatchedItemStoreInterface.

Definition at line 93 of file NoWriteWatchedItemStore.php.

◆ countVisitingWatchers()

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

Implements WatchedItemStoreInterface.

Definition at line 55 of file NoWriteWatchedItemStore.php.

◆ countVisitingWatchersMultiple()

NoWriteWatchedItemStore::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).

Implements WatchedItemStoreInterface.

Definition at line 63 of file NoWriteWatchedItemStore.php.

◆ countWatchedItems()

NoWriteWatchedItemStore::countWatchedItems ( UserIdentity  $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
UserIdentity$user
Returns
int

Implements WatchedItemStoreInterface.

Definition at line 47 of file NoWriteWatchedItemStore.php.

◆ countWatchers()

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

Implements WatchedItemStoreInterface.

Definition at line 51 of file NoWriteWatchedItemStore.php.

◆ countWatchersMultiple()

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

Implements WatchedItemStoreInterface.

Definition at line 59 of file NoWriteWatchedItemStore.php.

References $options.

◆ duplicateAllAssociatedEntries()

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

Implements WatchedItemStoreInterface.

Definition at line 97 of file NoWriteWatchedItemStore.php.

References null.

◆ duplicateEntry()

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

Implements WatchedItemStoreInterface.

Definition at line 101 of file NoWriteWatchedItemStore.php.

References null.

◆ getLatestNotificationTimestamp()

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

Parameters
string | null$timestampValue of wl_notificationtimestamp from the DB
UserIdentity$user
LinkTarget$target
Returns
string|null TS_MW timestamp of first unseen revision or null if there isn't one

Implements WatchedItemStoreInterface.

Definition at line 156 of file NoWriteWatchedItemStore.php.

References wfTimestampOrNull().

◆ getNotificationTimestampsBatch()

NoWriteWatchedItemStore::getNotificationTimestampsBatch ( UserIdentity  $user,
array  $targets 
)
Since
1.31
Parameters
UserIdentity$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.

Implements WatchedItemStoreInterface.

Definition at line 89 of file NoWriteWatchedItemStore.php.

◆ getWatchedItem()

NoWriteWatchedItemStore::getWatchedItem ( UserIdentity  $user,
LinkTarget  $target 
)

Get an item (may be cached)

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

Implements WatchedItemStoreInterface.

Definition at line 73 of file NoWriteWatchedItemStore.php.

◆ getWatchedItemsForUser()

NoWriteWatchedItemStore::getWatchedItemsForUser ( UserIdentity  $user,
array  $options = [] 
)
Since
1.31
Parameters
UserIdentity$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[]

Implements WatchedItemStoreInterface.

Definition at line 81 of file NoWriteWatchedItemStore.php.

References $options.

◆ isWatched()

NoWriteWatchedItemStore::isWatched ( UserIdentity  $user,
LinkTarget  $target 
)

Must be called separately for Subject & Talk namespaces.

Since
1.31
Parameters
UserIdentity$user
LinkTarget$target
Returns
bool

Implements WatchedItemStoreInterface.

Definition at line 85 of file NoWriteWatchedItemStore.php.

◆ loadWatchedItem()

NoWriteWatchedItemStore::loadWatchedItem ( UserIdentity  $user,
LinkTarget  $target 
)

Loads an item from the db.

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

Implements WatchedItemStoreInterface.

Definition at line 77 of file NoWriteWatchedItemStore.php.

◆ removeWatch()

NoWriteWatchedItemStore::removeWatch ( UserIdentity  $user,
LinkTarget  $target 
)

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

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

Implements WatchedItemStoreInterface.

Definition at line 113 of file NoWriteWatchedItemStore.php.

References null.

◆ removeWatchBatchForUser()

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

Implements WatchedItemStoreInterface.

Definition at line 152 of file NoWriteWatchedItemStore.php.

References null.

◆ resetAllNotificationTimestampsForUser()

NoWriteWatchedItemStore::resetAllNotificationTimestampsForUser ( UserIdentity  $user)

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

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

Implements WatchedItemStoreInterface.

Definition at line 131 of file NoWriteWatchedItemStore.php.

References null.

◆ resetNotificationTimestamp()

NoWriteWatchedItemStore::resetNotificationTimestamp ( UserIdentity  $user,
LinkTarget  $title,
  $force = '',
  $oldid = 0 
)

Reset the notification timestamp of this entry.

Since
1.31
Parameters
UserIdentity$user
LinkTarget$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

Implements WatchedItemStoreInterface.

Definition at line 135 of file NoWriteWatchedItemStore.php.

References null.

◆ setNotificationTimestampsForUser()

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

Implements WatchedItemStoreInterface.

Definition at line 117 of file NoWriteWatchedItemStore.php.

References null.

◆ updateNotificationTimestamp()

NoWriteWatchedItemStore::updateNotificationTimestamp ( UserIdentity  $editor,
LinkTarget  $target,
  $timestamp 
)
Since
1.31
Parameters
UserIdentity$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 (first unseen revision) timestamp to this value
Returns
int[] Array of user IDs the timestamp has been updated for

Implements WatchedItemStoreInterface.

Definition at line 125 of file NoWriteWatchedItemStore.php.

References null.

Member Data Documentation

◆ $actualStore

WatchedItemStoreInterface NoWriteWatchedItemStore::$actualStore
private

Definition at line 35 of file NoWriteWatchedItemStore.php.

Referenced by __construct().

◆ DB_READONLY_ERROR

const NoWriteWatchedItemStore::DB_READONLY_ERROR = 'The watchlist is currently readonly.'

Definition at line 37 of file NoWriteWatchedItemStore.php.


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