Merge "Pass function name to database functions"

This commit is contained in:
jenkins-bot 2020-06-07 16:03:38 +00:00 committed by Gerrit Code Review
commit f46260f4d7
24 changed files with 57 additions and 45 deletions

View file

@ -188,7 +188,7 @@ class Pingback {
private function getOrCreatePingbackId() {
if ( !$this->id ) {
$id = wfGetDB( DB_REPLICA )->selectField(
'updatelog', 'ul_value', [ 'ul_key' => 'PingBack' ] );
'updatelog', 'ul_value', [ 'ul_key' => 'PingBack' ], __METHOD__ );
if ( $id == false ) {
$id = MWCryptRand::generateHex( 32 );
@ -202,7 +202,7 @@ class Pingback {
if ( !$dbw->affectedRows() ) {
$id = $dbw->selectField(
'updatelog', 'ul_value', [ 'ul_key' => 'PingBack' ] );
'updatelog', 'ul_value', [ 'ul_key' => 'PingBack' ], __METHOD__ );
}
}

View file

@ -667,7 +667,8 @@ class RevisionStore
$dbw->onTransactionResolution(
function ( $trigger, IDatabase $dbw ) use ( $fname ) {
$dbw->unlock( 'fix-for-T202032', $fname );
}
},
__METHOD__
);
$dbw->delete( 'revision', [ 'rev_id' => $revisionRow['rev_id'] ], __METHOD__ );
@ -682,12 +683,14 @@ class RevisionStore
// And we have to use raw SQL to bypass the "aggregation used with a locking SELECT" warning
// that's for non-MySQL DBs.
$row1 = $dbw->query(
$dbw->selectSQLText( 'archive', [ 'v' => "MAX(ar_rev_id)" ], '', __METHOD__ ) . ' FOR UPDATE'
$dbw->selectSQLText( 'archive', [ 'v' => "MAX(ar_rev_id)" ], '', __METHOD__ ) . ' FOR UPDATE',
__METHOD__
)->fetchObject();
$row2 = $dbw->query(
$dbw->selectSQLText( 'slots', [ 'v' => "MAX(slot_revision_id)" ], '', __METHOD__ )
. ' FOR UPDATE'
. ' FOR UPDATE',
__METHOD__
)->fetchObject();
$maxRevId = max(

View file

@ -203,7 +203,7 @@ class NameTableStore {
$dbw = $this->getDBConnection( DB_MASTER );
$dbw->onTransactionPreCommitOrIdle( function () {
$this->cache->delete( $this->getCacheKey() );
} );
}, __METHOD__ );
}
$this->tableCache = $table;
}
@ -234,7 +234,7 @@ class NameTableStore {
$this->tableCache = $this->loadTable( $dbw );
$dbw->onTransactionPreCommitOrIdle( function () {
$this->cache->reap( $this->getCacheKey(), INF );
} );
}, __METHOD__ );
return $this->tableCache;
}

View file

@ -398,7 +398,7 @@ class ChangeTags {
[ 'ctd_name' => $tagsToAdd ],
$fname
);
} );
}, $fname );
$tagsRows = [];
foreach ( $tagsToAdd as $tag ) {
@ -449,7 +449,7 @@ class ChangeTags {
[ 'ctd_name' => $tag, 'ctd_count' => 0, 'ctd_user_defined' => 0 ],
$fname
);
} );
}, $fname );
}
}
}

View file

