* @throws DBConnectionError
*/
function open( $server, $user, $password, $dbName ) {
- global $wgAllDBsAreLocalhost, $wgDBmysql5, $wgSQLMode;
+ global $wgAllDBsAreLocalhost, $wgSQLMode;
wfProfileIn( __METHOD__ );
# Debugging hack -- fake cluster
wfProfileOut( __METHOD__ );
- return $this->reportConnectionError( $error );
+ $this->reportConnectionError( $error );
}
if ( $dbName != '' ) {
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 );
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" );
}
}
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
*
}
class MySQLMasterPos implements DBMasterPos {
- var $file, $pos;
+ /** @var string */
+ private $file;
+
+ /** @var int */
+ private $pos;
function __construct( $file, $pos ) {
$this->file = $file;