Merge "Automatically add a new line at the end of wfLogDBError()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 24 Mar 2014 18:45:47 +0000 (18:45 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 24 Mar 2014 18:45:47 +0000 (18:45 +0000)
1  2 
includes/db/Database.php
includes/db/DatabaseMysqlBase.php

diff --combined includes/db/Database.php
@@@ -1097,6 -1097,7 +1097,6 @@@ abstract class DatabaseBase implements 
                if ( false === $ret && $this->wasErrorReissuable() ) {
                        # Transaction is gone, like it or not
                        $hadTrx = $this->mTrxLevel; // possible lost transaction
 -                      wfDebug( "Connection lost, reconnecting...\n" );
                        $this->mTrxLevel = 0;
                        wfDebug( "Connection lost, reconnecting...\n" );
  
                                $elapsed = round( microtime( true ) - $wgRequestTime, 3 );
                                if ( $elapsed < 300 ) {
                                        # Not a database error to lose a transaction after a minute or two
-                                       wfLogDBError( "Connection lost and reconnected after {$elapsed}s, query: $sqlx\n" );
+                                       wfLogDBError( "Connection lost and reconnected after {$elapsed}s, query: $sqlx" );
                                }
                                if ( !$hadTrx ) {
                                        # Should be safe to silently retry
                        $this->ignoreErrors( $ignore );
                } else {
                        $sql1line = mb_substr( str_replace( "\n", "\\n", $sql ), 0, 5 * 1024 );
-                       wfLogDBError( "$fname\t{$this->mServer}\t$errno\t$error\t$sql1line\n" );
+                       wfLogDBError( "$fname\t{$this->mServer}\t$errno\t$error\t$sql1line" );
                        wfDebug( "SQL ERROR: " . $error . "\n" );
                        throw new DBQueryError( $this, $error, $errno, $sql, $fname );
                }
@@@ -93,7 -93,7 +93,7 @@@ abstract class DatabaseMysqlBase extend
                        if ( !$error ) {
                                $error = $this->lastError();
                        }
-                       wfLogDBError( "Error connecting to {$this->mServer}: $error\n" );
+                       wfLogDBError( "Error connecting to {$this->mServer}: $error" );
                        wfDebug( "DB connection error\n" .
                                "Server: $server, User: $user, Password: " .
                                substr( $password, 0, 3 ) . "..., error: " . $error . "\n" );
                        $success = $this->selectDB( $dbName );
                        wfRestoreWarnings();
                        if ( !$success ) {
-                               wfLogDBError( "Error selecting database $dbName on server {$this->mServer}\n" );
+                               wfLogDBError( "Error selecting database $dbName on server {$this->mServer}" );
                                wfDebug( "Error selecting database $dbName on server {$this->mServer} " .
                                        "from client host " . wfHostname() . "\n" );
  
         * @return string
         */
        public function getSoftwareLink() {
 +              // MariaDB includes its name in its version string (sent when the connection is opened),
 +              // and this is how MariaDB's version of the mysql command-line client identifies MariaDB
 +              // servers (see the mariadb_connection() function in libmysql/libmysql.c).
                $version = $this->getServerVersion();
 -              if ( strpos( $version, 'MariaDB' ) !== false ) {
 +              if ( strpos( $version, 'MariaDB' ) !== false || strpos( $version, '-maria-' ) !== false ) {
                        return '[{{int:version-db-mariadb-url}} MariaDB]';
 -              } elseif ( strpos( $version, 'percona' ) !== false ) {
 -                      return '[{{int:version-db-percona-url}} Percona Server]';
 -              } else {
 -                      return '[{{int:version-db-mysql-url}} MySQL]';
                }
 +
 +              // Percona Server's version suffix is not very distinctive, and @@version_comment
 +              // doesn't give the necessary info for source builds, so assume the server is MySQL.
 +              // (Even Percona's version of mysql doesn't try to make the distinction.)
 +              return '[{{int:version-db-mysql-url}} MySQL]';
        }
  
        /**