Skip to content

Commit 441bd64

Browse files
committed
MC-35778: Integration failures on Magento 2.3-develop with MariaDB 10.2
1 parent 04b8a75 commit 441bd64

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
namespace Magento\Framework\Setup\Declaration\Schema\Db;
88

9-
use Magento\Framework\DB\Adapter\ConnectionException;
10-
use Magento\Framework\DB\Adapter\SqlVersionProvider;
9+
use Magento\Framework\App\ResourceConnection;
1110
use Magento\Framework\Setup\Declaration\Schema\Dto\ElementInterface;
1211

1312
/**
@@ -21,20 +20,25 @@ class DefinitionAggregator implements DbDefinitionProcessorInterface
2120
private $definitionProcessors;
2221

2322
/**
24-
* @var SqlVersionProvider
23+
* @var ResourceConnection
2524
*/
26-
private $sqlVersionProvider;
25+
private $resourceConnection;
2726

2827
/**
29-
* @param SqlVersionProvider $sqlVersionProvider
28+
* @var string
29+
*/
30+
private $dbVersion;
31+
32+
/**
33+
* @param ResourceConnection $resourceConnection
3034
* @param DbDefinitionProcessorInterface[] $definitionProcessors
3135
*/
3236
public function __construct(
33-
SqlVersionProvider $sqlVersionProvider,
37+
ResourceConnection $resourceConnection,
3438
array $definitionProcessors
3539
) {
3640
$this->definitionProcessors = $definitionProcessors;
37-
$this->sqlVersionProvider = $sqlVersionProvider;
41+
$this->resourceConnection = $resourceConnection;
3842
}
3943

4044
/**
@@ -73,6 +77,21 @@ public function fromDefinition(array $data)
7377
return $definitionProcessor->fromDefinition($data);
7478
}
7579

80+
/**
81+
* Get DB version
82+
*
83+
* @return string
84+
*/
85+
private function getDatabaseVersion(): string
86+
{
87+
if (!$this->dbVersion) {
88+
$this->dbVersion = $this->resourceConnection->getConnection('default')
89+
->fetchPairs("SHOW variables LIKE 'version'")['version'];
90+
}
91+
92+
return $this->dbVersion;
93+
}
94+
7695
/**
7796
* Processes `$value` to be compatible with MySQL.
7897
*
@@ -88,7 +107,7 @@ protected function processDefaultValue(array $data)
88107
if ($defaultValue === "'NULL'") {
89108
return "NULL";
90109
}
91-
if ($defaultValue === "NULL" && $this->isMariaDbSqlConnection()) {
110+
if ($defaultValue === "NULL" && strpos($this->getDatabaseVersion(), 'MariaDB') !== false) {
92111
return null;
93112
}
94113
/*
@@ -108,18 +127,4 @@ protected function processDefaultValue(array $data)
108127

109128
return $defaultValue;
110129
}
111-
112-
/**
113-
* Checks if MariaDB used as SQL engine
114-
*
115-
* @return bool
116-
* @throws ConnectionException
117-
*/
118-
private function isMariaDbSqlConnection(): bool
119-
{
120-
return strpos(
121-
$this->sqlVersionProvider->getSqlVersion(),
122-
SqlVersionProvider::MARIA_DB_10_VERSION
123-
) === 0;
124-
}
125130
}

0 commit comments

Comments
 (0)