Merge "Revert "Declare visibility for class properties in MySQLMasterPos""
[lhc/web/wiklou.git] / includes / db / DatabaseMysqlBase.php
index 3125325..14369bf 100644 (file)
@@ -49,7 +49,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
         * @throws DBConnectionError
         */
        function open( $server, $user, $password, $dbName ) {
-               global $wgAllDBsAreLocalhost, $wgDBmysql5, $wgSQLMode;
+               global $wgAllDBsAreLocalhost, $wgSQLMode;
                wfProfileIn( __METHOD__ );
 
                # Debugging hack -- fake cluster
@@ -95,7 +95,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
 
                        wfProfileOut( __METHOD__ );
 
-                       return $this->reportConnectionError( $error );
+                       $this->reportConnectionError( $error );
                }
 
                if ( $dbName != '' ) {
@@ -109,17 +109,15 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
 
                                wfProfileOut( __METHOD__ );
 
-                               return $this->reportConnectionError( "Error selecting database $dbName" );
+                               $this->reportConnectionError( "Error selecting database $dbName" );
                        }
                }
 
-               // Tell the server we're communicating with it in UTF-8.
-               // This may engage various charset conversions.
-               if ( $wgDBmysql5 ) {
-                       $this->mysqlSetCharset( 'utf8' );
-               } else {
-                       $this->mysqlSetCharset( 'binary' );
+               // Tell the server what we're communicating with
+               if ( !$this->connectInitCharset() ) {
+                       $this->reportConnectionError( "Error setting character set" );
                }
+
                // Set SQL mode, default is turning them all off, can be overridden or skipped with null
                if ( is_string( $wgSQLMode ) ) {
                        $mode = $this->addQuotes( $wgSQLMode );
@@ -128,7 +126,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                        if ( !$success ) {
                                wfLogDBError( "Error setting sql_mode to $mode on server {$this->mServer}" );
                                wfProfileOut( __METHOD__ );
-                               return $this->reportConnectionError( "Error setting sql_mode to $mode" );
+                               $this->reportConnectionError( "Error setting sql_mode to $mode" );
                        }
                }
 
@@ -138,6 +136,22 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                return true;
        }
 
+       /**
+        * Set the character set information right after connection
+        * @return bool
+        */
+       protected function connectInitCharset() {
+               global $wgDBmysql5;
+
+               if ( $wgDBmysql5 ) {
+                       // Tell the server we're communicating with it in UTF-8.
+                       // This may engage various charset conversions.
+                       return $this->mysqlSetCharset( 'utf8' );
+               } else {
+                       return $this->mysqlSetCharset( 'binary' );
+               }
+       }
+
        /**
         * Open a connection to a MySQL server
         *