@ -107,7 +107,7 @@ class CloneDatabase {
# Create new table
wfDebug( __METHOD__ . " duplicating $oldTableName to $newTableName" );
$this->db->duplicateTableStructure(
$oldTableName, $newTableName, $this->useTemporaryTables );
$oldTableName, $newTableName, $this->useTemporaryTables, __METHOD__ );
}
}
@ -119,7 +119,7 @@ class CloneDatabase {
if ( $dropTables ) {
$this->db->tablePrefix( $this->newTablePrefix );
foreach ( $this->tablesToClone as $tbl ) {
$this->db->dropTable( $tbl );
$this->db->dropTable( $tbl, __METHOD__ );
}
}
$this->db->tablePrefix( $this->oldTablePrefix );

View file

@ -31,7 +31,7 @@ class MySqlLockManager extends DBLockManager {
protected function initConnection( $lockDb, IDatabase $db ) {
# Let this transaction see lock rows from other transactions
$db->query( "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;" );
$db->query( "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;", __METHOD__ );
# Do everything in a transaction as it all gets rolled back eventually
$db->startAtomic( __CLASS__ );
}

View file

@ -141,7 +141,8 @@ class ForeignDBFile extends LocalFile {
[
'page_namespace' => NS_FILE,
'page_title' => $this->title->getDBkey()
]
],
__METHOD__
);
if ( $touched === false ) {
return false; // no description page
@ -186,7 +187,8 @@ class ForeignDBFile extends LocalFile {
[
'page_namespace' => NS_FILE,
'page_title' => $this->title->getDBkey()
]
],
__METHOD__
);
if ( $pageId !== false ) {

View file

@ -54,7 +54,7 @@ class HistoryBlobCurStub {
*/
public function getText() {
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ] );
$row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ], __METHOD__ );
if ( !$row ) {
return false;
}

View file

