X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=blobdiff_plain;f=includes%2Fdb%2FDatabase.php;h=9df96f121f00bbb82b3882dc411b8ffd2ab3b989;hb=23650785efd515088e41a12bf4dff70ca3467ccc;hp=cedd624520148086d87a98a657e3b511b01939e4;hpb=99e6b43ab83329e286394b163fa74137344405b3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/Database.php b/includes/db/Database.php index cedd624520..9df96f121f 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -46,9 +46,6 @@ abstract class DatabaseBase implements IDatabase { /** Maximum time to wait before retry */ const DEADLOCK_DELAY_MAX = 1500000; - /** How many row changes in a write query trigger a log entry */ - const LOG_WRITE_THRESHOLD = 300; - protected $mLastQuery = ''; protected $mDoneWrites = false; protected $mPHPError = false; @@ -1160,11 +1157,13 @@ abstract class DatabaseBase implements IDatabase { # Log the query time and feed it into the DB trx profiler if ( $queryProf != '' ) { + $that = $this; $queryStartTime = microtime( true ); $queryProfile = new ScopedCallback( - function () use ( $queryStartTime, $queryProf, $isMaster ) { - $trxProfiler = Profiler::instance()->getTransactionProfiler(); - $trxProfiler->recordQueryCompletion( $queryProf, $queryStartTime, $isMaster ); + function () use ( $that, $queryStartTime, $queryProf, $isMaster ) { + $n = $that->affectedRows(); + $trxProf = Profiler::instance()->getTransactionProfiler(); + $trxProf->recordQueryCompletion( $queryProf, $queryStartTime, $isMaster, $n ); } ); } @@ -1206,13 +1205,6 @@ abstract class DatabaseBase implements IDatabase { if ( false === $ret ) { $this->reportQueryError( $this->lastError(), $this->lastErrno(), $sql, $fname, $tempIgnore ); - } else { - $n = $this->affectedRows(); - if ( $isWriteQuery && $n > self::LOG_WRITE_THRESHOLD && PHP_SAPI !== 'cli' ) { - wfDebugLog( 'DBPerformance', - "Query affected $n rows:\n" . - DatabaseBase::generalizeSQL( $sql ) . "\n" . wfBacktrace( true ) ); - } } $res = $this->resultObject( $ret ); @@ -1867,7 +1859,7 @@ abstract class DatabaseBase implements IDatabase { if ( $res ) { $row = $this->fetchRow( $res ); - $rows = ( isset( $row['rowcount'] ) ) ? $row['rowcount'] : 0; + $rows = ( isset( $row['rowcount'] ) ) ? (int)$row['rowcount'] : 0; } return $rows; @@ -1897,7 +1889,7 @@ abstract class DatabaseBase implements IDatabase { if ( $res ) { $row = $this->fetchRow( $res ); - $rows = ( isset( $row['rowcount'] ) ) ? $row['rowcount'] : 0; + $rows = ( isset( $row['rowcount'] ) ) ? (int)$row['rowcount'] : 0; } return $rows;