Skip to content

Commit 7a99248

Browse files
committed
AC-11995:Add compatibility with MySQL 8.4 LTS for Magento CE
1 parent f9d2a14 commit 7a99248

File tree

1 file changed

+18
-3
lines changed
  • lib/internal/Magento/Framework/DB/Adapter/Pdo

1 file changed

+18
-3
lines changed

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
use Magento\Framework\Stdlib\StringUtils;
3333
use Zend_Db_Adapter_Exception;
3434
use Zend_Db_Statement_Exception;
35-
35+
use Magento\Framework\DB\Adapter\SqlVersionProvider;
3636
// @codingStandardsIgnoreStart
3737

3838
/**
@@ -251,6 +251,16 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface, Rese
251251
*/
252252
private $parentConnections = [];
253253

254+
/**
255+
* @var SqlVersionProvider
256+
*/
257+
private $sqlVersionProvider;
258+
259+
/***
260+
* const MYSQL_8_4_VERSION
261+
*/
262+
public const MYSQL_8_4_VERSION = '8.4';
263+
254264
/**
255265
* Constructor
256266
*
@@ -260,21 +270,24 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface, Rese
260270
* @param SelectFactory $selectFactory
261271
* @param array $config
262272
* @param SerializerInterface|null $serializer
273+
* @param SqlVersionProvider|null $sqlVersionProvider
263274
*/
264275
public function __construct(
265276
StringUtils $string,
266277
DateTime $dateTime,
267278
LoggerInterface $logger,
268279
SelectFactory $selectFactory,
269280
array $config = [],
270-
SerializerInterface $serializer = null
281+
SerializerInterface $serializer = null,
282+
SqlVersionProvider $sqlVersionProvider = null
271283
) {
272284
$this->pid = getmypid();
273285
$this->string = $string;
274286
$this->dateTime = $dateTime;
275287
$this->logger = $logger;
276288
$this->selectFactory = $selectFactory;
277289
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
290+
$this->sqlVersionProvider = $sqlVersionProvider ?? ObjectManager::getInstance()->get(SqlVersionProvider::class);
278291
$this->exceptionMap = [
279292
// SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
280293
2006 => ConnectionException::class,
@@ -3069,7 +3082,9 @@ public function startSetup()
30693082
$this->rawQuery("SET SQL_MODE=''");
30703083
$this->rawQuery("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0");
30713084
$this->rawQuery("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
3072-
$this->rawQuery("SET @@GLOBAL.RESTRICT_FK_ON_NON_STANDARD_KEY=0");
3085+
if(str_contains($this->sqlVersionProvider->getSqlVersion(), self::MYSQL_8_4_VERSION)) {
3086+
$this->rawQuery("SET @@GLOBAL.RESTRICT_FK_ON_NON_STANDARD_KEY=0");
3087+
}
30733088
return $this;
30743089
}
30753090

0 commit comments

Comments
 (0)