Merge "Set autofocus on Special:Unblock"
[lhc/web/wiklou.git] / includes / db / DatabaseMysqlBase.php
index 647a42a..cf37736 100644 (file)
@@ -93,7 +93,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                        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" );
@@ -108,7 +108,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                        $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" );
 
@@ -321,7 +321,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
 
        /**
         * @param ResultWrapper|resource $res
-        * @param $n int
+        * @param int $n
         * @return string
         */
        function fieldName( $res, $n ) {
@@ -336,7 +336,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * Get the name of the specified field in a result
         *
         * @param ResultWrapper|resource $res
-        * @param $n int
+        * @param int $n
         * @return string
         */
        abstract protected function mysqlFieldName( $res, $n );
@@ -344,7 +344,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
        /**
         * mysql_field_type() wrapper
         * @param ResultWrapper|resource $res
-        * @param $n int
+        * @param int $n
         * @return string
         */
        public function fieldType( $res, $n ) {
@@ -637,47 +637,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                }
        }
 
-       /**
-        * @deprecated in 1.19, use getLagFromSlaveStatus
-        *
-        * @return bool|int
-        */
-       function getLagFromProcesslist() {
-               wfDeprecated( __METHOD__, '1.19' );
-               $res = $this->query( 'SHOW PROCESSLIST', __METHOD__ );
-               if ( !$res ) {
-                       return false;
-               }
-               # Find slave SQL thread
-               foreach ( $res as $row ) {
-                       /* This should work for most situations - when default db
-                        * for thread is not specified, it had no events executed,
-                        * and therefore it doesn't know yet how lagged it is.
-                        *
-                        * Relay log I/O thread does not select databases.
-                        */
-                       if ( $row->User == 'system user' &&
-                               $row->State != 'Waiting for master to send event' &&
-                               $row->State != 'Connecting to master' &&
-                               $row->State != 'Queueing master event to the relay log' &&
-                               $row->State != 'Waiting for master update' &&
-                               $row->State != 'Requesting binlog dump' &&
-                               $row->State != 'Waiting to reconnect after a failed master event read' &&
-                               $row->State != 'Reconnecting after a failed master event read' &&
-                               $row->State != 'Registering slave on master'
-                       ) {
-                               # This is it, return the time (except -ve)
-                               if ( $row->Time > 0x7fffffff ) {
-                                       return false;
-                               } else {
-                                       return $row->Time;
-                               }
-                       }
-               }
-
-               return false;
-       }
-
        /**
         * Wait for the slave to catch up to a given master position.
         * @todo Return values for this and base class are rubbish
@@ -804,14 +763,18 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * @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]';
        }
 
        /**
@@ -957,12 +920,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
 
        /**
         * DELETE where the condition is a join. MySql uses multi-table deletes.
-        * @param $delTable string
-        * @param $joinTable string
-        * @param $delVar string
-        * @param $joinVar string
-        * @param $conds array|string
-        * @param bool|string $fname bool
+        * @param string $delTable
+        * @param string $joinTable
+        * @param string $delVar
+        * @param string $joinVar
+        * @param array|string $conds
+        * @param bool|string $fname
         * @throws DBUnexpectedError
         * @return bool|ResultWrapper
         */
@@ -996,7 +959,10 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                if ( !count( $rows ) ) {
                        return true; // nothing to do
                }
-               $rows = is_array( reset( $rows ) ) ? $rows : array( $rows );
+
+               if ( !is_array( reset( $rows ) ) ) {
+                       $rows = array( $rows );
+               }
 
                $table = $this->tableName( $table );
                $columns = array_keys( $rows[0] );
@@ -1102,8 +1068,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
        }
 
        /**
-        * @param $tableName
-        * @param $fName string
+        * @param string $tableName
+        * @param string $fName
         * @return bool|ResultWrapper
         */
        public function dropTable( $tableName, $fName = __METHOD__ ) {
@@ -1289,7 +1255,7 @@ class MySQLMasterPos implements DBMasterPos {
        }
 
        /**
-        * @return array|false (int, int)
+        * @return array|bool (int, int)
         */
        protected function getCoordinates() {
                $m = array();