Remove unused deprecated WatchedItem methods

Not used in core or in any extensions on Gerrit

Change-Id: I10f0e98f52189f60480f5adb824a5cca9820d5f5
This commit is contained in:
addshore 2016-07-14 13:48:10 +01:00 committed by Addshore
parent 94ab94bd2d
commit 165a30184e
3 changed files with 7 additions and 113 deletions

View file

@ -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

View file

@ -1,4 +1,5 @@
<?php
use MediaWiki\MediaWikiServices;
/**
* @author Addshore
@ -63,7 +64,9 @@ class WatchedItemIntegrationTest extends MediaWikiTestCase {
WatchedItem::fromUserTitle( $user, $title )->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,

View file

@ -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 ] );
}
}