From 218e8311d578edfa04493cfde54f1850cd4cd6e3 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 27 Feb 2018 19:37:26 +0100 Subject: [PATCH 1/1] Pass '' instead of false for the $conds parameter in select calls. Per documentation on IDatabase, $conds must be a string or an array. Passing false for conds is confusing, since it's unclear whether this should match everything or nothing. Bug: T188314 Change-Id: I8be1ac4cbdaafc41aadc2a658be8a99b754b0268 --- includes/installer/DatabaseUpdater.php | 2 +- includes/specials/SpecialRecentchanges.php | 2 +- includes/specials/pagers/ContribsPager.php | 2 +- includes/specials/pagers/NewFilesPager.php | 2 +- maintenance/archives/upgradeLogging.php | 6 +++--- maintenance/clearInterwikiCache.php | 2 +- maintenance/migrateActors.php | 2 +- maintenance/populateBacklinkNamespace.php | 4 ++-- maintenance/populateFilearchiveSha1.php | 2 +- maintenance/populateIpChanges.php | 2 +- maintenance/populateLogSearch.php | 4 ++-- maintenance/populateLogUsertext.php | 4 ++-- maintenance/populateParentId.php | 4 ++-- maintenance/populateRecentChangesSource.php | 4 ++-- maintenance/populateRevisionLength.php | 4 ++-- maintenance/populateRevisionSha1.php | 4 ++-- maintenance/rebuildFileCache.php | 4 ++-- maintenance/refreshLinks.php | 4 ++-- maintenance/storage/checkStorage.php | 2 +- maintenance/storage/fixT22757.php | 2 +- maintenance/storage/moveToExternal.php | 2 +- maintenance/storage/orphanStats.php | 2 +- maintenance/storage/resolveStubs.php | 2 +- maintenance/storage/storageTypeStats.php | 2 +- maintenance/storage/trackBlobs.php | 6 +++--- maintenance/updateRestrictions.php | 4 ++-- 26 files changed, 40 insertions(+), 40 deletions(-) diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 500bc5af59..79ea4f8465 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -1047,7 +1047,7 @@ abstract class DatabaseUpdater { * Sets the number of active users in the site_stats table */ protected function doActiveUsersInit() { - $activeUsers = $this->db->selectField( 'site_stats', 'ss_active_users', false, __METHOD__ ); + $activeUsers = $this->db->selectField( 'site_stats', 'ss_active_users', '', __METHOD__ ); if ( $activeUsers == -1 ) { $activeUsers = $this->db->selectField( 'recentchanges', 'COUNT( DISTINCT rc_user_text )', diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 4abdebf8b5..d6d4c2723f 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -686,7 +686,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { */ public function checkLastModified() { $dbr = $this->getDB(); - $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ ); + $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ ); return $lastmod; } diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index 6fdf05fbae..cd0499551d 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -185,7 +185,7 @@ class ContribsPager extends RangeChronologicalPager { ]; if ( $this->contribs == 'newbie' ) { - $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ ); + $max = $this->mDb->selectField( 'user', 'max(user_id)', '', __METHOD__ ); $queryInfo['conds'][] = $revQuery['fields']['rev_user'] . ' >' . (int)( $max - $max / 100 ); # ignore local groups with the bot right # @todo FIXME: Global groups may have 'bot' rights diff --git a/includes/specials/pagers/NewFilesPager.php b/includes/specials/pagers/NewFilesPager.php index 4815189187..e764e8bc64 100644 --- a/includes/specials/pagers/NewFilesPager.php +++ b/includes/specials/pagers/NewFilesPager.php @@ -75,7 +75,7 @@ class NewFilesPager extends RangeChronologicalPager { if ( $opts->getValue( 'newbies' ) ) { // newbie = most recent 1% of users $dbr = wfGetDB( DB_REPLICA ); - $max = $dbr->selectField( 'user', 'max(user_id)', false, __METHOD__ ); + $max = $dbr->selectField( 'user', 'max(user_id)', '', __METHOD__ ); $conds[] = $imgQuery['fields']['img_user'] . ' >' . (int)( $max - $max / 100 ); // there's no point in looking for new user activity in a far past; diff --git a/maintenance/archives/upgradeLogging.php b/maintenance/archives/upgradeLogging.php index 13362e09ae..bcf70230e5 100644 --- a/maintenance/archives/upgradeLogging.php +++ b/maintenance/archives/upgradeLogging.php @@ -132,13 +132,13 @@ EOT; */ function sync( $srcTable, $dstTable ) { $batchSize = 1000; - $minTs = $this->dbw->selectField( $srcTable, 'MIN(log_timestamp)', false, __METHOD__ ); + $minTs = $this->dbw->selectField( $srcTable, 'MIN(log_timestamp)', '', __METHOD__ ); $minTsUnix = wfTimestamp( TS_UNIX, $minTs ); $numRowsCopied = 0; while ( true ) { - $maxTs = $this->dbw->selectField( $srcTable, 'MAX(log_timestamp)', false, __METHOD__ ); - $copyPos = $this->dbw->selectField( $dstTable, 'MAX(log_timestamp)', false, __METHOD__ ); + $maxTs = $this->dbw->selectField( $srcTable, 'MAX(log_timestamp)', '', __METHOD__ ); + $copyPos = $this->dbw->selectField( $dstTable, 'MAX(log_timestamp)', '', __METHOD__ ); $maxTsUnix = wfTimestamp( TS_UNIX, $maxTs ); $copyPosUnix = wfTimestamp( TS_UNIX, $copyPos ); diff --git a/maintenance/clearInterwikiCache.php b/maintenance/clearInterwikiCache.php index 2e1f7c98a9..8579f0f48a 100644 --- a/maintenance/clearInterwikiCache.php +++ b/maintenance/clearInterwikiCache.php @@ -38,7 +38,7 @@ class ClearInterwikiCache extends Maintenance { public function execute() { global $wgLocalDatabases, $wgMemc; $dbr = $this->getDB( DB_REPLICA ); - $res = $dbr->select( 'interwiki', [ 'iw_prefix' ], false ); + $res = $dbr->select( 'interwiki', [ 'iw_prefix' ], '', __METHOD__ ); $prefixes = []; foreach ( $res as $row ) { $prefixes[] = $row->iw_prefix; diff --git a/maintenance/migrateActors.php b/maintenance/migrateActors.php index 5b144fc347..edd5dda002 100644 --- a/maintenance/migrateActors.php +++ b/maintenance/migrateActors.php @@ -55,7 +55,7 @@ class MigrateActors extends LoggedUpdateMaintenance { $this->output( "Creating actor entries for all registered users\n" ); $end = 0; $dbw = $this->getDB( DB_MASTER ); - $max = $dbw->selectField( 'user', 'MAX(user_id)', false, __METHOD__ ); + $max = $dbw->selectField( 'user', 'MAX(user_id)', '', __METHOD__ ); $count = 0; while ( $end < $max ) { $start = $end + 1; diff --git a/maintenance/populateBacklinkNamespace.php b/maintenance/populateBacklinkNamespace.php index 23144e9520..e2fd8b5a58 100644 --- a/maintenance/populateBacklinkNamespace.php +++ b/maintenance/populateBacklinkNamespace.php @@ -52,13 +52,13 @@ class PopulateBacklinkNamespace extends LoggedUpdateMaintenance { $start = $this->getOption( 'lastUpdatedId' ); if ( !$start ) { - $start = $db->selectField( 'page', 'MIN(page_id)', false, __METHOD__ ); + $start = $db->selectField( 'page', 'MIN(page_id)', '', __METHOD__ ); } if ( !$start ) { $this->output( "Nothing to do." ); return false; } - $end = $db->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); + $end = $db->selectField( 'page', 'MAX(page_id)', '', __METHOD__ ); $batchSize = $this->getBatchSize(); # Do remaining chunk diff --git a/maintenance/populateFilearchiveSha1.php b/maintenance/populateFilearchiveSha1.php index 7c094be5fe..ef57640b10 100644 --- a/maintenance/populateFilearchiveSha1.php +++ b/maintenance/populateFilearchiveSha1.php @@ -56,7 +56,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance { } $this->output( "Populating fa_sha1 field from fa_storage_key\n" ); - $endId = $dbw->selectField( $table, 'MAX(fa_id)', false, __METHOD__ ); + $endId = $dbw->selectField( $table, 'MAX(fa_id)', '', __METHOD__ ); $batchSize = $this->getBatchSize(); $done = 0; diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index 7bb1605cc0..6e88dfaeac 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -75,7 +75,7 @@ TEXT $start = $this->getOption( 'rev-id', 0 ); $end = $maxRevId > 0 ? $maxRevId - : $dbw->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); + : $dbw->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ ); if ( empty( $end ) ) { $this->output( "No revisions found, aborting.\n" ); diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 332d7c5a33..589be48fa7 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -62,13 +62,13 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { return false; } - $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ ); + $start = $db->selectField( 'logging', 'MIN(log_id)', '', __FUNCTION__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); return true; } - $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ ); + $end = $db->selectField( 'logging', 'MAX(log_id)', '', __FUNCTION__ ); # Do remaining chunk $end += $batchSize - 1; diff --git a/maintenance/populateLogUsertext.php b/maintenance/populateLogUsertext.php index cacd067f3e..3c0bba97c1 100644 --- a/maintenance/populateLogUsertext.php +++ b/maintenance/populateLogUsertext.php @@ -50,13 +50,13 @@ class PopulateLogUsertext extends LoggedUpdateMaintenance { protected function doDBUpdates() { $batchSize = $this->getBatchSize(); $db = $this->getDB( DB_MASTER ); - $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__ ); + $start = $db->selectField( 'logging', 'MIN(log_id)', '', __METHOD__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); return true; } - $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__ ); + $end = $db->selectField( 'logging', 'MAX(log_id)', '', __METHOD__ ); // If this is being run during an upgrade from 1.16 or earlier, this // will be run before the actor table change and should continue. But diff --git a/maintenance/populateParentId.php b/maintenance/populateParentId.php index 39bc733161..2ef58b7c61 100644 --- a/maintenance/populateParentId.php +++ b/maintenance/populateParentId.php @@ -54,8 +54,8 @@ class PopulateParentId extends LoggedUpdateMaintenance { return false; } $this->output( "Populating rev_parent_id column\n" ); - $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ ); - $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ ); + $start = $db->selectField( 'revision', 'MIN(rev_id)', '', __FUNCTION__ ); + $end = $db->selectField( 'revision', 'MAX(rev_id)', '', __FUNCTION__ ); if ( is_null( $start ) || is_null( $end ) ) { $this->output( "...revision table seems to be empty, nothing to do.\n" ); diff --git a/maintenance/populateRecentChangesSource.php b/maintenance/populateRecentChangesSource.php index 4ac348672b..8a56d7d875 100644 --- a/maintenance/populateRecentChangesSource.php +++ b/maintenance/populateRecentChangesSource.php @@ -46,13 +46,13 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { $this->error( 'rc_source field in recentchanges table does not exist.' ); } - $start = $dbw->selectField( 'recentchanges', 'MIN(rc_id)', false, __METHOD__ ); + $start = $dbw->selectField( 'recentchanges', 'MIN(rc_id)', '', __METHOD__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); return true; } - $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', false, __METHOD__ ); + $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', '', __METHOD__ ); $end += $batchSize - 1; $blockStart = $start; $blockEnd = $start + $batchSize - 1; diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index bcc499947f..8895c9f4f7 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -76,8 +76,8 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); $batchSize = $this->getBatchSize(); - $start = $dbw->selectField( $table, "MIN($idCol)", false, __METHOD__ ); - $end = $dbw->selectField( $table, "MAX($idCol)", false, __METHOD__ ); + $start = $dbw->selectField( $table, "MIN($idCol)", '', __METHOD__ ); + $end = $dbw->selectField( $table, "MAX($idCol)", '', __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php index d2372a94a5..9662044acc 100644 --- a/maintenance/populateRevisionSha1.php +++ b/maintenance/populateRevisionSha1.php @@ -78,8 +78,8 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { protected function doSha1Updates( $table, $idCol, $queryInfo, $prefix ) { $db = $this->getDB( DB_MASTER ); $batchSize = $this->getBatchSize(); - $start = $db->selectField( $table, "MIN($idCol)", false, __METHOD__ ); - $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); + $start = $db->selectField( $table, "MIN($idCol)", '', __METHOD__ ); + $end = $db->selectField( $table, "MAX($idCol)", '', __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index ae6a75e5bc..ecdec29a95 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -82,10 +82,10 @@ class RebuildFileCache extends Maintenance { $overwrite = $this->hasOption( 'overwrite' ); $start = ( $start > 0 ) ? $start - : $dbr->selectField( 'page', 'MIN(page_id)', false, __METHOD__ ); + : $dbr->selectField( 'page', 'MIN(page_id)', '', __METHOD__ ); $end = ( $end > 0 ) ? $end - : $dbr->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); + : $dbr->selectField( 'page', 'MAX(page_id)', '', __METHOD__ ); if ( !$start ) { $this->fatalError( "Nothing to do." ); } diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index 9d5d39fd8e..49f1cd12f6 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -170,8 +170,8 @@ class RefreshLinks extends Maintenance { } } else { if ( !$end ) { - $maxPage = $dbr->selectField( 'page', 'max(page_id)', false ); - $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', false ); + $maxPage = $dbr->selectField( 'page', 'max(page_id)', '', __METHOD__ ); + $maxRD = $dbr->selectField( 'redirect', 'max(rd_from)', '', __METHOD__ ); $end = max( $maxPage, $maxRD ); } $this->output( "Refreshing redirects table.\n" ); diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index 8f55b88215..bd0556aa7c 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -65,7 +65,7 @@ class CheckStorage { } else { print "Checking...\n"; } - $maxRevId = $dbr->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); + $maxRevId = $dbr->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ ); $chunkSize = 1000; $flagStats = []; $objectStats = []; diff --git a/maintenance/storage/fixT22757.php b/maintenance/storage/fixT22757.php index da3ada7fa1..6bc2f988b8 100644 --- a/maintenance/storage/fixT22757.php +++ b/maintenance/storage/fixT22757.php @@ -55,7 +55,7 @@ class FixT22757 extends Maintenance { $numFixed = 0; $numBad = 0; - $totalRevs = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ ); + $totalRevs = $dbr->selectField( 'text', 'MAX(old_id)', '', __METHOD__ ); // In MySQL 4.1+, the binary field old_text has a non-working LOWER() function $lowerLeft = 'LOWER(CONVERT(LEFT(old_text,22) USING latin1))'; diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php index e1179920ca..9bb554c64c 100644 --- a/maintenance/storage/moveToExternal.php +++ b/maintenance/storage/moveToExternal.php @@ -41,7 +41,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { if ( isset( $options['e'] ) ) { $maxID = $options['e']; } else { - $maxID = $dbw->selectField( 'text', 'MAX(old_id)', false, $fname ); + $maxID = $dbw->selectField( 'text', 'MAX(old_id)', '', $fname ); } $minID = isset( $options['s'] ) ? $options['s'] : 1; diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index 4feb95e05c..9c1b53875e 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -47,7 +47,7 @@ class OrphanStats extends Maintenance { if ( !$dbr->tableExists( 'blob_orphans' ) ) { $this->fatalError( "blob_orphans doesn't seem to exist, need to run trackBlobs.php first" ); } - $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__ ); + $res = $dbr->select( 'blob_orphans', '*', '', __METHOD__ ); $num = 0; $totalSize = 0; diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php index 8ca8bb291b..f9ec39879d 100644 --- a/maintenance/storage/resolveStubs.php +++ b/maintenance/storage/resolveStubs.php @@ -38,7 +38,7 @@ function resolveStubs() { $fname = 'resolveStubs'; $dbr = wfGetDB( DB_REPLICA ); - $maxID = $dbr->selectField( 'text', 'MAX(old_id)', false, $fname ); + $maxID = $dbr->selectField( 'text', 'MAX(old_id)', '', $fname ); $blockSize = 10000; $numBlocks = intval( $maxID / $blockSize ) + 1; diff --git a/maintenance/storage/storageTypeStats.php b/maintenance/storage/storageTypeStats.php index 6dee1a5c83..9ba3d1b9a7 100644 --- a/maintenance/storage/storageTypeStats.php +++ b/maintenance/storage/storageTypeStats.php @@ -25,7 +25,7 @@ class StorageTypeStats extends Maintenance { function execute() { $dbr = $this->getDB( DB_REPLICA ); - $endId = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ ); + $endId = $dbr->selectField( 'text', 'MAX(old_id)', '', __METHOD__ ); if ( !$endId ) { echo "No text rows!\n"; exit( 1 ); diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index b4514ecbdf..ae6d2ff6a5 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -153,7 +153,7 @@ class TrackBlobs { $textClause = $this->getTextClause(); $startId = 0; - $endId = $dbr->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); + $endId = $dbr->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ ); $batchesDone = 0; $rowsInserted = 0; @@ -229,7 +229,7 @@ class TrackBlobs { $textClause = $this->getTextClause( $this->clusters ); $startId = 0; - $endId = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ ); + $endId = $dbr->selectField( 'text', 'MAX(old_id)', '', __METHOD__ ); $rowsInserted = 0; $batchesDone = 0; @@ -339,7 +339,7 @@ class TrackBlobs { $startId = 0; $batchesDone = 0; $actualBlobs = gmp_init( 0 ); - $endId = $extDB->selectField( $table, 'MAX(blob_id)', false, __METHOD__ ); + $endId = $extDB->selectField( $table, 'MAX(blob_id)', '', __METHOD__ ); // Build a bitmap of actual blob rows while ( true ) { diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index cb40af34c5..668ba790fa 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -46,11 +46,11 @@ class UpdateRestrictions extends Maintenance { $this->fatalError( "page_restrictions table does not exist" ); } - $start = $db->selectField( 'page', 'MIN(page_id)', false, __METHOD__ ); + $start = $db->selectField( 'page', 'MIN(page_id)', '', __METHOD__ ); if ( !$start ) { $this->fatalError( "Nothing to do." ); } - $end = $db->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); + $end = $db->selectField( 'page', 'MAX(page_id)', '', __METHOD__ ); # Do remaining chunk $end += $batchSize - 1; -- 2.20.1