Hello Daniel Kinzler, Tim Starling, Legoktm,
I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/383923
to review the following change.
Change subject: Update for deprecation of selectFields() methods
......................................................................
Update for deprecation of selectFields() methods
Various selectFields() methods were deprecated in MediaWiki core change
Idcfd1556. This change adapts the extension to use the replacement
getQueryInfo() methods when available.
Change-Id: I42237e8e29497bbc56606f6ad01de3d525bf8b2a
---
M includes/Sanity/Checker.php
M maintenance/forceSearchIndex.php
2 files changed, 39 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/23/383923/1
diff --git a/includes/Sanity/Checker.php b/includes/Sanity/Checker.php
index 8f8c364..cb907e2 100644
--- a/includes/Sanity/Checker.php
+++ b/includes/Sanity/Checker.php
@@ -303,11 +303,22 @@
}
$dbr = $this->getDB();
$where = 'page_id IN (' . $dbr->makeList( $pageIds ) . ')';
+ if ( is_callable( WikiPage::class, 'getQueryInfo' ) ) {
+ $pageQuery = WikiPage::getQueryInfo();
+ } else {
+ $pageQuery = [
+ 'tables' => [ 'page' ],
+ 'fields' => WikiPage::selectFields(),
+ 'joins' => [],
+ ];
+ }
$res = $dbr->select(
- [ 'page' ],
- WikiPage::selectFields(),
+ $pageQuery['tables'],
+ $pageQuery['fields'],
$where,
- __METHOD__
+ __METHOD__,
+ [],
+ $pageQuery['joins']
);
foreach ( $res as $row ) {
$page = WikiPage::newFromRow( $row );
diff --git a/maintenance/forceSearchIndex.php b/maintenance/forceSearchIndex.php
index 4e151ba..9d0f41e 100644
--- a/maintenance/forceSearchIndex.php
+++ b/maintenance/forceSearchIndex.php
@@ -427,7 +427,10 @@
protected function getIdsIterator() {
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
- $it = new BatchRowIterator( $dbr, 'page', 'page_id',
$this->mBatchSize );
+ $it = new BatchRowIterator(
+ $dbr, self::getPageQueryInfo()['tables'], 'page_id',
$this->mBatchSize
+ );
+ $it->addJoinConditions( self::getPageQueryInfo()['joins'] );
$it->addConditions( [
'page_id in (' . $dbr->makeList( $this->pageIds,
LIST_COMMA ) . ')',
] );
@@ -440,13 +443,13 @@
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
$it = new BatchRowIterator(
$dbr,
- [ 'page', 'revision' ],
+ array_merge( self::getPageQueryInfo()['tables'], [
'revision' ] ),
[ 'rev_timestamp', 'page_id' ],
$this->mBatchSize
);
- $it->addConditions( [
- 'rev_page = page_id',
- 'rev_id = page_latest',
+ $it->addJoinConditions( self::getPageQueryInfo()['joins'] );
+ $it->addJoinConditions( [
+ 'revision' => [ 'JOIN', [ 'rev_page = page_id', 'rev_id
= page_latest' ] ]
] );
$this->attachTimestampConditions( $dbr, $it, 'rev' );
@@ -457,7 +460,10 @@
protected function getUpdatesByIdIterator() {
$dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
- $it = new BatchRowIterator( $dbr, 'page', 'page_id',
$this->mBatchSize );
+ $it = new BatchRowIterator(
+ $dbr, self::getPageQueryInfo()['tables'], 'page_id',
$this->mBatchSize
+ );
+ $it->addJoinConditions( self::getPageQueryInfo()['joins'] );
$fromId = $this->getOption( 'fromId', 0 );
if ( $fromId > 0 ) {
$it->addConditions( [
@@ -490,9 +496,21 @@
}
}
+ private static function getPageQueryInfo() {
+ if ( is_callable( WikiPage::class, 'getQueryInfo' ) ) {
+ return WikiPage::getQueryInfo();
+ }
+
+ return [
+ 'tables' => [ 'page' ],
+ 'fields' => WikiPage::selectFields(),
+ 'joins' => [],
+ ];
+ }
+
private function attachPageConditions( IDatabase $dbr, BatchRowIterator
$it, $columnPrefix ) {
if ( $columnPrefix === 'page' ) {
- $it->setFetchColumns( WikiPage::selectFields() );
+ $it->setFetchColumns(
self::getPageQueryInfo()['fields'] );
}
if ( $this->namespace ) {
$it->addConditions( [
--
To view, visit https://gerrit.wikimedia.org/r/383923
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42237e8e29497bbc56606f6ad01de3d525bf8b2a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits