function Connection::getMariaDbVersionMatch

Same name and namespace in other branches
  1. 10 core/modules/mysql/src/Driver/Database/mysql/Connection.php \Drupal\mysql\Driver\Database\mysql\Connection::getMariaDbVersionMatch()
  2. 11.x core/modules/mysql/src/Driver/Database/mysql/Connection.php \Drupal\mysql\Driver\Database\mysql\Connection::getMariaDbVersionMatch()

Gets the MariaDB portion of the server version.

Return value

string The MariaDB portion of the server version if present, or NULL if not.

2 calls to Connection::getMariaDbVersionMatch()
Connection::isMariaDb in core/modules/mysql/src/Driver/Database/mysql/Connection.php
Determines whether the MySQL distribution is MariaDB or not.
Connection::version in core/modules/mysql/src/Driver/Database/mysql/Connection.php
Returns the version of the database server.

File

core/modules/mysql/src/Driver/Database/mysql/Connection.php, line 290

Class

Connection
MySQL implementation of <a href="/api/drupal/core%21lib%21Drupal%21Core%21Database%21Connection.php/class/Connection/9" title="Base Database API class." class="local">\Drupal\Core\Database\Connection</a>.

Namespace

Drupal\mysql\Driver\Database\mysql

Code

protected function getMariaDbVersionMatch() : ?string {
    // MariaDB may prefix its version string with '5.5.5-', which should be
    // ignored.
    // @see https://github.com/MariaDB/server/blob/f6633bf058802ad7da8196d01fd19d75c53f7274/include/mysql_com.h#L42.
    $regex = '/^(?:5\\.5\\.5-)?(\\d+\\.\\d+\\.\\d+.*-mariadb.*)/i';
    preg_match($regex, $this->getServerVersion(), $matches);
    return empty($matches[1]) ? NULL : $matches[1];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.