dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanups to DatabaseMysqlBase
[lhc/web/wiklou.git]
/
includes
/
db
/
DatabaseMysqlBase.php
diff --git
a/includes/db/DatabaseMysqlBase.php
b/includes/db/DatabaseMysqlBase.php
index
06511e0
..
46c6678
100644
(file)
--- a/
includes/db/DatabaseMysqlBase.php
+++ b/
includes/db/DatabaseMysqlBase.php
@@
-46,6
+46,11
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
protected $sslCAPath;
/** @var string[]|null */
protected $sslCiphers;
protected $sslCAPath;
/** @var string[]|null */
protected $sslCiphers;
+ /** @var string sql_mode value to send on connection */
+ protected $sqlMode;
+ /** @var bool Use experimental UTF-8 transmission encoding */
+ protected $utf8Mode;
+
/** @var string|null */
private $serverVersion = null;
/** @var string|null */
private $serverVersion = null;
@@
-82,6
+87,8
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
$this->$var = $params[$var];
}
}
$this->$var = $params[$var];
}
}
+ $this->sqlMode = isset( $params['sqlMode'] ) ? $params['sqlMode'] : '';
+ $this->utf8Mode = !empty( $params['utf8Mode'] );
}
/**
}
/**
@@
-100,13
+107,9
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
* @return bool
*/
function open( $server, $user, $password, $dbName ) {
* @return bool
*/
function open( $server, $user, $password, $dbName ) {
- global $wgAllDBsAreLocalhost, $wgSQLMode;
-
# Close/unset connection handle
$this->close();
# Close/unset connection handle
$this->close();
- # Debugging hack -- fake cluster
- $realServer = $wgAllDBsAreLocalhost ? 'localhost' : $server;
$this->mServer = $server;
$this->mUser = $user;
$this->mPassword = $password;
$this->mServer = $server;
$this->mUser = $user;
$this->mPassword = $password;
@@
-114,7
+117,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
$this->installErrorHandler();
try {
$this->installErrorHandler();
try {
- $this->mConn = $this->mysqlConnect( $
real
Server );
+ $this->mConn = $this->mysqlConnect( $
this->m
Server );
} catch ( Exception $ex ) {
$this->restoreErrorHandler();
throw $ex;
} catch ( Exception $ex ) {
$this->restoreErrorHandler();
throw $ex;
@@
-126,14
+129,14
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
if ( !$error ) {
$error = $this->lastError();
}
if ( !$error ) {
$error = $this->lastError();
}
-
wfLogDBE
rror(
+
$this->queryLogger->e
rror(
"Error connecting to {db_server}: {error}",
$this->getLogContext( [
'method' => __METHOD__,
'error' => $error,
] )
);
"Error connecting to {db_server}: {error}",
$this->getLogContext( [
'method' => __METHOD__,
'error' => $error,
] )
);
-
wfD
ebug( "DB connection error\n" .
+
$this->queryLogger->d
ebug( "DB connection error\n" .
"Server: $server, User: $user, Password: " .
substr( $password, 0, 3 ) . "..., error: " . $error . "\n" );
"Server: $server, User: $user, Password: " .
substr( $password, 0, 3 ) . "..., error: " . $error . "\n" );
@@
-145,14
+148,14
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
$success = $this->selectDB( $dbName );
MediaWiki\restoreWarnings();
if ( !$success ) {
$success = $this->selectDB( $dbName );
MediaWiki\restoreWarnings();
if ( !$success ) {
-
wfLogDBE
rror(
+
$this->queryLogger->e
rror(
"Error selecting database {db_name} on server {db_server}",
$this->getLogContext( [
'method' => __METHOD__,
] )
);
"Error selecting database {db_name} on server {db_server}",
$this->getLogContext( [
'method' => __METHOD__,
] )
);
- wfDebug( "Error selecting database $dbName on server {$this->mServer} " .
- "
from client host " . wfHostname() . "\n
" );
+ $this->queryLogger->debug(
+ "
Error selecting database $dbName on server {$this->mServer}
" );
$this->reportConnectionError( "Error selecting database $dbName" );
}
$this->reportConnectionError( "Error selecting database $dbName" );
}
@@
-166,8
+169,8
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
// Abstract over any insane MySQL defaults
$set = [ 'group_concat_max_len = 262144' ];
// Set SQL mode, default is turning them all off, can be overridden or skipped with null
// Abstract over any insane MySQL defaults
$set = [ 'group_concat_max_len = 262144' ];
// Set SQL mode, default is turning them all off, can be overridden or skipped with null
- if ( is_string( $
wgSQL
Mode ) ) {
- $set[] = 'sql_mode = ' . $this->addQuotes( $
wgSQL
Mode );
+ if ( is_string( $
this->sql
Mode ) ) {
+ $set[] = 'sql_mode = ' . $this->addQuotes( $
this->sql
Mode );
}
// Set any custom settings defined by site config
// (e.g. https://dev.mysql.com/doc/refman/4.1/en/innodb-parameters.html)
}
// Set any custom settings defined by site config
// (e.g. https://dev.mysql.com/doc/refman/4.1/en/innodb-parameters.html)
@@
-183,7
+186,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
// Use doQuery() to avoid opening implicit transactions (DBO_TRX)
$success = $this->doQuery( 'SET ' . implode( ', ', $set ) );
if ( !$success ) {
// Use doQuery() to avoid opening implicit transactions (DBO_TRX)
$success = $this->doQuery( 'SET ' . implode( ', ', $set ) );
if ( !$success ) {
-
wfLogDBE
rror(
+
$this->queryLogger->e
rror(
'Error setting MySQL variables on server {db_server} (check $wgSQLMode)',
$this->getLogContext( [
'method' => __METHOD__,
'Error setting MySQL variables on server {db_server} (check $wgSQLMode)',
$this->getLogContext( [
'method' => __METHOD__,
@@
-204,9
+207,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
* @return bool
*/
protected function connectInitCharset() {
* @return bool
*/
protected function connectInitCharset() {
- global $wgDBmysql5;
-
- if ( $wgDBmysql5 ) {
+ if ( $this->utf8Mode ) {
// Tell the server we're communicating with it in UTF-8.
// This may engage various charset conversions.
return $this->mysqlSetCharset( 'utf8' );
// Tell the server we're communicating with it in UTF-8.
// This may engage various charset conversions.
return $this->mysqlSetCharset( 'utf8' );
@@
-657,7
+658,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
// Standard method: use master server ID (works with stock pt-heartbeat)
$masterInfo = $this->getMasterServerInfo();
if ( !$masterInfo ) {
// Standard method: use master server ID (works with stock pt-heartbeat)
$masterInfo = $this->getMasterServerInfo();
if ( !$masterInfo ) {
-
wfLogDBE
rror(
+
$this->queryLogger->e
rror(
"Unable to query master of {db_server} for server ID",
$this->getLogContext( [
'method' => __METHOD__
"Unable to query master of {db_server} for server ID",
$this->getLogContext( [
'method' => __METHOD__
@@
-680,7
+681,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
return max( $nowUnix - $timeUnix, 0.0 );
}
return max( $nowUnix - $timeUnix, 0.0 );
}
-
wfLogDBE
rror(
+
$this->queryLogger->e
rror(
"Unable to find pt-heartbeat row for {db_server}",
$this->getLogContext( [
'method' => __METHOD__
"Unable to find pt-heartbeat row for {db_server}",
$this->getLogContext( [
'method' => __METHOD__
@@
-984,7
+985,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
return true;
}
return true;
}
-
wfD
ebug( __METHOD__ . " failed to acquire lock\n" );
+
$this->queryLogger->d
ebug( __METHOD__ . " failed to acquire lock\n" );
return false;
}
return false;
}
@@
-1006,7
+1007,7
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
return true;
}
return true;
}
-
wfD
ebug( __METHOD__ . " failed to release lock\n" );
+
$this->queryLogger->d
ebug( __METHOD__ . " failed to release lock\n" );
return false;
}
return false;
}