* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Handles the backend logic of moving a page from one title
* to another.
$oldsnamespace = MWNamespace::getSubject( $this->oldTitle->getNamespace() );
$newsnamespace = MWNamespace::getSubject( $this->newTitle->getNamespace() );
if ( $oldsnamespace != $newsnamespace || $oldtitle != $newtitle ) {
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
$store->duplicateAllAssociatedEntries( $this->oldTitle, $this->newTitle );
}
*/
use MediaWiki\Linker\LinkTarget;
+use MediaWiki\MediaWikiServices;
+
/**
* Represents a title within MediaWiki.
* Optionally may contain an interwiki designation or namespace.
$this->mNotificationTimestamp = [];
}
- $watchedItem = WatchedItemStore::getDefaultInstance()->getWatchedItem( $user, $this );
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $watchedItem = $store->getWatchedItem( $user, $this );
if ( $watchedItem ) {
$this->mNotificationTimestamp[$uid] = $watchedItem->getNotificationTimestamp();
} else {
* @file
* @ingroup Watchlist
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Linker\LinkTarget;
/**
if ( $this->checkRights && !$this->user->isAllowed( 'viewmywatchlist' ) ) {
return false;
}
- $item = WatchedItemStore::getDefaultInstance()
+ $item = MediaWikiServices::getInstance()->getWatchedItemStore()
->loadWatchedItem( $this->user, $this->linkTarget );
if ( $item ) {
$this->notificationTimestamp = $item->getNotificationTimestamp();
if ( $this->checkRights && !$this->user->isAllowed( 'editmywatchlist' ) ) {
return;
}
- WatchedItemStore::getDefaultInstance()->resetNotificationTimestamp(
+ MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
$this->user,
$this->getTitle(),
$force,
$targets[$userId][] = $watchedItem->getTitle()->getTalkPage();
}
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
$success = true;
foreach ( $users as $userId => $user ) {
$success &= $store->addWatchBatchForUser( $user, $targets[$userId] );
*/
public static function duplicateEntries( Title $oldTitle, Title $newTitle ) {
// wfDeprecated( __METHOD__, '1.27' );
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
$store->duplicateAllAssociatedEntries( $oldTitle, $newTitle );
}
} );
}
- /**
- * @deprecated use MediaWikiServices::getInstance()->getWatchedItemStore()
- * @return self
- */
- public static function getDefaultInstance() {
- return MediaWikiServices::getInstance()->getWatchedItemStore();
- }
-
private function getCacheKey( User $user, LinkTarget $target ) {
return $this->cache->makeKey(
(string)$target->getNamespace(),
* @ingroup Actions
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Displays information about a page.
*
$setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
- $watchedItemStore = WatchedItemStore::getDefaultInstance();
+ $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
$result = [];
$result['watchers'] = $watchedItemStore->countWatchers( $title );
*
* @file
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Linker\LinkTarget;
/**
$this->watched = [];
$this->notificationtimestamps = [];
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
$timestamps = $store->getNotificationTimestampsBatch( $user, $this->everything );
if ( $this->fld_watched ) {
$countOptions['minimumWatchers'] = $unwatchedPageThreshold;
}
- $this->watchers = WatchedItemStore::getDefaultInstance()->countWatchersMultiple(
+ $this->watchers = MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchersMultiple(
$this->everything,
$countOptions
);
)
);
}
-
- $this->visitingwatchers = WatchedItemStore::getDefaultInstance()->countVisitingWatchersMultiple(
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $this->visitingwatchers = $store->countVisitingWatchersMultiple(
$titlesWithThresholds,
!$canUnwatchedpages ? $unwatchedPageThreshold : null
);
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Query module to get information about the currently logged-in user
*
}
if ( isset( $this->prop['unreadcount'] ) ) {
- $unreadNotifications = WatchedItemStore::getDefaultInstance()->countUnreadNotifications(
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $unreadNotifications = $store->countUnreadNotifications(
$user,
self::WL_UNREAD_LIMIT
);
*/
use MediaWiki\Linker\LinkTarget;
+use MediaWiki\MediaWikiServices;
+
/**
* This module processes the email notifications when the current page is
* changed. It looks up the table watchlist to find out which users are watching
if ( !$config->get( 'EnotifWatchlist' ) && !$config->get( 'ShowUpdatedMarker' ) ) {
return [];
}
- return WatchedItemStore::getDefaultInstance()->updateNotificationTimestamp(
+ return MediaWikiServices::getInstance()->getWatchedItemStore()->updateNotificationTimestamp(
$editor,
$linkTarget,
$timestamp
$config = RequestContext::getMain()->getConfig();
$watchers = [];
if ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) ) {
- $watchers = WatchedItemStore::getDefaultInstance()->updateNotificationTimestamp(
+ $watchers = MediaWikiServices::getInstance()->getWatchedItemStore()->updateNotificationTimestamp(
$editor,
$title,
$timestamp
* @ingroup Watchlist
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Provides the UI through which users can perform editing
* operations on their watchlist
private function getWatchlist() {
$list = [];
- $watchedItems = WatchedItemStore::getDefaultInstance()->getWatchedItemsForUser(
+ $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()->getWatchedItemsForUser(
$this->getUser(),
[ 'forWrite' => $this->getRequest()->wasPosted() ]
);
protected function getWatchlistInfo() {
$titles = [];
- $watchedItems = WatchedItemStore::getDefaultInstance()
+ $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()
->getWatchedItemsForUser( $this->getUser(), [ 'sort' => WatchedItemStore::SORT_ASC ] );
$lb = new LinkBatch();
}
$user = $this->getUser();
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
foreach ( $this->badItems as $row ) {
list( $title, $namespace, $dbKey ) = $row;
$expandedTargets[] = new TitleValue( MWNamespace::getTalk( $ns ), $dbKey );
}
- WatchedItemStore::getDefaultInstance()->addWatchBatchForUser(
+ MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
$this->getUser(),
$expandedTargets
);
* @param array $titles Array of strings, or Title objects
*/
private function unwatchTitles( $titles ) {
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
foreach ( $titles as $title ) {
if ( !$title instanceof Title ) {
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page that lists last changes made to the wiki
*
if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
$watcherCache[$obj->rc_namespace][$obj->rc_title] =
- WatchedItemStore::getDefaultInstance()->countWatchers(
+ MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(
new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
);
}
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page that lists last changes made to the wiki,
* limited to user-defined list of titles.
if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
&& $user->getOption( 'shownumberswatching' )
) {
- $watchedItemStore = WatchedItemStore::getDefaultInstance();
+ $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
}
$s = $list->beginRecentChangesList();
* @return int
*/
protected function countItems() {
- $count = WatchedItemStore::getDefaultInstance()->countWatchedItems( $this->getUser() );
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $count = $store->countWatchedItems( $this->getUser() );
return floor( $count / 2 );
}
}
*/
public function isWatched( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
if ( $title->isWatchable() && ( !$checkRights || $this->isAllowed( 'viewmywatchlist' ) ) ) {
- return WatchedItemStore::getDefaultInstance()->isWatched( $this, $title );
+ return MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched( $this, $title );
}
return false;
}
*/
public function addWatch( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
if ( !$checkRights || $this->isAllowed( 'editmywatchlist' ) ) {
- WatchedItemStore::getDefaultInstance()->addWatchBatchForUser(
+ MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
$this,
[ $title->getSubjectPage(), $title->getTalkPage() ]
);
*/
public function removeWatch( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
if ( !$checkRights || $this->isAllowed( 'editmywatchlist' ) ) {
- WatchedItemStore::getDefaultInstance()->removeWatch( $this, $title->getSubjectPage() );
- WatchedItemStore::getDefaultInstance()->removeWatch( $this, $title->getTalkPage() );
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ $store->removeWatch( $this, $title->getSubjectPage() );
+ $store->removeWatch( $this, $title->getTalkPage() );
}
$this->invalidateCache();
}
$force = 'force';
}
- WatchedItemStore::getDefaultInstance()
+ MediaWikiServices::getInstance()->getWatchedItemStore()
->resetNotificationTimestamp( $this, $title, $force, $oldid );
}
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* @author Addshore
*
public function testWatchAndUnWatchItem() {
$user = $this->getUser();
$title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' );
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
// Cleanup after previous tests
$store->removeWatch( $user, $title );
$initialWatchers = $store->countWatchers( $title );
$user = $this->getUser();
$otherUser = ( new TestUser( 'WatchedItemStoreIntegrationTestUser_otherUser' ) )->getUser();
$title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' );
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
$store->addWatch( $user, $title );
$this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
$initialVisitingWatchers = $store->countVisitingWatchers( $title, '20150202020202' );
$user = $this->getUser();
$titleOld = Title::newFromText( 'WatchedItemStoreIntegrationTestPageOld' );
$titleNew = Title::newFromText( 'WatchedItemStoreIntegrationTestPageNew' );
- $store = WatchedItemStore::getDefaultInstance();
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
$store->addWatch( $user, $titleOld->getSubjectPage() );
$store->addWatch( $user, $titleOld->getTalkPage() );
// Cleanup after previous tests
);
}
- public function testGetDefaultInstance() {
- $instanceOne = WatchedItemStore::getDefaultInstance();
- $instanceTwo = WatchedItemStore::getDefaultInstance();
- $this->assertSame( $instanceOne, $instanceTwo );
- }
-
public function testCountWatchedItems() {
$user = $this->getMockNonAnonUserWithId( 1 );