Skip to content

Commit cd1dadc

Browse files
committed
AC-12085:: Add compatibility with MariaDB 11.4 LTS For CE
1 parent 94a601f commit cd1dadc

File tree

4 files changed

+49
-97
lines changed

4 files changed

+49
-97
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@
9090
"tubalmartin/cssmin": "^4.1",
9191
"web-token/jwt-framework": "^3.1",
9292
"webonyx/graphql-php": "^15.0",
93-
"wikimedia/less.php": "^3.2",
94-
"psr/http-message": "^1.0"
93+
"wikimedia/less.php": "^3.2"
9594
},
9695
"require-dev": {
9796
"allure-framework/allure-phpunit": "^3",

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/integration/framework/Magento/TestFramework/Db/Mysql.php

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ class Mysql extends \Magento\TestFramework\Db\AbstractDb
1616
/**
1717
* Mysql default Port.
1818
*/
19-
protected const DEFAULT_PORT = 3306;
19+
public const DEFAULT_PORT = 3306;
2020

2121
/**
2222
* MariaDB minimum version.
2323
*/
24-
protected const MARIADB_MIN_VERSION = '11.4.';
24+
public const MARIADB_MIN_VERSION = '11.4.';
2525

2626
/**
2727
* Name of configuration file.
2828
*/
29-
protected const DEFAULTS_EXTRA_FILE_NAME = 'defaults_extra.cnf';
29+
public const DEFAULTS_EXTRA_FILE_NAME = 'defaults_extra.cnf';
3030

3131
/**
3232
* MySQL DB dump file
@@ -92,10 +92,8 @@ public function __construct($host, $user, $password, $schema, $varPath, \Magento
9292
*/
9393
public function cleanup()
9494
{
95-
$dbCommand = 'mysql';
96-
if ($this->isMariaDB()) {
97-
$dbCommand = 'mariadb';
98-
}
95+
$dbCommand = $this->getDbCommand();
96+
9997
$this->ensureDefaultsExtraFile();
10098
$this->_shell->execute(
10199
'%s --defaults-file=%s --host=%s --port=%s %s -e %s',
@@ -135,14 +133,10 @@ public function isDbDumpExists()
135133
*/
136134
public function storeDbDump()
137135
{
138-
$dumpCommand = 'mysqldump';
136+
$dumpCommand = $this->getDbDumpCommand();
139137
$this->ensureDefaultsExtraFile();
140138
$additionalArguments = [];
141139

142-
if ($this->isMariaDB()) {
143-
$dumpCommand = 'mariadb-dump';
144-
}
145-
146140
if ($this->isMysqlDumpVersion8()) {
147141
$additionalArguments[] = '--column-statistics=0';
148142
}
@@ -184,10 +178,7 @@ public function restoreFromDbDump()
184178
throw new \LogicException("DB dump file does not exist: " . $this->getSetupDbDumpFilename());
185179
}
186180

187-
$dbCommand = 'mysql';
188-
if ($this->isMariaDB()) {
189-
$dbCommand = 'mariadb';
190-
}
181+
$dbCommand = $this->getDbCommand();
191182

192183
$this->_shell->execute(
193184
'%s --defaults-file=%s --host=%s --port=%s %s < %s',
@@ -279,25 +270,45 @@ private function isUsingAuroraDb(): bool
279270
private function isMariaDB(): bool
280271
{
281272
try {
282-
if (!$this->isMariaDB) {
273+
if (!isset($this->isMariaDB)) {
283274
$version = $this->_shell->execute(
284275
'mariadb-dump --version'
285276
);
286-
287-
$this->isMariaDB = (bool) preg_match('/-MariaDB/i', $version);
288-
289-
if ($this->isMariaDB) {
290-
$pattern = "/\s*((?:[0-9]+\.?)+)/i";
291-
preg_match($pattern, $version, $matches);
292-
$currentVersion = $matches[1];
293-
if (!version_compare($currentVersion, self::MARIADB_MIN_VERSION, '>=')) {
294-
$this->isMariaDB = false;
295-
}
277+
$pattern = "/((?:[0-9]+\.?)+)(.*?)(mariadb)/i";
278+
preg_match($pattern, $version === null ? $version : '', $matches);
279+
$currentVersion = $matches[1] ?? '';
280+
$isMariadb = isset($matches[3]);
281+
if ($isMariadb
282+
&& $currentVersion
283+
&& version_compare($currentVersion, self::MARIADB_MIN_VERSION, '>=')) {
284+
$this->isMariaDB = true;
285+
} else {
286+
$this->isMariaDB = false;
296287
}
297288
}
298289
} catch (LocalizedException $e) {
299290
$this->isMariaDB = false;
300291
}
301292
return $this->isMariaDB;
302293
}
294+
295+
/**
296+
* Get db command mysql or mariadb
297+
*
298+
* @return string
299+
*/
300+
protected function getDbCommand()
301+
{
302+
return $this->isMariaDB() ? 'mariadb' : 'mysql';
303+
}
304+
305+
/**
306+
* Get dump command mysqldum or mariadb-dump
307+
*
308+
* @return string
309+
*/
310+
protected function getDbDumpCommand()
311+
{
312+
return $this->isMariaDB() ? 'mysqldump' : 'mariadb-dump';
313+
}
303314
}

dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/dry_run_log.mariadb10427.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)