rdbms: fix a few IDEA warnings in Database
[lhc/web/wiklou.git] / includes / libs / rdbms / database / Database.php
index d11b51b..cf8d064 100644 (file)
@@ -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()
                );