Database: Generalise SQL before writing to debug log
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 1 Jul 2014 19:38:53 +0000 (21:38 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 1 Jul 2014 19:38:53 +0000 (21:38 +0200)
The log often contains stuff like the following, where the trimmed
snippet can span many many lines:

* DatabaseBase::query: Writes done: INSERT IGNORE INTO `msg_resource`
   (mr_lang,mr_resource,mr_blob,mr_timestamp) VALUES ('۶?2x?ptt?`0<snip>?`0??O?')
* DatabaseBase::query: Writes done: REPLACE INTO `objectcache`
   (keyname,value,exptime) VALUES ('۶?2x?ptt?`0<snip>?`0??O ?`???`0??O ?`???`0?')

Bug: 67382
Change-Id: I76ca042f166fed56d86df15f788702384d48064c

includes/db/Database.php

index 699ab71..7d8fbe9 100644 (file)
@@ -1022,7 +1022,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                $this->mLastQuery = $sql;
                if ( !$this->mDoneWrites && $this->isWriteQuery( $sql ) ) {
                        # Set a flag indicating that writes have been done
-                       wfDebug( __METHOD__ . ": Writes done: $sql\n" );
+                       wfDebug( __METHOD__ . ': Writes done: ' . DatabaseBase::generalizeSQL( $sql ) . "\n" );
                        $this->mDoneWrites = true;
                }