BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
WatchedItemStore Class Reference
Inheritance diagram for WatchedItemStore:
Collaboration diagram for WatchedItemStore:

Public Member Functions

 __construct (LoadBalancer $loadBalancer, HashBagOStuff $cache)
 
 setStatsdDataFactory (StatsdDataFactoryInterface $stats)
 
 overrideDeferredUpdatesAddCallableUpdateCallback ($callback)
 
 overrideRevisionGetTimestampFromIdCallback ($callback)
 
 countWatchedItems (User $user)
 
 countWatchers (LinkTarget $target)
 
 countVisitingWatchers (LinkTarget $target, $threshold)
 
 countWatchersMultiple (array $targets, array $options=[])
 
 countVisitingWatchersMultiple (array $targetsWithVisitThresholds, $minimumWatchers=null)
 
 getWatchedItem (User $user, LinkTarget $target)
 
 loadWatchedItem (User $user, LinkTarget $target)
 
 getWatchedItemsForUser (User $user, array $options=[])
 
 isWatched (User $user, LinkTarget $target)
 
 getNotificationTimestampsBatch (User $user, array $targets)
 
 addWatch (User $user, LinkTarget $target)
 
 addWatchBatchForUser (User $user, array $targets)
 
 removeWatch (User $user, LinkTarget $target)
 
 updateNotificationTimestamp (User $editor, LinkTarget $target, $timestamp)
 
 resetNotificationTimestamp (User $user, Title $title, $force= '', $oldid=0)
 
 countUnreadNotifications (User $user, $unreadLimit=null)
 
 duplicateAllAssociatedEntries (LinkTarget $oldTarget, LinkTarget $newTarget)
 
 duplicateEntry (LinkTarget $oldTarget, LinkTarget $newTarget)
 

Static Public Member Functions

static overrideDefaultInstance (WatchedItemStore $store=null)
 
static getDefaultInstance ()
 

Public Attributes

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

Detailed Description

Storage layer class for WatchedItems. Database interaction.

Author
Addshore
Since
1.27

Constructor & Destructor Documentation

WatchedItemStore::__construct ( LoadBalancer  $loadBalancer,
HashBagOStuff  $cache 
)
Parameters
LoadBalancer$loadBalancer
HashBagOStuff$cache

Member Function Documentation

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

Must be called separately for Subject & Talk namespaces

Parameters
User$user
LinkTarget$target
WatchedItemStore::addWatchBatchForUser ( User  $user,
array  $targets 
)
Parameters
User$user
LinkTarget[]$targets
Returns
bool success
WatchedItemStore::countUnreadNotifications ( User  $user,
  $unreadLimit = null 
)
Parameters
User$user
int$unreadLimit
Returns
int|bool The number of unread notifications true if greater than or equal to $unreadLimit
WatchedItemStore::countVisitingWatchers ( LinkTarget  $target,
  $threshold 
)

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

Parameters
LinkTarget$target
mixed$thresholdtimestamp accepted by wfTimestamp
Returns
int
Exceptions
DBUnexpectedError
MWException
WatchedItemStore::countVisitingWatchersMultiple ( array  $targetsWithVisitThresholds,
  $minimumWatchers = null 
)

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

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

Parameters
User$user
Returns
int
WatchedItemStore::countWatchers ( LinkTarget  $target)
Parameters
LinkTarget$target
Returns
int
WatchedItemStore::countWatchersMultiple ( array  $targets,
array  $options = [] 
)
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.
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.

Parameters
LinkTarget$oldTarget
LinkTarget$newTarget
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

Parameters
LinkTarget$oldTarget
LinkTarget$newTarget
static WatchedItemStore::getDefaultInstance ( )
static
Returns
self
WatchedItemStore::getNotificationTimestampsBatch ( User  $user,
array  $targets 
)
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.
WatchedItemStore::getWatchedItem ( User  $user,
LinkTarget  $target 
)

Get an item (may be cached)

Parameters
User$user
LinkTarget$target
Returns
WatchedItem|false
WatchedItemStore::getWatchedItemsForUser ( User  $user,
array  $options = [] 
)
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[]
WatchedItemStore::isWatched ( User  $user,
LinkTarget  $target 
)

Must be called separately for Subject & Talk namespaces

Parameters
User$user
LinkTarget$target
Returns
bool
WatchedItemStore::loadWatchedItem ( User  $user,
LinkTarget  $target 
)

Loads an item from the db

Parameters
User$user
LinkTarget$target
Returns
WatchedItem|false
static WatchedItemStore::overrideDefaultInstance ( WatchedItemStore  $store = null)
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.

Parameters
WatchedItemStore | null$store
Returns
ScopedCallback to reset the overridden value
Exceptions
MWException
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.

Parameters
callable$callback
See Also
DeferredUpdates::addCallableUpdate for callback signiture
Returns
ScopedCallback to reset the overridden value
Exceptions
MWException
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.

Parameters
callable$callback
See Also
Revision::getTimestampFromId for callback signiture
Returns
ScopedCallback to reset the overridden value
Exceptions
MWException
WatchedItemStore::removeWatch ( User  $user,
LinkTarget  $target 
)

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

Parameters
User$user
LinkTarget$target
Returns
bool success
Exceptions
DBUnexpectedError
MWException
WatchedItemStore::resetNotificationTimestamp ( User  $user,
Title  $title,
  $force = '',
  $oldid = 0 
)

Reset the notification timestamp of this entry

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
WatchedItemStore::setStatsdDataFactory ( StatsdDataFactoryInterface  $statsFactory)

Sets a StatsdDataFactory instance on the object

Parameters
StatsdDataFactoryInterface$statsFactory
Returns
null

Implements StatsdAwareInterface.

WatchedItemStore::updateNotificationTimestamp ( User  $editor,
LinkTarget  $target,
  $timestamp 
)
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

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