maintenance: Use expression builder instead of raw sql
Bug: T361023 Change-Id: Ieb229d8088cb1ff3f03e44f7ac99eb612f48bc7b
This commit is contained in:
parent
70063937ea
commit
81c6df6a46
15 changed files with 20 additions and 19 deletions
|
|
@ -48,7 +48,7 @@ class CheckUsernames extends Maintenance {
|
|||
$res = $dbr->newSelectQueryBuilder()
|
||||
->select( [ 'user_id', 'user_name' ] )
|
||||
->from( 'user' )
|
||||
->where( 'user_id > ' . $maxUserId )
|
||||
->where( $dbr->expr( 'user_id', '>', $maxUserId ) )
|
||||
->orderBy( 'user_id' )
|
||||
->limit( $this->getBatchSize() )
|
||||
->caller( __METHOD__ )
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class CompareParserCache extends Maintenance {
|
|||
->where( [
|
||||
'page_namespace' => $this->getOption( 'namespace' ),
|
||||
'page_is_redirect' => 0,
|
||||
'page_random >= ' . wfRandom()
|
||||
$dbr->expr( 'page_random', '>=', wfRandom() ),
|
||||
] )
|
||||
->orderBy( 'page_random' )
|
||||
->caller( __METHOD__ )->fetchRow();
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ class FindBadBlobs extends Maintenance {
|
|||
$db = $this->getReplicaDB();
|
||||
$rows = $this->revisionStore->newArchiveSelectQueryBuilder( $db )
|
||||
->joinComment()
|
||||
->where( [ "ar_rev_id > $afterId", "ar_rev_id <= $uptoId" ] )
|
||||
->where( [ $db->expr( 'ar_rev_id', '>', $afterId ), $db->expr( 'ar_rev_id', '<=', $uptoId ) ] )
|
||||
->orderBy( 'ar_rev_id' )
|
||||
->limit( $batchSize )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ ERROR
|
|||
->where( [
|
||||
$dbw->expr( 'user_password', IExpression::NOT_LIKE, new LikeValue( ':null:', $dbw->anyString() ) ),
|
||||
$dbw->expr( 'user_password', '!=', PasswordFactory::newInvalidPassword()->toString() ),
|
||||
'user_password IS NOT NULL',
|
||||
$dbw->expr( 'user_password', '!=', null ),
|
||||
'user_name' => $userBatch,
|
||||
] )
|
||||
->caller( __METHOD__ )->execute();
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class InitEditCount extends Maintenance {
|
|||
->from( 'user' )
|
||||
->leftJoin( 'revision', 'rev', "user_id = actor_rev_user.actor_user" )
|
||||
->join( 'actor', 'actor_rev_user', 'actor_rev_user.actor_id = rev_actor' )
|
||||
->where( "user_id > $min AND user_id <= $max" )
|
||||
->where( $dbr->expr( 'user_id', '>', $min )->and( 'user_id', '<=', $max ) )
|
||||
->groupBy( 'user_id' )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ class InitUserPreference extends Maintenance {
|
|||
$iterator->setFetchColumns( [ 'up_user', 'up_value' ] );
|
||||
$iterator->addConditions( [
|
||||
'up_property' => $source,
|
||||
'up_value IS NOT NULL',
|
||||
'up_value != 0',
|
||||
$dbr->expr( 'up_value', '!=', null ),
|
||||
$dbr->expr( 'up_value', '!=', 0 ),
|
||||
] );
|
||||
$iterator->setCaller( __METHOD__ );
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance {
|
|||
$ids = $dbr->newSelectQueryBuilder()
|
||||
->select( 'ct_id' )
|
||||
->from( 'change_tag' )
|
||||
->where( [ 'ct_tag' => $tagName, 'ct_tag_id' => null, 'ct_id > ' . $lastId ] )
|
||||
->where( [ 'ct_tag' => $tagName, 'ct_tag_id' => null, $dbr->expr( 'ct_id', '>', $lastId ) ] )
|
||||
->orderBy( 'ct_id' )
|
||||
->limit( $this->getBatchSize() )
|
||||
->caller( __METHOD__ )->fetchFieldValues();
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
|
|||
$res = $dbw->newSelectQueryBuilder()
|
||||
->select( [ 'fa_id', 'fa_storage_key' ] )
|
||||
->from( $table )
|
||||
->where( [ 'fa_sha1' => '', 'fa_storage_key IS NOT NULL' ] )
|
||||
->where( [ 'fa_sha1' => '', $dbw->expr( 'fa_storage_key', '!=', null ) ] )
|
||||
->limit( $batchSize )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class PrewarmParsoidParserCache extends Maintenance {
|
|||
if ( $namespaceIndex !== null ) {
|
||||
$query = $query->where( [ 'page_namespace' => $namespaceIndex ] );
|
||||
}
|
||||
$query = $query->where( 'page_id >= ' . $startFrom )
|
||||
$query = $query->where( $this->getReplicaDB()->expr( 'page_id', '>=', $startFrom ) )
|
||||
->limit( $this->getBatchSize() );
|
||||
|
||||
$result = $query->fetchResultSet();
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ TEXT
|
|||
$idsToUpdate = $dbr->newSelectQueryBuilder()
|
||||
->select( 'cat_id' )
|
||||
->from( 'category' )
|
||||
->where( [ 'cat_id > ' . (int)$this->minimumId, "cat_{$mode} != ($countingSubquery)" ] )
|
||||
->where( [ $dbr->expr( 'cat_id', '>', (int)$this->minimumId ), "cat_{$mode} != ($countingSubquery)" ] )
|
||||
->limit( $this->getBatchSize() )
|
||||
->caller( __METHOD__ )->fetchFieldValues();
|
||||
if ( !$idsToUpdate ) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ class RefreshLinks extends Maintenance {
|
|||
} else {
|
||||
if ( $touched ) {
|
||||
$builder->andWhere( [
|
||||
'page_touched > page_links_updated OR page_links_updated IS NULL',
|
||||
$dbr->expr( 'page_touched', '>', 'page_links_updated' )
|
||||
->or( 'page_links_updated', '=', null ),
|
||||
] );
|
||||
}
|
||||
$this->output( "Refreshing $what from pages...\n" );
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ class CompressOld extends Maintenance {
|
|||
|
||||
return false;
|
||||
}
|
||||
$queryBuilderTemplate->andWhere( "rev_timestamp>'" . $beginDate . "'" );
|
||||
$queryBuilderTemplate->andWhere( $dbr->expr( 'rev_timestamp', '>', $beginDate ) );
|
||||
}
|
||||
if ( $endDate ) {
|
||||
if ( !preg_match( '/^\d{14}$/', $endDate ) ) {
|
||||
|
|
@ -310,7 +310,7 @@ class CompressOld extends Maintenance {
|
|||
|
||||
return false;
|
||||
}
|
||||
$queryBuilderTemplate->andWhere( "rev_timestamp<'" . $endDate . "'" );
|
||||
$queryBuilderTemplate->andWhere( $dbr->expr( 'rev_timestamp', '<', $endDate ) );
|
||||
}
|
||||
|
||||
for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) {
|
||||
|
|
@ -343,7 +343,7 @@ class CompressOld extends Maintenance {
|
|||
// Don't operate on the current revision
|
||||
// Use < instead of <> in case the current revision has changed
|
||||
// since the page select, which wasn't locking
|
||||
'rev_timestamp < ' . (int)$pageRow->rev_timestamp
|
||||
$dbr->expr( 'rev_timestamp', '<', (int)$pageRow->rev_timestamp ),
|
||||
] )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ class RecompressTracked {
|
|||
$startId = 0;
|
||||
$conds = array_merge( $conds, [
|
||||
'bt_moved' => 0,
|
||||
'bt_new_url IS NOT NULL'
|
||||
$dbr->expr( 'bt_new_url', '!=', null ),
|
||||
] );
|
||||
while ( true ) {
|
||||
$res = $dbr->newSelectQueryBuilder()
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ SQL;
|
|||
$res = $dbr->newSelectQueryBuilder()
|
||||
->select( [ 'old_flags', 'class' => $classSql, 'count' => 'COUNT(*)' ] )
|
||||
->from( 'text' )
|
||||
->where( [ 'old_id >= ' . intval( $rangeStart ) ] )
|
||||
->andWhere( [ 'old_id < ' . intval( $rangeStart + $binSize ) ] )
|
||||
->where( $dbr->expr( 'old_id', '>=', intval( $rangeStart ) ) )
|
||||
->andWhere( $dbr->expr( 'old_id', '<', intval( $rangeStart + $binSize ) ) )
|
||||
->groupBy( [ 'old_flags', 'class' ] )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class TrackBlobs extends Maintenance {
|
|||
$slotRoleStore = $this->getServiceContainer()->getSlotRoleStore();
|
||||
|
||||
$conds = array_merge( [
|
||||
'slot_role_id=' . $slotRoleStore->getId( SlotRecord::MAIN ),
|
||||
'slot_role_id' => $slotRoleStore->getId( SlotRecord::MAIN ),
|
||||
'SUBSTRING(content_address, 1, 3)=' . $dbr->addQuotes( 'tt:' ),
|
||||
], $conds );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue