'LonelyPagesPage' => __DIR__ . '/includes/specials/SpecialLonelypages.php',
'LongPagesPage' => __DIR__ . '/includes/specials/SpecialLongpages.php',
'MIMEsearchPage' => __DIR__ . '/includes/specials/SpecialMIMEsearch.php',
- 'MWCallableUpdate' => __DIR__ . '/includes/deferred/CallableUpdate.php',
+ 'MWCallableUpdate' => __DIR__ . '/includes/deferred/MWCallableUpdate.php',
'MWContentSerializationException' => __DIR__ . '/includes/content/ContentHandler.php',
'MWCryptHKDF' => __DIR__ . '/includes/utils/MWCryptHKDF.php',
'MWCryptHash' => __DIR__ . '/includes/utils/MWCryptHash.php',
return new self( $user, $title, self::DEPRECATED_USAGE_TIMESTAMP, (bool)$checkRights );
}
- /**
- * @deprecated since 1.27 Use WatchedItemStore::resetNotificationTimestamp()
- */
- public function resetNotificationTimestamp( $force = '', $oldid = 0 ) {
- wfDeprecated( __METHOD__, '1.27' );
- if ( $this->checkRights && !$this->user->isAllowed( 'editmywatchlist' ) ) {
- return;
- }
- MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
- $this->user,
- $this->getTitle(),
- $force,
- $oldid
- );
- }
-
- /**
- * @deprecated since 1.27 Use WatchedItemStore::addWatchBatch()
- */
- public static function batchAddWatch( array $items ) {
- wfDeprecated( __METHOD__, '1.27' );
- if ( !$items ) {
- return false;
- }
-
- $targets = [];
- $users = [];
- /** @var WatchedItem $watchedItem */
- foreach ( $items as $watchedItem ) {
- $user = $watchedItem->getUser();
- if ( $watchedItem->checkRights && !$user->isAllowed( 'editmywatchlist' ) ) {
- continue;
- }
- $userId = $user->getId();
- $users[$userId] = $user;
- $targets[$userId][] = $watchedItem->getTitle()->getSubjectPage();
- $targets[$userId][] = $watchedItem->getTitle()->getTalkPage();
- }
-
- $store = MediaWikiServices::getInstance()->getWatchedItemStore();
- $success = true;
- foreach ( $users as $userId => $user ) {
- $success &= $store->addWatchBatchForUser( $user, $targets[$userId] );
- }
-
- return $success;
- }
-
/**
* @deprecated since 1.27 Use User::addWatch()
* @return bool
+++ /dev/null
-<?php
-
-/**
- * Deferrable Update for closure/callback
- */
-class MWCallableUpdate implements DeferrableUpdate, DeferrableCallback {
- /** @var callable */
- private $callback;
- /** @var string */
- private $fname;
-
- /**
- * @param callable $callback
- * @param string $fname Calling method
- */
- public function __construct( callable $callback, $fname = 'unknown' ) {
- $this->callback = $callback;
- $this->fname = $fname;
- }
-
- public function doUpdate() {
- call_user_func( $this->callback );
- }
-
- public function getOrigin() {
- return $this->fname;
- }
-}
--- /dev/null
+<?php
+
+/**
+ * Deferrable Update for closure/callback
+ */
+class MWCallableUpdate implements DeferrableUpdate, DeferrableCallback {
+ /** @var callable */
+ private $callback;
+ /** @var string */
+ private $fname;
+
+ /**
+ * @param callable $callback
+ * @param string $fname Calling method
+ */
+ public function __construct( callable $callback, $fname = 'unknown' ) {
+ $this->callback = $callback;
+ $this->fname = $fname;
+ }
+
+ public function doUpdate() {
+ call_user_func( $this->callback );
+ }
+
+ public function getOrigin() {
+ return $this->fname;
+ }
+}
<?php
+use MediaWiki\MediaWikiServices;
/**
* @author Addshore
WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp()
);
- WatchedItem::fromUserTitle( $user, $title )->resetNotificationTimestamp();
+ MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
+ $user, $title
+ );
$this->assertNull( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
}
$user = $this->getUser();
$title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
WatchedItem::fromUserTitle( $user, $title )->addWatch();
- WatchedItem::fromUserTitle( $user, $title )->resetNotificationTimestamp();
+ MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
+ $user, $title
+ );
$this->assertEquals(
null,
$this->assertEquals( $timestamp, $item->getNotificationTimestamp() );
}
- /**
- * @dataProvider provideUserTitleTimestamp
- */
- public function testResetNotificationTimestamp( $user, $linkTarget, $timestamp ) {
- $force = 'XXX';
- $oldid = 999;
-
- $store = $this->getMockWatchedItemStore();
- $store->expects( $this->once() )
- ->method( 'resetNotificationTimestamp' )
- ->with( $user, $this->isInstanceOf( Title::class ), $force, $oldid )
- ->will( $this->returnCallback(
- function ( $user, Title $title, $force, $oldid ) use ( $linkTarget ) {
- /** @var LinkTarget $linkTarget */
- $this->assertInstanceOf( 'Title', $title );
- $this->assertSame( $linkTarget->getDBkey(), $title->getDBkey() );
- $this->assertSame( $linkTarget->getFragment(), $title->getFragment() );
- $this->assertSame( $linkTarget->getNamespace(), $title->getNamespace() );
- $this->assertSame( $linkTarget->getText(), $title->getText() );
-
- return true;
- }
- ) );
- $this->setService( 'WatchedItemStore', $store );
-
- $item = new WatchedItem( $user, $linkTarget, $timestamp );
- $item->resetNotificationTimestamp( $force, $oldid );
- }
-
public function testAddWatch() {
$title = Title::newFromText( 'SomeTitle' );
$timestamp = null;
WatchedItem::duplicateEntries( $oldTitle, $newTitle );
}
- public function testBatchAddWatch() {
- $itemOne = new WatchedItem( $this->getMockUser( 1 ), new TitleValue( 0, 'Title1' ), null );
- $itemTwo = new WatchedItem(
- $this->getMockUser( 3 ),
- Title::newFromText( 'Title2' ),
- '20150101010101'
- );
-
- $store = $this->getMockWatchedItemStore();
- $store->expects( $this->exactly( 2 ) )
- ->method( 'addWatchBatchForUser' );
- $store->expects( $this->at( 0 ) )
- ->method( 'addWatchBatchForUser' )
- ->with(
- $itemOne->getUser(),
- [
- $itemOne->getTitle()->getSubjectPage(),
- $itemOne->getTitle()->getTalkPage(),
- ]
- );
- $store->expects( $this->at( 1 ) )
- ->method( 'addWatchBatchForUser' )
- ->with(
- $itemTwo->getUser(),
- [
- $itemTwo->getTitle()->getSubjectPage(),
- $itemTwo->getTitle()->getTalkPage(),
- ]
- );
- $this->setService( 'WatchedItemStore', $store );
-
- WatchedItem::batchAddWatch( [ $itemOne, $itemTwo ] );
- }
-
}