aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Dziewoński <matma.rex@gmail.com>2023-10-22 00:01:51 +0200
committerBartosz Dziewoński <matma.rex@gmail.com>2023-10-22 01:05:47 +0200
commit978d739bc6269415b9e561fd2c7e5c6260af54d5 (patch)
tree1d9831399f6601925385162e372fae343be270aa
parent373122c4f3eaf1083590b0b4e35db8c85bd9f5b6 (diff)
downloadmediawikicore-978d739bc6269415b9e561fd2c7e5c6260af54d5.tar.gz
mediawikicore-978d739bc6269415b9e561fd2c7e5c6260af54d5.zip
Replace single-value $db->buildComparison() with $db->expr()
Find: ->buildComparison\( ('..?'), \[(\s*)([^\],]+) => ([^\],]+)(\s*)\] \) Replace with: ->expr($2$3, $1, $4$5) Change-Id: I2cfc3070c2a08fc3888ad48a995f7d79198cc336
-rw-r--r--includes/Category/Category.php2
-rw-r--r--includes/ExternalLinks/LinkFilter.php4
-rw-r--r--includes/api/ApiQueryAllUsers.php2
-rw-r--r--includes/api/ApiQueryRandom.php2
-rw-r--r--includes/block/DatabaseBlockStore.php4
-rw-r--r--includes/cache/BacklinkCache.php4
-rw-r--r--includes/jobqueue/JobQueueDB.php4
-rw-r--r--includes/jobqueue/jobs/CategoryMembershipChangeJob.php2
-rw-r--r--includes/jobqueue/jobs/ClearUserWatchlistJob.php2
-rw-r--r--includes/jobqueue/jobs/HTMLCacheUpdateJob.php2
-rw-r--r--includes/jobqueue/jobs/RecentChangesUpdateJob.php8
-rw-r--r--includes/jobqueue/utils/PurgeJobUtils.php4
-rw-r--r--includes/objectcache/SqlBagOStuff.php2
-rw-r--r--includes/pager/RangeChronologicalPager.php2
-rw-r--r--includes/pager/ReverseChronologicalPager.php2
-rw-r--r--includes/title/Title.php4
-rw-r--r--includes/user/UserFactory.php2
-rw-r--r--maintenance/migrateRevisionCommentTemp.php2
-rw-r--r--maintenance/purgeChangedFiles.php4
19 files changed, 29 insertions, 29 deletions
diff --git a/includes/Category/Category.php b/includes/Category/Category.php
index 6760490676c9..294f277ede18 100644
--- a/includes/Category/Category.php
+++ b/includes/Category/Category.php
@@ -337,7 +337,7 @@ class Category {
}
if ( $offset !== '' ) {
- $queryBuilder->andWhere( $dbr->buildComparison( '>', [ 'cl_sortkey' => $offset ] ) );
+ $queryBuilder->andWhere( $dbr->expr( 'cl_sortkey', '>', $offset ) );
}
$result = new TitleArrayFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() );
diff --git a/includes/ExternalLinks/LinkFilter.php b/includes/ExternalLinks/LinkFilter.php
index 8b887e7a6bc6..9fb518f9f093 100644
--- a/includes/ExternalLinks/LinkFilter.php
+++ b/includes/ExternalLinks/LinkFilter.php
@@ -365,8 +365,8 @@ class LinkFilter {
}
foreach ( $domainGaps[$index1] ?? [] as $from => $to ) {
$thisDomainConditions[] = $db->makeList( [
- $db->buildComparison( '<', [ 'el_id' => $from ] ),
- $db->buildComparison( '>', [ 'el_id' => $to ] ),
+ $db->expr( 'el_id', '<', $from ),
+ $db->expr( 'el_id', '>', $to ),
], ISQLPlatform::LIST_OR );
}
$domainConditions[] = $db->makeList( $thisDomainConditions, ISQLPlatform::LIST_AND );
diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php
index 26a4c6ec3331..2fc02730c302 100644
--- a/includes/api/ApiQueryAllUsers.php
+++ b/includes/api/ApiQueryAllUsers.php
@@ -221,7 +221,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
'actor_user = user_id',
'rc_type != ' . $db->addQuotes( RC_EXTERNAL ), // no wikidata
'rc_log_type IS NULL OR rc_log_type != ' . $db->addQuotes( 'newusers' ),
- $db->buildComparison( '>=', [ 'rc_timestamp' => $timestamp ] ),
+ $db->expr( 'rc_timestamp', '>=', $timestamp ),
] );
$this->addFields( [
'recentactions' => '(' . $subqueryBuilder->caller( __METHOD__ )->getSQL() . ')'
diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php
index f183bf82125f..b9d6a8c90964 100644
--- a/includes/api/ApiQueryRandom.php
+++ b/includes/api/ApiQueryRandom.php
@@ -92,7 +92,7 @@ class ApiQueryRandom extends ApiQueryGeneratorBase {
}
}
if ( $end !== null ) {
- $this->addWhere( $this->getDB()->buildComparison( '<', [ 'page_random' => $end ] ) );
+ $this->addWhere( $this->getDB()->expr( 'page_random', '<', $end ) );
}
$this->addOption( 'ORDER BY', [ 'page_random', 'page_id' ] );
diff --git a/includes/block/DatabaseBlockStore.php b/includes/block/DatabaseBlockStore.php
index 49cf249359f1..64bd4f23d794 100644
--- a/includes/block/DatabaseBlockStore.php
+++ b/includes/block/DatabaseBlockStore.php
@@ -143,7 +143,7 @@ class DatabaseBlockStore {
$ids = $dbw->newSelectQueryBuilder()
->select( 'ipb_id' )
->from( 'ipblocks' )
- ->where( $dbw->buildComparison( '<', [ 'ipb_expiry' => $dbw->timestamp() ] ) )
+ ->where( $dbw->expr( 'ipb_expiry', '<', $dbw->timestamp() ) )
// Set a limit to avoid causing replication lag (T301742)
->limit( $limit )
->caller( $fname )->fetchFieldValues();
@@ -245,7 +245,7 @@ class DatabaseBlockStore {
->select( 'ipb_id' )
->from( 'ipblocks' )
->where( [ 'ipb_address' => $row['ipb_address'], 'ipb_user' => $row['ipb_user'] ] )
- ->andWhere( $dbw->buildComparison( '<', [ 'ipb_expiry' => $dbw->timestamp() ] ) )
+ ->andWhere( $dbw->expr( 'ipb_expiry', '<', $dbw->timestamp() ) )
->caller( __METHOD__ )->fetchFieldValues();
if ( $ids ) {
$ids = array_map( 'intval', $ids );
diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php
index 9e7c31a46a9c..6b07ba3fa0c3 100644
--- a/includes/cache/BacklinkCache.php
+++ b/includes/cache/BacklinkCache.php
@@ -187,12 +187,12 @@ class BacklinkCache {
// because databases are stupid and don't necessarily propagate indexes.
if ( $startId ) {
$queryBuilder->where(
- $this->getDB()->buildComparison( '>=', [ $fromField => $startId ] )
+ $this->getDB()->expr( $fromField, '>=', $startId )
);
}
if ( $endId ) {
$queryBuilder->where(
- $this->getDB()->buildComparison( '<=', [ $fromField => $endId ] )
+ $this->getDB()->expr( $fromField, '<=', $endId )
);
}
$queryBuilder->orderBy( $fromField );
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 5cbb5ba6ccb0..92b23aac402b 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -183,7 +183,7 @@ class JobQueueDB extends JobQueue {
[
'job_cmd' => $this->type,
"job_token != {$dbr->addQuotes( '' )}",
- $dbr->buildComparison( '>=', [ 'job_attempts' => $this->maxTries ] ),
+ $dbr->expr( 'job_attempts', '>=', $this->maxTries ),
]
)
->caller( __METHOD__ )->fetchRowCount();
@@ -771,7 +771,7 @@ class JobQueueDB extends JobQueue {
[
'job_cmd' => $this->type,
"job_token != {$dbw->addQuotes( '' )}", // was acquired
- $dbw->buildComparison( '<', [ 'job_token_timestamp' => $pruneCutoff ] ) // stale
+ $dbw->expr( 'job_token_timestamp', '<', $pruneCutoff ) // stale
]
);
if ( $this->claimTTL > 0 ) { // only prune jobs attempted too many times...
diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
index 7a4835308365..f1f537595be2 100644
--- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
+++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
@@ -134,7 +134,7 @@ class CategoryMembershipChangeJob extends Job {
->select( [ 'rev_timestamp', 'rev_id' ] )
->from( 'revision' )
->where( [ 'rev_page' => $page->getId() ] )
- ->andWhere( $dbr->buildComparison( '>=', [ 'rev_timestamp' => $dbr->timestamp( $cutoffUnix ) ] ) )
+ ->andWhere( $dbr->expr( 'rev_timestamp', '>=', $dbr->timestamp( $cutoffUnix ) ) )
->andWhere( 'EXISTS (' . $subQuery->caller( __METHOD__ )->getSQL() . ')' )
->orderBy( [ 'rev_timestamp', 'rev_id' ], SelectQueryBuilder::SORT_DESC )
->caller( __METHOD__ )->fetchRow();
diff --git a/includes/jobqueue/jobs/ClearUserWatchlistJob.php b/includes/jobqueue/jobs/ClearUserWatchlistJob.php
index 9024cb00beba..92f40de79bf9 100644
--- a/includes/jobqueue/jobs/ClearUserWatchlistJob.php
+++ b/includes/jobqueue/jobs/ClearUserWatchlistJob.php
@@ -70,7 +70,7 @@ class ClearUserWatchlistJob extends Job implements GenericParameterJob {
->select( 'wl_id' )
->from( 'watchlist' )
->where( [ 'wl_user' => $userId ] )
- ->andWhere( $dbr->buildComparison( '<=', [ 'wl_id' => $maxWatchlistId ] ) )
+ ->andWhere( $dbr->expr( 'wl_id', '<=', $maxWatchlistId ) )
->limit( $batchSize )
->caller( __METHOD__ )->fetchFieldValues();
if ( count( $watchlistIds ) == 0 ) {
diff --git a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
index d57cdbc14a39..dd283924120c 100644
--- a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
+++ b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
@@ -151,7 +151,7 @@ class HTMLCacheUpdateJob extends Job {
->update( 'page' )
->set( [ 'page_touched' => $dbw->timestamp( $newTouchedUnix ) ] )
->where( [ 'page_id' => $batch ] )
- ->andWhere( $dbw->buildComparison( '<', [ 'page_touched' => $dbw->timestamp( $casTsUnix ) ] ) )
+ ->andWhere( $dbw->expr( 'page_touched', '<', $dbw->timestamp( $casTsUnix ) ) )
->caller( __METHOD__ )->execute();
if ( count( $batches ) > 1 ) {
$lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
index 8c38d1d662be..46449dd9d1e2 100644
--- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php
+++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
@@ -172,8 +172,8 @@ class RecentChangesUpdateJob extends Job {
'actor_user IS NOT NULL', // actual accounts
'rc_type != ' . $dbw->addQuotes( RC_EXTERNAL ), // no wikidata
'rc_log_type IS NULL OR rc_log_type != ' . $dbw->addQuotes( 'newusers' ),
- $dbw->buildComparison( '>=', [ 'rc_timestamp' => $dbw->timestamp( $sTimestamp ) ] ),
- $dbw->buildComparison( '<=', [ 'rc_timestamp' => $dbw->timestamp( $eTimestamp ) ] ),
+ $dbw->expr( 'rc_timestamp', '>=', $dbw->timestamp( $sTimestamp ) ),
+ $dbw->expr( 'rc_timestamp', '<=', $dbw->timestamp( $eTimestamp ) ),
] )
->groupBy( 'actor_name' )
->orderBy( 'NULL' ) // avoid filesort
@@ -193,7 +193,7 @@ class RecentChangesUpdateJob extends Job {
'qcc_type' => 'activeusers',
'qcc_namespace' => NS_USER,
'qcc_title' => array_map( 'strval', array_keys( $names ) ),
- $dbw->buildComparison( '>=', [ 'qcc_value' => $nowUnix - $days * 86400 ] ),
+ $dbw->expr( 'qcc_value', '>=', $nowUnix - $days * 86400 ),
] )
->caller( __METHOD__ )->fetchResultSet();
// Note: In order for this to be actually consistent, we would need
@@ -241,7 +241,7 @@ class RecentChangesUpdateJob extends Job {
->deleteFrom( 'querycachetwo' )
->where( [
'qcc_type' => 'activeusers',
- $dbw->buildComparison( '<', [ 'qcc_value' => $nowUnix - $days * 86400 ] ) // TS_UNIX
+ $dbw->expr( 'qcc_value', '<', $nowUnix - $days * 86400 ) // TS_UNIX
] )
->caller( __METHOD__ )->execute();
diff --git a/includes/jobqueue/utils/PurgeJobUtils.php b/includes/jobqueue/utils/PurgeJobUtils.php
index 658673bae3b7..76127eb84803 100644
--- a/includes/jobqueue/utils/PurgeJobUtils.php
+++ b/includes/jobqueue/utils/PurgeJobUtils.php
@@ -54,7 +54,7 @@ class PurgeJobUtils {
->from( 'page' )
->where( [ 'page_namespace' => $namespace ] )
->andWhere( [ 'page_title' => $dbkeys ] )
- ->andWhere( $dbw->buildComparison( '<', [ 'page_touched' => $now ] ) )
+ ->andWhere( $dbw->expr( 'page_touched', '<', $now ) )
->caller( $fname )->fetchFieldValues();
if ( !$ids ) {
@@ -70,7 +70,7 @@ class PurgeJobUtils {
->update( 'page' )
->set( [ 'page_touched' => $now ] )
->where( [ 'page_id' => $idBatch ] )
- ->andWhere( $dbw->buildComparison( '<', [ 'page_touched' => $now ] ) ) // handle races
+ ->andWhere( $dbw->expr( 'page_touched', '<', $now ) ) // handle races
->caller( $fname )->execute();
if ( count( $idBatches ) > 1 ) {
$lbFactory->commitAndWaitForReplication( $fname, $ticket );
diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php
index 0650c529a1b0..cb40de92833e 100644
--- a/includes/objectcache/SqlBagOStuff.php
+++ b/includes/objectcache/SqlBagOStuff.php
@@ -1497,7 +1497,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
->deleteFrom( $this->getTableNameByShard( $tableIndex ) )
->where( [
'keyname' => $keys,
- $db->buildComparison( '<', [ 'exptime' => $db->timestamp( $cutoffUnix ) ] ),
+ $db->expr( 'exptime', '<', $db->timestamp( $cutoffUnix ) ),
] )
->caller( __METHOD__ )->execute();
$keysDeletedCount += $db->affectedRows();
diff --git a/includes/pager/RangeChronologicalPager.php b/includes/pager/RangeChronologicalPager.php
index 39c6a78efb90..da320b8d70b4 100644
--- a/includes/pager/RangeChronologicalPager.php
+++ b/includes/pager/RangeChronologicalPager.php
@@ -108,7 +108,7 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager {
);
// End of the range has been added by ReverseChronologicalPager
if ( $this->startOffset ) {
- $conds[] = $this->mDb->buildComparison( '>=', [ $this->getTimestampField() => $this->startOffset ] );
+ $conds[] = $this->mDb->expr( $this->getTimestampField(), '>=', $this->startOffset );
} elseif ( $this->rangeConds ) {
// Keep compatibility with some derived classes, T325034
$conds = array_merge( $conds, $this->rangeConds );
diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php
index e9416048bd0d..abd590b900fe 100644
--- a/includes/pager/ReverseChronologicalPager.php
+++ b/includes/pager/ReverseChronologicalPager.php
@@ -328,7 +328,7 @@ abstract class ReverseChronologicalPager extends IndexPager {
$order
);
if ( $this->endOffset ) {
- $conds[] = $this->mDb->buildComparison( '<', [ $this->getTimestampField() => $this->endOffset ] );
+ $conds[] = $this->mDb->expr( $this->getTimestampField(), '<', $this->endOffset );
}
return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
diff --git a/includes/title/Title.php b/includes/title/Title.php
index 169ada98be6c..6183cc0f1265 100644
--- a/includes/title/Title.php
+++ b/includes/title/Title.php
@@ -2448,7 +2448,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
static function ( IDatabase $dbw, $fname ) {
$dbw->newDeleteQueryBuilder()
->deleteFrom( 'protected_titles' )
- ->where( $dbw->buildComparison( '<', [ 'pt_expiry' => $dbw->timestamp() ] ) )
+ ->where( $dbw->expr( 'pt_expiry', '<', $dbw->timestamp() ) )
->caller( $fname )->execute();
}
) );
@@ -3430,7 +3430,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
->update( 'page' )
->set( [ 'page_touched' => $dbTimestamp ] )
->where( $conds )
- ->andWhere( $dbw->buildComparison( '<', [ 'page_touched' => $dbTimestamp ] ) )
+ ->andWhere( $dbw->expr( 'page_touched', '<', $dbTimestamp ) )
->caller( $fname )->execute();
MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $this );
diff --git a/includes/user/UserFactory.php b/includes/user/UserFactory.php
index fb133e563103..0a0b6cf76451 100644
--- a/includes/user/UserFactory.php
+++ b/includes/user/UserFactory.php
@@ -294,7 +294,7 @@ class UserFactory implements IDBAccessObject, UserRigorOptions {
->select( 'user_id' )
->from( 'user' )
->where( [ 'user_email_token' => md5( $confirmationCode ) ] )
- ->andWhere( $db->buildComparison( '>', [ 'user_email_token_expires' => $db->timestamp() ] ) )
+ ->andWhere( $db->expr( 'user_email_token_expires', '>', $db->timestamp() ) )
->options( $options )
->caller( __METHOD__ )->fetchField();
diff --git a/maintenance/migrateRevisionCommentTemp.php b/maintenance/migrateRevisionCommentTemp.php
index 269b31f92b7a..b419835a6cf1 100644
--- a/maintenance/migrateRevisionCommentTemp.php
+++ b/maintenance/migrateRevisionCommentTemp.php
@@ -95,7 +95,7 @@ class MigrateRevisionCommentTemp extends LoggedUpdateMaintenance {
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression last is not-null when used
$this->output( "... rev_id=$last, updated $updated\n" );
- $conds = [ $dbw->buildComparison( '>', [ 'rev_id' => $last ] ) ];
+ $conds = [ $dbw->expr( 'rev_id', '>', $last ) ];
// Sleep between batches for replication to catch up
$this->waitForReplication();
diff --git a/maintenance/purgeChangedFiles.php b/maintenance/purgeChangedFiles.php
index ea8ef50cdae7..4e877f5ef867 100644
--- a/maintenance/purgeChangedFiles.php
+++ b/maintenance/purgeChangedFiles.php
@@ -150,8 +150,8 @@ class PurgeChangedFiles extends Maintenance {
'log_namespace' => NS_FILE,
'log_type' => $logType,
'log_action' => $logActions,
- $dbr->buildComparison( '>=', [ 'log_timestamp' => $this->startTimestamp ] ),
- $dbr->buildComparison( '<=', [ 'log_timestamp' => $this->endTimestamp ] ),
+ $dbr->expr( 'log_timestamp', '>=', $this->startTimestamp ),
+ $dbr->expr( 'log_timestamp', '<=', $this->endTimestamp ),
] )
->caller( __METHOD__ )->fetchResultSet();