diff --git a/RELEASE-NOTES-1.35 b/RELEASE-NOTES-1.35 index 1b04a921b88..4359e14e568 100644 --- a/RELEASE-NOTES-1.35 +++ b/RELEASE-NOTES-1.35 @@ -609,6 +609,7 @@ because of Phabricator reports. - ::countByPageId - use RevisionStore::countRevisionsByPageId instead - ::countByTitle - use RevisionStore::countRevisionsByTitle instead - ::newKnownCurrent - use RevisionStore::getKnownCurrentRevision instead + - ::getParentLengths - use RevisionStore::getRevisionSizes instead * RecentChange::markPatrolled was deprecated. Use ::doMarkPatrolled instead. * The JobRunner class has been converted to a service class. Direct construction is deprecated, use MediaWikiServices::getJobRunner. @@ -618,6 +619,7 @@ because of Phabricator reports. * LogEventsList::typeAction accepts an optional right to check against as the fourth parameter. Specifying such a right is deprecated. * RevisionStore::loadRevisionFromTitle was deprecated. +* RevisionStore::listRevisionSizes was deprecated. * SkinTemplate::makeArticleUrlDetails has been deprecated, no longer used. * The "mediawiki.legacy.oldshared" module has been deprecated. Skins and extensions that are using this should copy its necessary CSS rules diff --git a/includes/Revision.php b/includes/Revision.php index f67ddb5db7e..59ce2d3b93c 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -320,13 +320,15 @@ class Revision implements IDBAccessObject { * Do a batched query to get the parent revision lengths * * @deprecated in 1.31, use RevisionStore::getRevisionSizes instead. + * Hard deprecated since 1.35. * * @param IDatabase $db * @param array $revIds * @return array */ public static function getParentLengths( $db, array $revIds ) { - return self::getRevisionStore()->listRevisionSizes( $db, $revIds ); + wfDeprecated( __METHOD__, '1.31' ); + return self::getRevisionStore()->getRevisionSizes( $revIds ); } /** diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php index 5ea51929473..ec62081c136 100644 --- a/includes/Revision/RevisionStore.php +++ b/includes/Revision/RevisionStore.php @@ -2885,30 +2885,13 @@ class RevisionStore * of the corresponding revision. */ public function getRevisionSizes( array $revIds ) { - return $this->listRevisionSizes( $this->getDBConnectionRef( DB_REPLICA ), $revIds ); - } - - /** - * Do a batched query for the sizes of a set of revisions. - * - * MCR migration note: this replaces Revision::getParentLengths - * - * @deprecated use RevisionStore::getRevisionSizes instead. - * - * @param IDatabase $db - * @param int[] $revIds - * @return int[] associative array mapping revision IDs from $revIds to the nominal size - * of the corresponding revision. - */ - public function listRevisionSizes( IDatabase $db, array $revIds ) { - $this->checkDatabaseDomain( $db ); - + $dbr = $this->getDBConnectionRef( DB_REPLICA ); $revLens = []; if ( !$revIds ) { return $revLens; // empty } - $res = $db->select( + $res = $dbr->select( 'revision', [ 'rev_id', 'rev_len' ], [ 'rev_id' => $revIds ], @@ -2922,6 +2905,23 @@ class RevisionStore return $revLens; } + /** + * Do a batched query for the sizes of a set of revisions. + * + * MCR migration note: this replaces Revision::getParentLengths + * + * @deprecated since 1.35 use RevisionStore::getRevisionSizes instead. + * + * @param IDatabase $db + * @param int[] $revIds + * @return int[] associative array mapping revision IDs from $revIds to the nominal size + * of the corresponding revision. + */ + public function listRevisionSizes( IDatabase $db, array $revIds ) { + wfDeprecated( __METHOD__, '1.35' ); + return $this->getRevisionSizes( $revIds ); + } + /** * Implementation of getPreviousRevision and getNextRevision. * diff --git a/includes/api/ApiQueryUserContribs.php b/includes/api/ApiQueryUserContribs.php index 4223e26f67f..b4bf10d8656 100644 --- a/includes/api/ApiQueryUserContribs.php +++ b/includes/api/ApiQueryUserContribs.php @@ -242,7 +242,7 @@ class ApiQueryUserContribs extends ApiQueryBase { } } $this->parentLens = MediaWikiServices::getInstance()->getRevisionStore() - ->listRevisionSizes( $dbSecondary, $revIds ); + ->getRevisionSizes( $revIds ); } foreach ( $res as $row ) { diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index 0339afcfed1..6704c9b4c3a 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -86,9 +86,6 @@ class ContribsPager extends RangeChronologicalPager { private $preventClickjacking = false; - /** @var IDatabase */ - private $mDbSecondary; - /** * @var array */ @@ -141,9 +138,7 @@ class ContribsPager extends RangeChronologicalPager { $this->getDateRangeCond( $startTimestamp, $endTimestamp ); // Most of this code will use the 'contributions' group DB, which can map to replica DBs - // with extra user based indexes or partioning by user. The additional metadata - // queries should use a regular replica DB since the lookup pattern is not all by user. - $this->mDbSecondary = wfGetDB( DB_REPLICA ); // any random replica DB + // with extra user based indexes or partioning by user. $this->mDb = wfGetDB( DB_REPLICA, 'contributions' ); $this->templateParser = new TemplateParser(); } @@ -508,10 +503,9 @@ class ContribsPager extends RangeChronologicalPager { } } # Fetch rev_len for revisions not already scanned above - $this->mParentLens += Revision::getParentLengths( - $this->mDbSecondary, - array_diff( $parentRevIds, array_keys( $this->mParentLens ) ) - ); + $this->mParentLens += MediaWikiServices::getInstance() + ->getRevisionStore() + ->getRevisionSizes( array_diff( $parentRevIds, array_keys( $this->mParentLens ) ) ); $batch->execute(); $this->mResult->seek( 0 ); } diff --git a/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php b/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php index edd932776f5..652d3e4f94d 100644 --- a/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php +++ b/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php @@ -1407,7 +1407,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase { } /** - * @covers \MediaWiki\Revision\RevisionStore::listRevisionSizes + * @covers \MediaWiki\Revision\RevisionStore::getRevisionSizes */ public function testGetParentLengths() { $page = WikiPage::factory( Title::newFromText( __METHOD__ ) ); @@ -1425,20 +1425,14 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase { [ $revOne->getId() => strlen( __METHOD__ ), ], - $store->listRevisionSizes( - wfGetDB( DB_MASTER ), - [ $revOne->getId() ] - ) + $store->getRevisionSizes( [ $revOne->getId() ] ) ); $this->assertSame( [ $revOne->getId() => strlen( __METHOD__ ), $revTwo->getId() => strlen( __METHOD__ ) + 1, ], - $store->listRevisionSizes( - wfGetDB( DB_MASTER ), - [ $revOne->getId(), $revTwo->getId() ] - ) + $store->getRevisionSizes( [ $revOne->getId(), $revTwo->getId() ] ) ); } diff --git a/tests/phpunit/includes/RevisionDbTestBase.php b/tests/phpunit/includes/RevisionDbTestBase.php index 146c6589941..03cfa8f562b 100644 --- a/tests/phpunit/includes/RevisionDbTestBase.php +++ b/tests/phpunit/includes/RevisionDbTestBase.php @@ -1206,6 +1206,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase { * @covers Revision::getParentLengths */ public function testGetParentLengths_noRevIds() { + $this->hideDeprecated( Revision::class . '::getParentLengths' ); $this->assertSame( [], Revision::getParentLengths( @@ -1225,6 +1226,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase { $this->testPage->doEditContent( new WikitextContent( $text ), __METHOD__ ); $rev[1] = $this->testPage->getLatest(); + $this->hideDeprecated( Revision::class . '::getParentLengths' ); $this->assertSame( [ $rev[1] => $textLength ], Revision::getParentLengths( @@ -1248,6 +1250,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase { $this->testPage->doEditContent( new WikitextContent( $textTwo ), __METHOD__ ); $rev[2] = $this->testPage->getLatest(); + $this->hideDeprecated( Revision::class . '::getParentLengths' ); $this->assertSame( [ $rev[1] => $textOneLength, $rev[2] => $textTwoLength ], Revision::getParentLengths(