@ -87,7 +87,8 @@ class HistoryBlobStub {
$row = $dbr->selectRow(
'text',
[ 'old_flags', 'old_text' ],
[ 'old_id' => $this->mOldId ]
[ 'old_id' => $this->mOldId ],
__METHOD__
);
if ( !$row ) {

View file

@ -533,7 +533,7 @@ class JobQueueDB extends JobQueue {
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = $this->getScopedNoTrxFlag( $dbw );
try {
$dbw->delete( 'job', [ 'job_cmd' => $this->type ] );
$dbw->delete( 'job', [ 'job_cmd' => $this->type ], __METHOD__ );
} catch ( DBError $e ) {
throw $this->getDBException( $e );
}
@ -592,7 +592,7 @@ class JobQueueDB extends JobQueue {
$scope = $this->getScopedNoTrxFlag( $dbr );
try {
return new MappedIterator(
$dbr->select( 'job', self::selectFields(), $conds ),
$dbr->select( 'job', self::selectFields(), $conds, __METHOD__ ),
function ( $row ) {
return $this->jobFromRow( $row );
}

View file

@ -132,7 +132,8 @@ class CategoryMembershipChangeJob extends Job {
[
'rc_this_oldid = rev_id',
'rc_source' => RecentChange::SRC_CATEGORIZE,
]
],
__METHOD__
) . ')'
],
__METHOD__,

View file

@ -141,7 +141,8 @@ class RecentChangesUpdateJob extends Job {
// Get the last-updated timestamp for the cache
$cTime = $dbw->selectField( 'querycache_info',
'qci_timestamp',
[ 'qci_type' => 'activeusers' ]
[ 'qci_type' => 'activeusers' ],
__METHOD__
);
$cTimeUnix = $cTime ? wfTimestamp( TS_UNIX, $cTime ) : 1;

View file

@ -223,7 +223,7 @@ abstract class DBLockManager extends QuorumLockManager {
public function __destruct() {
$this->releaseAllLocks();
foreach ( $this->conns as $db ) {
$db->close();
$db->close( __METHOD__ );
}
}
}

View file

@ -967,7 +967,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
]
) );
// Automatically create the objectcache table for sqlite as needed
if ( $conn->getType() === 'sqlite' && !$conn->tableExists( 'objectcache' ) ) {
if ( $conn->getType() === 'sqlite' && !$conn->tableExists( 'objectcache', __METHOD__ ) ) {
$this->initSqliteDatabase( $conn );
}
$this->conns[$shardIndex] = $conn;
@ -1049,11 +1049,11 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
* @throws DBError
*/
private function initSqliteDatabase( IMaintainableDatabase $db ) {
if ( $db->tableExists( 'objectcache' ) ) {
if ( $db->tableExists( 'objectcache', __METHOD__ ) ) {
return;
}
// Use one table for SQLite; sharding does not seem to have much benefit
$db->query( "PRAGMA journal_mode=WAL" ); // this is permanent
$db->query( "PRAGMA journal_mode=WAL", __METHOD__ ); // this is permanent
$db->startAtomic( __METHOD__ ); // atomic DDL
try {
$encTable = $db->tableName( 'objectcache' );
@ -1066,7 +1066,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
")",
__METHOD__
);
$db->query( "CREATE INDEX $encExptimeIndex ON $encTable (exptime)" );
$db->query( "CREATE INDEX $encExptimeIndex ON $encTable (exptime)", __METHOD__ );
$db->endAtomic( __METHOD__ );
} catch ( DBError $e ) {
$db->rollback( __METHOD__ );
@ -1084,7 +1084,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
for ( $i = 0; $i < $this->numTableShards; $i++ ) {
$encBaseTable = $db->tableName( 'objectcache' );
$encShardTable = $db->tableName( $this->getTableNameByShard( $i ) );
$db->query( "CREATE TABLE $encShardTable LIKE $encBaseTable" );
$db->query( "CREATE TABLE $encShardTable LIKE $encBaseTable", __METHOD__ );
}
}
}

View file

@ -2828,7 +2828,7 @@ class WikiPage implements Page, IDBAccessObject {
continue;
}
if ( $dbw->trxLevel() ) {
$dbw->commit();
$dbw->commit( __METHOD__ );
}
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$lbFactory->waitForReplication();

View file

@ -136,7 +136,7 @@ class SearchPostgres extends SearchDatabase {
# # We need a separate query here so gin does not complain about empty searches
$sql = "SELECT to_tsquery($searchstring)";
$dbr = $this->lb->getConnectionRef( DB_REPLICA );
$res = $dbr->query( $sql );
$res = $dbr->query( $sql, __METHOD__ );
if ( !$res ) {
# # TODO: Better output (example to catch: one 'two)
die( "Sorry, that was not a valid search string. Please go back and try again" );
@ -208,7 +208,7 @@ class SearchPostgres extends SearchDatabase {
" ORDER BY old_rev_text_id DESC OFFSET 1)";
$dbw = $this->lb->getConnectionRef( DB_MASTER );
$dbw->query( $sql );
$dbw->query( $sql, __METHOD__ );
return true;
}

View file

@ -191,10 +191,10 @@ class SearchSqlite extends SearchDatabase {
$filteredTerm =
$this->filter( MediaWikiServices::getInstance()->getContentLanguage()->lc( $term ) );
$dbr = $this->lb->getConnectionRef( DB_REPLICA );
$resultSet = $dbr->query( $this->getQuery( $filteredTerm, $fulltext ) );
$resultSet = $dbr->query( $this->getQuery( $filteredTerm, $fulltext ), __METHOD__ );
$total = null;
$totalResult = $dbr->query( $this->getCountQuery( $filteredTerm, $fulltext ) );
$totalResult = $dbr->query( $this->getCountQuery( $filteredTerm, $fulltext ), __METHOD__ );
$row = $totalResult->fetchObject();
if ( $row ) {
$total = intval( $row->c );

View file

@ -155,7 +155,7 @@ class SpecialActiveUsers extends SpecialPage {
if ( $cTime ) {
$secondsOld = wfTimestamp( TS_UNIX, $rcMax ) - wfTimestamp( TS_UNIX, $cTime );
} else {
$rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)' );
$rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)', '', __METHOD__ );
$secondsOld = time() - wfTimestamp( TS_UNIX, $rcMin );
}
if ( $secondsOld > 0 ) {

View file

@ -168,21 +168,21 @@ class SpecialRandomInCategory extends FormSpecialPage {
$up = false;
}
$row = $this->selectRandomPageFromDB( $rand, $offset, $up );
$row = $this->selectRandomPageFromDB( $rand, $offset, $up, __METHOD__ );
// Try again without the timestamp offset (wrap around the end)
if ( !$row ) {
$row = $this->selectRandomPageFromDB( false, $offset, $up );
$row = $this->selectRandomPageFromDB( false, $offset, $up, __METHOD__ );
}
// Maybe the category is really small and offset too high
if ( !$row ) {
$row = $this->selectRandomPageFromDB( $rand, 0, $up );
$row = $this->selectRandomPageFromDB( $rand, 0, $up, __METHOD__ );
}
// Just get the first entry.
if ( !$row ) {
$row = $this->selectRandomPageFromDB( false, 0, true );
$row = $this->selectRandomPageFromDB( false, 0, true, __METHOD__ );
}
if ( $row ) {

View file

@ -115,7 +115,7 @@ class RandomPage extends SpecialPage {
return $title;
}
$row = $this->selectRandomPageFromDB( $randstr );
$row = $this->selectRandomPageFromDB( $randstr, __METHOD__ );
/* If we picked a value that was higher than any in
* the DB, wrap around and select the page with the
@ -125,7 +125,7 @@ class RandomPage extends SpecialPage {
* causes anyway. Trust me, I'm a mathematician. :)
*/
if ( !$row ) {
$row = $this->selectRandomPageFromDB( "0" );
$row = $this->selectRandomPageFromDB( "0", __METHOD__ );
}
if ( $row ) {

View file

@ -131,7 +131,7 @@ class ActiveUsersPager extends UsersPager {
->userHasRight( $this->getUser(), 'hideuser' )
) {
$conds[] = 'NOT EXISTS (' . $dbr->selectSQLText(
'ipblocks', '1', [ 'ipb_user=user_id', 'ipb_deleted' => 1 ]
'ipblocks', '1', [ 'ipb_user=user_id', 'ipb_deleted' => 1 ], __METHOD__
) . ')';
}
$subquery = $dbr->buildSelectSubquery( $tables, $fields, $conds, $fname, $options, $jconds );

View file

@ -390,7 +390,8 @@ class BlockListPager extends TablePager {
[
'ipb_auto' => '1',
'ipb_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() ),
]
],
__METHOD__
);
if ( $res ) {
return $res;

View file

@ -677,7 +677,8 @@ class User implements IDBAccessObject, UserIdentity {
[
'user_email_token' => md5( $code ),
'user_email_token_expires > ' . $db->addQuotes( $db->timestamp() ),
]
],
__METHOD__
);
return $id ? self::newFromId( $id ) : null;

View file

@ -283,7 +283,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
// First fetch the wl_ids.
$wlIds = $dbw->selectFieldValues( 'watchlist', 'wl_id', [
'wl_user' => $user->getId()
] );
], __METHOD__ );
if ( $wlIds ) {
// Delete rows from both the watchlist and watchlist_expiry tables.
@ -508,7 +508,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
'wl_user' => $user->getId(),
'wl_namespace' => $namespace,
'wl_title' => $toDelete
] );
], __METHOD__ );
if ( $wlIds ) {
// Delete rows from both the watchlist and watchlist_expiry tables.
@ -1099,7 +1099,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
'watchlist_expiry',
$weRows,
'we_item',
[ 'we_expiry' => $expiry ]
[ 'we_expiry' => $expiry ],
__METHOD__
);
return $dbw->affectedRows();
@ -1166,7 +1167,8 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
'wl_user' => $user->getId(),
'wl_namespace' => $namespace,
'wl_title' => $toUpdate
]
],
__METHOD__
);
$affectedSinceWait += $dbw->affectedRows();
// Wait for replication every time we've touched updateRowsPerQuery rows