Hard deprecate Revision::getQueryInfo and ::getArchiveQueryInfo
Bug: T246284 Change-Id: I708f265aac3016e34d02936cf5dff98a3036ef0f
This commit is contained in:
parent
8ca9f34270
commit
1d4df4f221
20 changed files with 90 additions and 35 deletions
|
|
@ -660,6 +660,8 @@ because of Phabricator reports.
|
|||
- ::newKnownCurrent - use RevisionStore::getKnownCurrentRevision instead
|
||||
- ::getParentLengths - use RevisionStore::getRevisionSizes instead
|
||||
- ::setTitle - the method was previously a no-op
|
||||
- ::getQueryInfo - use RevisionStore::getQueryInfo instead
|
||||
- ::getArchiveQueryInfo - use RevisionStore::getArchiveQueryInfo 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.
|
||||
|
|
|
|||
|
|
@ -1886,7 +1886,7 @@ class Linker {
|
|||
$dbr = wfGetDB( DB_REPLICA );
|
||||
|
||||
// Up to the value of $wgShowRollbackEditCount revisions are counted
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
|
||||
$res = $dbr->select(
|
||||
$revQuery['tables'],
|
||||
[ 'rev_user_text' => $revQuery['fields']['rev_user_text'], 'rev_deleted' ],
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class Revision implements IDBAccessObject {
|
|||
* Return the tables, fields, and join conditions to be selected to create
|
||||
* a new revision object.
|
||||
* @since 1.31
|
||||
* @deprecated since 1.31, use RevisionStore::getQueryInfo() instead.
|
||||
* @deprecated since 1.31 (soft), 1.35 (hard), use RevisionStore::getQueryInfo() instead.
|
||||
* @param array $options Any combination of the following strings
|
||||
* - 'page': Join with the page table, and select fields to identify the page
|
||||
* - 'user': Join with the user table, and select the user name
|
||||
|
|
@ -307,6 +307,7 @@ class Revision implements IDBAccessObject {
|
|||
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
|
||||
*/
|
||||
public static function getQueryInfo( $options = [] ) {
|
||||
wfDeprecated( __METHOD__, '1.31' );
|
||||
return self::getRevisionStore()->getQueryInfo( $options );
|
||||
}
|
||||
|
||||
|
|
@ -314,13 +315,15 @@ class Revision implements IDBAccessObject {
|
|||
* Return the tables, fields, and join conditions to be selected to create
|
||||
* a new archived revision object.
|
||||
* @since 1.31
|
||||
* @deprecated since 1.31, use RevisionStore::getArchiveQueryInfo() instead.
|
||||
* @deprecated since 1.31 (soft), 1.35 (hard), use RevisionStore::getArchiveQueryInfo()
|
||||
* instead.
|
||||
* @return array With three keys:
|
||||
* - tables: (string[]) to include in the `$table` to `IDatabase->select()`
|
||||
* - fields: (string[]) to include in the `$vars` to `IDatabase->select()`
|
||||
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
|
||||
*/
|
||||
public static function getArchiveQueryInfo() {
|
||||
wfDeprecated( __METHOD__, '1.31' );
|
||||
return self::getRevisionStore()->getArchiveQueryInfo();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
* @ingroup Change tagging
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
/**
|
||||
|
|
@ -36,7 +37,9 @@ class ChangeTagsRevisionList extends ChangeTagsList {
|
|||
*/
|
||||
public function doQuery( $db ) {
|
||||
$ids = array_map( 'intval', $this->ids );
|
||||
$revQuery = Revision::getQueryInfo( [ 'user' ] );
|
||||
$revQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getQueryInfo( [ 'user' ] );
|
||||
$queryInfo = [
|
||||
'tables' => $revQuery['tables'],
|
||||
'fields' => $revQuery['fields'],
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,7 @@ abstract class ContentHandler {
|
|||
|
||||
// Find out if there was only one contributor
|
||||
// Only scan the last 20 revisions
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
|
||||
$res = $dbr->select(
|
||||
$revQuery['tables'],
|
||||
[ 'rev_user_text' => $revQuery['fields']['rev_user_text'] ],
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use MediaWiki\Content\IContentHandlerFactory;
|
|||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\Revision\RevisionStore;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use MediaWiki\Storage\NameTableAccessException;
|
||||
|
||||
|
|
@ -214,6 +215,11 @@ class DifferenceEngine extends ContextSource {
|
|||
*/
|
||||
private $contentHandlerFactory;
|
||||
|
||||
/**
|
||||
* @var RevisionStore
|
||||
*/
|
||||
private $revisionStore;
|
||||
|
||||
/** #@- */
|
||||
|
||||
/**
|
||||
|
|
@ -249,8 +255,11 @@ class DifferenceEngine extends ContextSource {
|
|||
$this->mNewid = $new;
|
||||
$this->mRefreshCache = $refreshCache;
|
||||
$this->unhide = $unhide;
|
||||
$this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
||||
$this->contentHandlerFactory = MediaWikiServices::getInstance()->getContentHandlerFactory();
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$this->linkRenderer = $services->getLinkRenderer();
|
||||
$this->contentHandlerFactory = $services->getContentHandlerFactory();
|
||||
$this->revisionStore = $services->getRevisionStore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -427,7 +436,7 @@ class DifferenceEngine extends ContextSource {
|
|||
$permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
|
||||
if ( $permissionManager->userHasRight( $this->getUser(), 'deletedhistory' ) ) {
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$arQuery = Revision::getArchiveQueryInfo();
|
||||
$arQuery = $this->revisionStore->getArchiveQueryInfo();
|
||||
$row = $dbr->selectRow(
|
||||
$arQuery['tables'],
|
||||
array_merge( $arQuery['fields'], [ 'ar_namespace', 'ar_title' ] ),
|
||||
|
|
@ -1591,13 +1600,12 @@ class DifferenceEngine extends ContextSource {
|
|||
|
||||
// Sanity: don't show the notice if too many rows must be scanned
|
||||
// @todo show some special message for that case
|
||||
$nEdits = MediaWikiServices::getInstance()->getRevisionStore()
|
||||
->countRevisionsBetween(
|
||||
$this->mNewPage->getArticleID(),
|
||||
$oldRev->getRevisionRecord(),
|
||||
$newRev->getRevisionRecord(),
|
||||
1000
|
||||
);
|
||||
$nEdits = $this->revisionStore->countRevisionsBetween(
|
||||
$this->mNewPage->getArticleID(),
|
||||
$oldRev->getRevisionRecord(),
|
||||
$newRev->getRevisionRecord(),
|
||||
1000
|
||||
);
|
||||
if ( $nEdits > 0 && $nEdits <= 1000 ) {
|
||||
$limit = 100; // use diff-multi-manyusers if too many users
|
||||
$users = $this->mNewPage->getAuthorsBetween( $oldRev, $newRev, $limit );
|
||||
|
|
|
|||
|
|
@ -246,7 +246,9 @@ class WikiExporter {
|
|||
$this->author_list = "<contributors>";
|
||||
// rev_deleted
|
||||
|
||||
$revQuery = Revision::getQueryInfo( [ 'page' ] );
|
||||
$revQuery = MediaWikiServicesAlias::getInstance()
|
||||
->getRevisionStore()
|
||||
->getQueryInfo( [ 'page' ] );
|
||||
$res = $this->db->select(
|
||||
$revQuery['tables'],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -2860,7 +2860,7 @@ class WikiPage implements Page, IDBAccessObject {
|
|||
$commentStore = CommentStore::getStore();
|
||||
$actorMigration = ActorMigration::newMigration();
|
||||
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = $this->getRevisionStore()->getQueryInfo();
|
||||
$bitfield = false;
|
||||
|
||||
// Bitfields to further suppress the content
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
* @ingroup RevisionDelete
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +44,9 @@ class RevDelArchiveList extends RevDelRevisionList {
|
|||
$timestamps[] = $db->timestamp( $id );
|
||||
}
|
||||
|
||||
$arQuery = Revision::getArchiveQueryInfo();
|
||||
$arQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getArchiveQueryInfo();
|
||||
$tables = $arQuery['tables'];
|
||||
$fields = $arQuery['fields'];
|
||||
$conds = [
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@ class RevDelRevisionList extends RevDelList {
|
|||
* @return mixed
|
||||
*/
|
||||
public function doQuery( $db ) {
|
||||
$revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
|
||||
$ids = array_map( 'intval', $this->ids );
|
||||
$revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
|
||||
$revQuery = $revisionStore->getQueryInfo( [ 'page', 'user' ] );
|
||||
$queryInfo = [
|
||||
'tables' => $revQuery['tables'],
|
||||
'fields' => $revQuery['fields'],
|
||||
|
|
@ -100,7 +101,7 @@ class RevDelRevisionList extends RevDelList {
|
|||
return $live;
|
||||
}
|
||||
|
||||
$arQuery = Revision::getArchiveQueryInfo();
|
||||
$arQuery = $revisionStore->getArchiveQueryInfo();
|
||||
$archiveQueryInfo = [
|
||||
'tables' => $arQuery['tables'],
|
||||
'fields' => $arQuery['fields'],
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
class RevisionList extends RevisionListBase {
|
||||
|
|
@ -36,7 +37,9 @@ class RevisionList extends RevisionListBase {
|
|||
if ( $this->ids !== null ) {
|
||||
$conds['rev_id'] = array_map( 'intval', $this->ids );
|
||||
}
|
||||
$revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
|
||||
$revQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getQueryInfo( [ 'page', 'user' ] );
|
||||
return $db->select(
|
||||
$revQuery['tables'],
|
||||
$revQuery['fields'],
|
||||
|
|
|
|||
|
|
@ -261,7 +261,9 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
}
|
||||
|
||||
function getQueryInfo() {
|
||||
$revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
|
||||
$revQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getQueryInfo( [ 'page', 'user' ] );
|
||||
$queryInfo = [
|
||||
'tables' => $revQuery['tables'],
|
||||
'fields' => array_merge( $revQuery['fields'], [ 'page_is_new' ] ),
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup Pager
|
||||
*/
|
||||
|
|
@ -90,7 +92,11 @@ class MergeHistoryPager extends ReverseChronologicalPager {
|
|||
$conds['rev_page'] = $this->articleID;
|
||||
$conds[] = "rev_timestamp < " . $this->mDb->addQuotes( $this->maxTimestamp );
|
||||
|
||||
$revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
|
||||
// TODO inject a RevisionStore into SpecialMergeHistory and pass it to
|
||||
// the MergeHistoryPager constructor
|
||||
$revQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getQueryInfo( [ 'page', 'user' ] );
|
||||
return [
|
||||
'tables' => $revQuery['tables'],
|
||||
'fields' => $revQuery['fields'],
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
|
|
@ -56,11 +57,23 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
|
|||
return false;
|
||||
}
|
||||
|
||||
$revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
|
||||
|
||||
$this->output( "Populating rev_len column\n" );
|
||||
$rev = $this->doLenUpdates( 'revision', 'rev_id', 'rev', Revision::getQueryInfo() );
|
||||
$rev = $this->doLenUpdates(
|
||||
'revision',
|
||||
'rev_id',
|
||||
'rev',
|
||||
$revisionStore->getQueryInfo()
|
||||
);
|
||||
|
||||
$this->output( "Populating ar_len column\n" );
|
||||
$ar = $this->doLenUpdates( 'archive', 'ar_id', 'ar', Revision::getArchiveQueryInfo() );
|
||||
$ar = $this->doLenUpdates(
|
||||
'archive',
|
||||
'ar_id',
|
||||
'ar',
|
||||
$revisionStore->getArchiveQueryInfo()
|
||||
);
|
||||
|
||||
$this->output( "rev_len and ar_len population complete "
|
||||
. "[$rev revision rows, $ar archive rows].\n" );
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\DatabaseSqlite;
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +85,9 @@ class RebuildTextIndex extends Maintenance {
|
|||
$this->output( "Rebuilding index fields for {$count} pages...\n" );
|
||||
$n = 0;
|
||||
|
||||
$revQuery = Revision::getQueryInfo( [ 'page' ] );
|
||||
$revQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getQueryInfo( [ 'page' ] );
|
||||
|
||||
while ( $n < $count ) {
|
||||
if ( $n ) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ if ( isset( $options['limit'] ) ) {
|
|||
$type = $options['type'] ?? ConcatenatedGzipHistoryBlob::class;
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$revQuery = Revision::getQueryInfo( [ 'page' ] );
|
||||
$revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo( [ 'page' ] );
|
||||
$res = $dbr->select(
|
||||
$revQuery['tables'],
|
||||
$revQuery['fields'],
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideArchiveQueryInfo
|
||||
*/
|
||||
public function testRevisionGetArchiveQueryInfo( $migrationStageSettings, $expected ) {
|
||||
$this->hideDeprecated( 'Revision::getArchiveQueryInfo' );
|
||||
$this->setMwGlobals( $migrationStageSettings );
|
||||
|
||||
$queryInfo = Revision::getArchiveQueryInfo();
|
||||
|
|
@ -311,6 +312,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideQueryInfo
|
||||
*/
|
||||
public function testRevisionGetQueryInfo( $migrationStageSettings, $options, $expected ) {
|
||||
$this->hideDeprecated( 'Revision::getQueryInfo' );
|
||||
$this->setMwGlobals( $migrationStageSettings );
|
||||
|
||||
$queryInfo = Revision::getQueryInfo( $options );
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
$orig = $this->makeRevisionWithProps();
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
|
||||
$res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
|
||||
__METHOD__, [], $revQuery['joins'] );
|
||||
$this->assertIsObject( $res, 'query failed' );
|
||||
|
|
@ -464,7 +464,7 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$arQuery = Revision::getArchiveQueryInfo();
|
||||
$arQuery = $services->getRevisionStore()->getArchiveQueryInfo();
|
||||
$arQuery['fields'] = $selectModifier( $arQuery['fields'] );
|
||||
$res = $dbr->select(
|
||||
$arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
|
||||
|
|
@ -498,7 +498,9 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$arQuery = Revision::getArchiveQueryInfo();
|
||||
$arQuery = MediaWikiServices::getInstance()
|
||||
->getRevisionStore()
|
||||
->getArchiveQueryInfo();
|
||||
$res = $dbr->select(
|
||||
$arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
|
||||
__METHOD__, [], $arQuery['joins']
|
||||
|
|
@ -841,7 +843,7 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
// test it ---------------------------------
|
||||
$since = $revisions[$sinceIdx]->getTimestamp();
|
||||
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
|
||||
$allRows = iterator_to_array( $dbw->select(
|
||||
$revQuery['tables'],
|
||||
[ 'rev_id', 'rev_timestamp', 'rev_user' => $revQuery['fields']['rev_user'] ],
|
||||
|
|
@ -1708,7 +1710,7 @@ class RevisionDbTest extends MediaWikiIntegrationTestCase {
|
|||
public function testGetRevisionText() {
|
||||
$rev = $this->testPage->getRevisionRecord();
|
||||
|
||||
$queryInfo = Revision::getQueryInfo();
|
||||
$queryInfo = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
|
||||
|
||||
$conds = [ 'rev_id' => $rev->getId() ];
|
||||
$row = $this->db->selectRow(
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ EOF
|
|||
$importer->doImport();
|
||||
|
||||
$db = wfGetDB( DB_MASTER );
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
|
||||
|
||||
$row = $db->selectRow(
|
||||
$revQuery['tables'],
|
||||
|
|
|
|||
|
|
@ -119,9 +119,11 @@ class PageArchiveTest extends MediaWikiTestCase {
|
|||
// TODO: Replace deprecated PageArchive::undelete with ::undeleteAsUser
|
||||
$this->hideDeprecated( 'PageArchive::undelete' );
|
||||
|
||||
$revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
|
||||
|
||||
// First make sure old revisions are archived
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$arQuery = Revision::getArchiveQueryInfo();
|
||||
$arQuery = $revisionStore->getArchiveQueryInfo();
|
||||
$row = $dbr->selectRow(
|
||||
$arQuery['tables'],
|
||||
$arQuery['fields'],
|
||||
|
|
@ -144,7 +146,7 @@ class PageArchiveTest extends MediaWikiTestCase {
|
|||
$this->archivedPage->undelete( [] );
|
||||
|
||||
// Should be back in revision
|
||||
$revQuery = Revision::getQueryInfo();
|
||||
$revQuery = $revisionStore->getQueryInfo();
|
||||
$row = $dbr->selectRow(
|
||||
$revQuery['tables'],
|
||||
$revQuery['fields'],
|
||||
|
|
|
|||
Loading…
Reference in a new issue