Discussion:
[MediaWiki-commits] [Gerrit] DatabaseMysqlBase: Use VERSION() rather than server_info - change (mediawiki/core)
PleaseStand (Code Review)
2014-09-20 10:34:40 UTC
Permalink
PleaseStand has uploaded a new change for review.

https://gerrit.wikimedia.org/r/161652

Change subject: DatabaseMysqlBase: Use VERSION() rather than server_info
......................................................................

DatabaseMysqlBase: Use VERSION() rather than server_info

I noticed enwiki's Special:Version page was reporting the version
of MariaDB 10 as "5.5.5-10.0.11-MariaDB-log" rather than just
"10.0.11-MariaDB-log". This change should fix that.

Change-Id: I6bf7e27e88014f70594b33d089636b09b6c97527
---
M includes/db/DatabaseMysql.php
M includes/db/DatabaseMysqlBase.php
M includes/db/DatabaseMysqli.php
3 files changed, 19 insertions(+), 17 deletions(-)


git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/52/161652/1

diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php
index dc4a67d..823d9b6 100644
--- a/includes/db/DatabaseMysql.php
+++ b/includes/db/DatabaseMysql.php
@@ -142,13 +142,6 @@
return mysql_select_db( $db, $this->mConn );
}

- /**
- * @return string
- */
- function getServerVersion() {
- return mysql_get_server_info( $this->mConn );
- }
-
protected function mysqlFreeResult( $res ) {
return mysql_free_result( $res );
}
diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php
index ba0f39f..2008f4d 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -38,6 +38,9 @@

protected $mFakeMaster = false;

+ /** @var string|null */
+ private $serverVersion = null;
+
/**
* @return string
*/
@@ -763,9 +766,9 @@
* @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).
+ // MariaDB includes its name in its version string; this is how MariaDB's version of
+ // the mysql command-line client identifies MariaDB servers (see mariadb_connection()
+ // in libmysql/libmysql.c).
$version = $this->getServerVersion();
if ( strpos( $version, 'MariaDB' ) !== false || strpos( $version, '-maria-' ) !== false ) {
return '[{{int:version-db-mariadb-url}} MariaDB]';
@@ -778,6 +781,19 @@
}

/**
+ * @return string
+ */
+ public function getServerVersion() {
+ // Not using mysql_get_server_info() or similar for consistency: in the handshake,
+ // MariaDB 10 adds the prefix "5.5.5-", and only some newer client libraries strip
+ // it off (see RPL_VERSION_HACK in include/mysql_com.h).
+ if ( $this->serverVersion === null ) {
+ $this->serverVersion = $this->selectField( '', 'VERSION()', '', __METHOD__ );
+ }
+ return $this->serverVersion;
+ }
+
+ /**
* @param array $options
*/
public function setSessionOptions( array $options ) {
diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php
index a03c9aa..e9c4b39 100644
--- a/includes/db/DatabaseMysqli.php
+++ b/includes/db/DatabaseMysqli.php
@@ -166,13 +166,6 @@
}

/**
- * @return string
- */
- function getServerVersion() {
- return $this->mConn->server_info;
- }
-
- /**
* @param mysqli $res
* @return bool
*/
--
To view, visit https://gerrit.wikimedia.org/r/161652
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bf7e27e88014f70594b33d089636b09b6c97527
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <***@live.com>
jenkins-bot (Code Review)
2014-09-20 21:12:38 UTC
Permalink
jenkins-bot has submitted this change and it was merged.

Change subject: DatabaseMysqlBase: Use VERSION() rather than server_info
......................................................................


DatabaseMysqlBase: Use VERSION() rather than server_info

I noticed enwiki's Special:Version page was reporting the version
of MariaDB 10 as "5.5.5-10.0.11-MariaDB-log" rather than just
"10.0.11-MariaDB-log". This change should fix that.

Change-Id: I6bf7e27e88014f70594b33d089636b09b6c97527
---
M includes/db/DatabaseMysql.php
M includes/db/DatabaseMysqlBase.php
M includes/db/DatabaseMysqli.php
3 files changed, 19 insertions(+), 17 deletions(-)

Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified



diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php
index dc4a67d..823d9b6 100644
--- a/includes/db/DatabaseMysql.php
+++ b/includes/db/DatabaseMysql.php
@@ -142,13 +142,6 @@
return mysql_select_db( $db, $this->mConn );
}

- /**
- * @return string
- */
- function getServerVersion() {
- return mysql_get_server_info( $this->mConn );
- }
-
protected function mysqlFreeResult( $res ) {
return mysql_free_result( $res );
}
diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php
index ba0f39f..2008f4d 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -38,6 +38,9 @@

protected $mFakeMaster = false;

+ /** @var string|null */
+ private $serverVersion = null;
+
/**
* @return string
*/
@@ -763,9 +766,9 @@
* @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).
+ // MariaDB includes its name in its version string; this is how MariaDB's version of
+ // the mysql command-line client identifies MariaDB servers (see mariadb_connection()
+ // in libmysql/libmysql.c).
$version = $this->getServerVersion();
if ( strpos( $version, 'MariaDB' ) !== false || strpos( $version, '-maria-' ) !== false ) {
return '[{{int:version-db-mariadb-url}} MariaDB]';
@@ -778,6 +781,19 @@
}

/**
+ * @return string
+ */
+ public function getServerVersion() {
+ // Not using mysql_get_server_info() or similar for consistency: in the handshake,
+ // MariaDB 10 adds the prefix "5.5.5-", and only some newer client libraries strip
+ // it off (see RPL_VERSION_HACK in include/mysql_com.h).
+ if ( $this->serverVersion === null ) {
+ $this->serverVersion = $this->selectField( '', 'VERSION()', '', __METHOD__ );
+ }
+ return $this->serverVersion;
+ }
+
+ /**
* @param array $options
*/
public function setSessionOptions( array $options ) {
diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php
index a03c9aa..e9c4b39 100644
--- a/includes/db/DatabaseMysqli.php
+++ b/includes/db/DatabaseMysqli.php
@@ -166,13 +166,6 @@
}

/**
- * @return string
- */
- function getServerVersion() {
- return $this->mConn->server_info;
- }
-
- /**
* @param mysqli $res
* @return bool
*/
--
To view, visit https://gerrit.wikimedia.org/r/161652
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6bf7e27e88014f70594b33d089636b09b6c97527
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <***@live.com>
Gerrit-Reviewer: Aaron Schulz <***@wikimedia.org>
Gerrit-Reviewer: Parent5446 <***@gmail.com>
Gerrit-Reviewer: jenkins-bot <>
Loading...