aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/rdbms
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2020-01-09 20:41:16 -0800
committerAaron Schulz <aschulz@wikimedia.org>2021-05-18 19:44:45 +0000
commitb94eeb077a5409870cb30b8f708d171948a6ad6c (patch)
tree74634c3468a8b08e4b2d325610761f67c5a2b52f /includes/libs/rdbms
parent0157586f9b311751b3ebb06e41ddfd2afd254ebe (diff)
downloadmediawikicore-b94eeb077a5409870cb30b8f708d171948a6ad6c.tar.gz
mediawikicore-b94eeb077a5409870cb30b8f708d171948a6ad6c.zip
rdbms: factor out getMySqlServerVariant() helper method
Change-Id: I31e18c79983ec4846083ccbbc699e03b05f4592e
Diffstat (limited to 'includes/libs/rdbms')
-rw-r--r--includes/libs/rdbms/database/DatabaseMysqlBase.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php
index e8578e4a4dfd..001f47faf520 100644
--- a/includes/libs/rdbms/database/DatabaseMysqlBase.php
+++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php
@@ -1128,21 +1128,37 @@ abstract class DatabaseMysqlBase extends Database {
* @return string
*/
public function getSoftwareLink() {
- // 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 ) {
+ list( $variant ) = $this->getMySqlServerVariant();
+ if ( $variant === 'MariaDB' ) {
return '[{{int:version-db-mariadb-url}} MariaDB]';
}
- // 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]';
}
/**
+ * @return string[] (one of ("MariaDB","MySQL"), x.y.z version string)
+ */
+ protected function getMySqlServerVariant() {
+ $version = $this->getServerVersion();
+
+ // MariaDB includes its name in its version string; this is how MariaDB's version of
+ // the mysql command-line client identifies MariaDB servers.
+ // https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_version
+ // https://mariadb.com/kb/en/version/
+ $parts = explode( '-', $version, 2 );
+ $number = $parts[0];
+ $suffix = $parts[1] ?? '';
+ if ( strpos( $suffix, 'MariaDB' ) !== false || strpos( $suffix, '-maria-' ) !== false ) {
+ $vendor = 'MariaDB';
+ } else {
+ $vendor = 'MySQL';
+ }
+
+ return [ $vendor, $number ];
+ }
+
+ /**
* @return string
*/
public function getServerVersion() {