X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Fdatabase%2FDatabase.php;h=cf8d06461bef740b6407ec247ae19fa5239fdcf0;hb=8053bc9e0dc56d610305065cd1703dc2dfff3775;hp=d11b51b0fd439c7243a7c32fc4e743ce8a1e9245;hpb=c5f5ac85d14671a9baa983949e8acb81d092e802;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index d11b51b0fd..cf8d06461b 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -266,7 +266,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware /** @var int[] Prior flags member variable values */ private $priorFlags = []; - /** @var object|string Class name or object With profileIn/profileOut methods */ + /** @var mixed Class name or object With profileIn/profileOut methods */ protected $profiler; /** @var TransactionProfiler */ protected $trxProfiler; @@ -287,7 +287,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware const STATUS_TRX_NONE = 3; /** - * @note: exceptions for missing libraries/drivers should be thrown in initConnection() + * @note exceptions for missing libraries/drivers should be thrown in initConnection() * @param array $params Parameters passed from Database::factory() */ protected function __construct( array $params ) { @@ -1132,11 +1132,11 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware if ( $this->trxLevel && !$this->trxDoneWrites && $isWrite ) { $this->trxDoneWrites = true; $this->trxProfiler->transactionWritingIn( - $this->server, $this->dbName, $this->trxShortId ); + $this->server, $this->getDomainID(), $this->trxShortId ); } if ( $this->getFlag( self::DBO_DEBUG ) ) { - $this->queryLogger->debug( "{$this->dbName} {$commentedSql}" ); + $this->queryLogger->debug( "{$this->getDomainID()} {$commentedSql}" ); } # Send the query to the server and fetch any corresponding errors @@ -1239,7 +1239,10 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware } $this->trxProfiler->recordQueryCompletion( - $queryProf, $startTime, $isWrite, $this->affectedRows() + $queryProf, + $startTime, + $isWrite, + $isWrite ? $this->affectedRows() : $this->numRows( $ret ) ); $this->queryLogger->debug( $sql, [ 'method' => $fname, @@ -3493,7 +3496,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware list( $phpCallback ) = $callback; $phpCallback( $this ); } catch ( Exception $ex ) { - $this->errorLogger( $ex ); + ( $this->errorLogger )( $ex ); $e = $e ?: $ex; } } @@ -3844,14 +3847,16 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware $this->assertOpen(); $this->runOnTransactionPreCommitCallbacks(); + $writeTime = $this->pendingWriteQueryDuration( self::ESTIMATE_DB_APPLY ); $this->doCommit( $fname ); $this->trxStatus = self::STATUS_TRX_NONE; + if ( $this->trxDoneWrites ) { $this->lastWriteTime = microtime( true ); $this->trxProfiler->transactionWritingOut( $this->server, - $this->dbName, + $this->getDomainID(), $this->trxShortId, $writeTime, $this->trxWriteAffectedRows @@ -3894,14 +3899,18 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware // Avoid fatals if close() was called $this->assertOpen(); + $writeTime = $this->pendingWriteQueryDuration( self::ESTIMATE_DB_APPLY ); $this->doRollback( $fname ); $this->trxStatus = self::STATUS_TRX_NONE; $this->trxAtomicLevels = []; + if ( $this->trxDoneWrites ) { $this->trxProfiler->transactionWritingOut( $this->server, - $this->dbName, - $this->trxShortId + $this->getDomainID(), + $this->trxShortId, + $writeTime, + $this->trxWriteAffectedRows ); } } @@ -4009,7 +4018,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware * a wrapper. Nowadays, raw database objects are never exposed to external * callers, so this is unnecessary in external code. * - * @param bool|ResultWrapper|resource|object $result + * @param bool|ResultWrapper|resource $result * @return bool|ResultWrapper */ protected function resultObject( $result ) { @@ -4581,7 +4590,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware */ public function __clone() { $this->connLogger->warning( - "Cloning " . static::class . " is not recomended; forking connection:\n" . + "Cloning " . static::class . " is not recommended; forking connection:\n" . ( new RuntimeException() )->getTraceAsString() );