From 165a30184ea7432eaf905db8e4024b6ea5834748 Mon Sep 17 00:00:00 2001 From: addshore Date: Thu, 14 Jul 2016 13:48:10 +0100 Subject: [PATCH] Remove unused deprecated WatchedItem methods Not used in core or in any extensions on Gerrit Change-Id: I10f0e98f52189f60480f5adb824a5cca9820d5f5 --- includes/WatchedItem.php | 48 -------------- .../includes/WatchedItemIntegrationTest.php | 9 ++- .../phpunit/includes/WatchedItemUnitTest.php | 63 ------------------- 3 files changed, 7 insertions(+), 113 deletions(-) diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index b070e1eba6..bfd1d6136b 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -156,54 +156,6 @@ class WatchedItem { 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 diff --git a/tests/phpunit/includes/WatchedItemIntegrationTest.php b/tests/phpunit/includes/WatchedItemIntegrationTest.php index be22260d76..0c813dac5c 100644 --- a/tests/phpunit/includes/WatchedItemIntegrationTest.php +++ b/tests/phpunit/includes/WatchedItemIntegrationTest.php @@ -1,4 +1,5 @@ getNotificationTimestamp() ); - WatchedItem::fromUserTitle( $user, $title )->resetNotificationTimestamp(); + MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp( + $user, $title + ); $this->assertNull( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() ); } @@ -107,7 +110,9 @@ class WatchedItemIntegrationTest extends MediaWikiTestCase { $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, diff --git a/tests/phpunit/includes/WatchedItemUnitTest.php b/tests/phpunit/includes/WatchedItemUnitTest.php index 0182eb7fc4..7e1ff3d7a9 100644 --- a/tests/phpunit/includes/WatchedItemUnitTest.php +++ b/tests/phpunit/includes/WatchedItemUnitTest.php @@ -78,35 +78,6 @@ class WatchedItemUnitTest extends MediaWikiTestCase { $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; @@ -176,38 +147,4 @@ class WatchedItemUnitTest extends MediaWikiTestCase { 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 ] ); - } - } -- 2.20.1