Merge "Add class around diff-empty and add it as notice"
[lhc/web/wiklou.git] / includes / db / Database.php
index 623010f..27e6dad 100644 (file)
@@ -882,22 +882,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
         *     for a successful read query, or false on failure if $tempIgnore set
         */
        public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
-               $isMaster = !is_null( $this->getLBInfo( 'master' ) );
-               if ( !Profiler::instance()->isStub() ) {
-                       # generalizeSQL will probably cut down the query to reasonable
-                       # logging size most of the time. The substr is really just a sanity check.
-
-                       if ( $isMaster ) {
-                               $queryProf = 'query-m: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
-                               $totalProf = 'DatabaseBase::query-master';
-                       } else {
-                               $queryProf = 'query: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
-                               $totalProf = 'DatabaseBase::query';
-                       }
-
-                       wfProfileIn( $totalProf );
-                       wfProfileIn( $queryProf );
-               }
+               global $wgUser, $wgDebugDBTransactions;
 
                $this->mLastQuery = $sql;
                if ( !$this->mDoneWrites && $this->isWriteQuery( $sql ) ) {
@@ -907,7 +892,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                }
 
                # Add a comment for easy SHOW PROCESSLIST interpretation
-               global $wgUser;
                if ( is_object( $wgUser ) && $wgUser->isItemLoaded( 'name' ) ) {
                        $userName = $wgUser->getName();
                        if ( mb_strlen( $userName ) > 15 ) {
@@ -931,7 +915,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        # is really used by application
                        $sqlstart = substr( $sql, 0, 10 ); // very much worth it, benchmark certified(tm)
                        if ( strpos( $sqlstart, "SHOW " ) !== 0 && strpos( $sqlstart, "SET " ) !== 0 ) {
-                               global $wgDebugDBTransactions;
                                if ( $wgDebugDBTransactions ) {
                                        wfDebug( "Implicit transaction start.\n" );
                                }
@@ -946,6 +929,21 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname );
                }
 
+               $isMaster = !is_null( $this->getLBInfo( 'master' ) );
+               if ( !Profiler::instance()->isStub() ) {
+                       # generalizeSQL will probably cut down the query to reasonable
+                       # logging size most of the time. The substr is really just a sanity check.
+                       if ( $isMaster ) {
+                               $queryProf = 'query-m: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
+                               $totalProf = 'DatabaseBase::query-master';
+                       } else {
+                               $queryProf = 'query: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
+                               $totalProf = 'DatabaseBase::query';
+                       }
+                       wfProfileIn( $totalProf );
+                       wfProfileIn( $queryProf );
+               }
+
                if ( $this->debug() ) {
                        static $cnt = 0;
 
@@ -1607,7 +1605,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                $sql = preg_replace( '/\s+/', ' ', $sql );
 
                # All numbers => N
-               $sql = preg_replace( '/-?[0-9]+/s', 'N', $sql );
+               $sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
+               $sql = preg_replace( '/-?\d+/s', 'N', $sql );
 
                return $sql;
        }