From e4f1fbddecf4fee12cd6bf3429e5c7d112a307a4 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Thu, 9 May 2019 16:19:53 +0100 Subject: [PATCH] page: Remove deprecated/unused methods in PageArchive class This code is no longer used per usage (below) and was to be actually removed in 1.33. Methods are; getLastRevisionText(), listAllPages() and getTextFromRow(), see example search of usage below. Usage ===== https://codesearch.wmflabs.org/search/?q=%5CbgetTextFromRow%5Cb&i=nope&files=&repos= Change-Id: I4b9675a9cf84442f08f125f4c23ec67d72b12c15 --- RELEASE-NOTES-1.34 | 2 + includes/page/PageArchive.php | 71 ------------------- .../includes/page/PageArchivePreMcrTest.php | 18 ----- .../includes/page/PageArchiveTestBase.php | 21 ------ 4 files changed, 2 insertions(+), 110 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 7a10b7e1ae..5cb3dbe1f0 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -141,6 +141,8 @@ because of Phabricator reports. use WatchAction::getWatchToken() with action 'unwatch' directly. * Language::initEncoding(), ::recodeForEdit(), and recodeInput(), deprecated in 1.28, have been removed. +* PageArchive::getTextFromRow(), ::listAllPages(), and ::getLastRevisionText(), + deprecated in 1.32, have been removed. * … === Deprecations in 1.34 === diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php index e843cf38da..a314f3a9ea 100644 --- a/includes/page/PageArchive.php +++ b/includes/page/PageArchive.php @@ -21,7 +21,6 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Revision\RevisionRecord; use MediaWiki\Revision\RevisionStore; -use MediaWiki\Storage\SqlBlobStore; use Wikimedia\Assert\Assert; use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\IDatabase; @@ -69,23 +68,6 @@ class PageArchive { return true; } - /** - * List all deleted pages recorded in the archive table. Returns result - * wrapper with (ar_namespace, ar_title, count) fields, ordered by page - * namespace/title. - * - * @deprecated since 1.32. - * - * @return IResultWrapper - */ - public static function listAllPages() { - wfDeprecated( __METHOD__, '1.32' ); - - $dbr = wfGetDB( DB_REPLICA ); - - return self::listPages( $dbr, '' ); - } - /** * List deleted pages recorded in the archive matching the * given term, using search engine archive. @@ -370,59 +352,6 @@ class PageArchive { return $rec; } - /** - * Get the text from an archive row containing ar_text_id. - * - * @deprecated since 1.32. In the MCR schema, ar_text_id no longer exists. - * Calling code should switch to getArchiveRevision(). - * - * @todo remove in 1.33 - * - * @param object $row Database row - * @return string - */ - public function getTextFromRow( $row ) { - wfDeprecated( __METHOD__, '1.32' ); - - if ( empty( $row->ar_text_id ) ) { - throw new InvalidArgumentException( '$row->ar_text_id must be set and not empty!' ); - } - - $address = SqlBlobStore::makeAddressFromTextId( $row->ar_text_id ); - $blobStore = MediaWikiServices::getInstance()->getBlobStore(); - - return $blobStore->getBlob( $address ); - } - - /** - * Fetch (and decompress if necessary) the stored text of the most - * recently edited deleted revision of the page. - * - * If there are no archived revisions for the page, returns NULL. - * - * @note this bypasses any audience checks. - * - * @deprecated since 1.32. For compatibility with the MCR schema, - * calling code should switch to getLastRevisionId() and getArchiveRevision(). - * - * @todo remove in 1.33 - * - * @return string|null - */ - public function getLastRevisionText() { - wfDeprecated( __METHOD__, '1.32' ); - - $revId = $this->getLastRevisionId(); - - if ( $revId ) { - $rev = $this->getArchivedRevision( $revId ); - $content = $rev->getContent( RevisionRecord::RAW ); - return $content->serialize(); - } - - return null; - } - /** * Returns the ID of the latest deleted revision. * diff --git a/tests/phpunit/includes/page/PageArchivePreMcrTest.php b/tests/phpunit/includes/page/PageArchivePreMcrTest.php index 8d7ed61217..fcb10e7e9c 100644 --- a/tests/phpunit/includes/page/PageArchivePreMcrTest.php +++ b/tests/phpunit/includes/page/PageArchivePreMcrTest.php @@ -18,24 +18,6 @@ class PageArchivePreMcrTest extends PageArchiveTestBase { use PreMcrSchemaOverride; - /** - * @covers PageArchive::getTextFromRow - */ - public function testGetTextFromRow() { - $this->hideDeprecated( PageArchive::class . '::getTextFromRow' ); - - /** @var SqlBlobStore $blobStore */ - $blobStore = MediaWikiServices::getInstance()->getBlobStore(); - - $textId = $blobStore->getTextIdFromAddress( - $this->firstRev->getSlot( SlotRecord::MAIN )->getAddress() - ); - - $row = (object)[ 'ar_text_id' => $textId ]; - $text = $this->archivedPage->getTextFromRow( $row ); - $this->assertSame( 'testing', $text ); - } - protected function getExpectedArchiveRows() { /** @var SqlBlobStore $blobStore */ $blobStore = MediaWikiServices::getInstance()->getBlobStore(); diff --git a/tests/phpunit/includes/page/PageArchiveTestBase.php b/tests/phpunit/includes/page/PageArchiveTestBase.php index 218d4ce2a4..15c64a9431 100644 --- a/tests/phpunit/includes/page/PageArchiveTestBase.php +++ b/tests/phpunit/includes/page/PageArchiveTestBase.php @@ -252,27 +252,6 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase { yield 'ar_text_id is "0"' => [ [ 'ar_text_id' => '0' ] ]; } - /** - * @dataProvider provideGetTextFromRowThrowsInvalidArgumentException - * @covers PageArchive::getTextFromRow - */ - public function testGetTextFromRowThrowsInvalidArgumentException( array $row ) { - $this->hideDeprecated( PageArchive::class . '::getTextFromRow' ); - $this->setExpectedException( InvalidArgumentException::class ); - - $this->archivedPage->getTextFromRow( (object)$row ); - } - - /** - * @covers PageArchive::getLastRevisionText - */ - public function testGetLastRevisionText() { - $this->hideDeprecated( PageArchive::class . '::getLastRevisionText' ); - - $text = $this->archivedPage->getLastRevisionText(); - $this->assertSame( 'Lorem Ipsum', $text ); - } - /** * @covers PageArchive::getLastRevisionId */ -- 2.20.1