Hard deprecate Revision::getParentLengths
As well hard-deprecate RevisionStore::listRevisionSizes. It was marked as @deprecated, but the release for the deprecation was not specified. Let's say it's 1.35. Additionally, in order to avoid temporary code duplication, listRevisionSizes now uses getRevisionSizes and ignores the database object injected into it. This is ok since we're hard-deprecating the method and all the usages have been removed. Bug: T246284 Change-Id: Ifad1c25a0af892b88fce492b2d34c8cf71279b70
This commit is contained in:
parent
03fb3e9f8f
commit
ebd35bdc85
7 changed files with 35 additions and 40 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class ApiQueryUserContribs extends ApiQueryBase {
|
|||
}
|
||||
}
|
||||
$this->parentLens = MediaWikiServices::getInstance()->getRevisionStore()
|
||||
->listRevisionSizes( $dbSecondary, $revIds );
|
||||
->getRevisionSizes( $revIds );
|
||||
}
|
||||
|
||||
foreach ( $res as $row ) {
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() ] )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue