API
9 months ago
Exception
2 years ago
Middleware
2 years ago
AbstractException.php
2 years ago
AbstractMySQLDriver.php
9 months ago
Connection.php
2 years ago
Exception.php
2 years ago
FetchUtils.php
2 years ago
Middleware.php
2 years ago
Result.php
2 years ago
ServerInfoAwareConnection.php
2 years ago
Statement.php
2 years ago
index.php
2 years ago
AbstractMySQLDriver.php
117 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL\Driver; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Connection; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Driver\API\ExceptionConverter; |
| 6 | use MailPoetVendor\Doctrine\DBAL\Driver\API\MySQL; |
| 7 | use MailPoetVendor\Doctrine\DBAL\Exception; |
| 8 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractMySQLPlatform; |
| 9 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 10 | use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1010Platform; |
| 11 | use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1027Platform; |
| 12 | use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1043Platform; |
| 13 | use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1052Platform; |
| 14 | use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1060Platform; |
| 15 | use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb110700Platform; |
| 16 | use MailPoetVendor\Doctrine\DBAL\Platforms\MySQL57Platform; |
| 17 | use MailPoetVendor\Doctrine\DBAL\Platforms\MySQL80Platform; |
| 18 | use MailPoetVendor\Doctrine\DBAL\Platforms\MySQL84Platform; |
| 19 | use MailPoetVendor\Doctrine\DBAL\Platforms\MySQLPlatform; |
| 20 | use MailPoetVendor\Doctrine\DBAL\Schema\MySQLSchemaManager; |
| 21 | use MailPoetVendor\Doctrine\DBAL\VersionAwarePlatformDriver; |
| 22 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 23 | use function assert; |
| 24 | use function preg_match; |
| 25 | use function stripos; |
| 26 | use function version_compare; |
| 27 | abstract class AbstractMySQLDriver implements VersionAwarePlatformDriver |
| 28 | { |
| 29 | public function createDatabasePlatformForVersion($version) |
| 30 | { |
| 31 | $mariadb = stripos($version, 'mariadb') !== \false; |
| 32 | if ($mariadb) { |
| 33 | $mariaDbVersion = $this->getMariaDbMysqlVersionNumber($version); |
| 34 | if (version_compare($mariaDbVersion, '11.7.0', '>=')) { |
| 35 | return new MariaDb110700Platform(); |
| 36 | } |
| 37 | if (version_compare($mariaDbVersion, '10.10.0', '>=')) { |
| 38 | return new MariaDb1010Platform(); |
| 39 | } |
| 40 | if (version_compare($mariaDbVersion, '10.6.0', '>=')) { |
| 41 | return new MariaDb1060Platform(); |
| 42 | } |
| 43 | if (version_compare($mariaDbVersion, '10.5.2', '>=')) { |
| 44 | return new MariaDb1052Platform(); |
| 45 | } |
| 46 | if (version_compare($mariaDbVersion, '10.4.3', '>=')) { |
| 47 | return new MariaDb1043Platform(); |
| 48 | } |
| 49 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/6110', 'Support for MariaDB < 10.4 is deprecated and will be removed in DBAL 4.' . ' Consider upgrading to a more recent version of MariaDB.'); |
| 50 | if (version_compare($mariaDbVersion, '10.2.7', '>=')) { |
| 51 | return new MariaDb1027Platform(); |
| 52 | } |
| 53 | } else { |
| 54 | $oracleMysqlVersion = $this->getOracleMysqlVersionNumber($version); |
| 55 | if (version_compare($oracleMysqlVersion, '8.4.0', '>=')) { |
| 56 | if (!version_compare($version, '8.4.0', '>=')) { |
| 57 | Deprecation::trigger('doctrine/orm', 'https://github.com/doctrine/dbal/pull/5779', 'Version detection logic for MySQL will change in DBAL 4. ' . 'Please specify the version as the server reports it, e.g. "8.4.0" instead of "8.4".'); |
| 58 | } |
| 59 | return new MySQL84Platform(); |
| 60 | } |
| 61 | if (version_compare($oracleMysqlVersion, '8', '>=')) { |
| 62 | if (!version_compare($version, '8.0.0', '>=')) { |
| 63 | Deprecation::trigger('doctrine/orm', 'https://github.com/doctrine/dbal/pull/5779', 'Version detection logic for MySQL will change in DBAL 4. ' . 'Please specify the version as the server reports it, e.g. "8.0.31" instead of "8".'); |
| 64 | } |
| 65 | return new MySQL80Platform(); |
| 66 | } |
| 67 | if (version_compare($oracleMysqlVersion, '5.7.9', '>=')) { |
| 68 | if (!version_compare($version, '5.7.9', '>=')) { |
| 69 | Deprecation::trigger('doctrine/orm', 'https://github.com/doctrine/dbal/pull/5779', 'Version detection logic for MySQL will change in DBAL 4. ' . 'Please specify the version as the server reports it, e.g. "5.7.40" instead of "5.7".'); |
| 70 | } |
| 71 | return new MySQL57Platform(); |
| 72 | } |
| 73 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5072', 'MySQL 5.6 support is deprecated and will be removed in DBAL 4.' . ' Consider upgrading to MySQL 5.7 or later.'); |
| 74 | } |
| 75 | return $this->getDatabasePlatform(); |
| 76 | } |
| 77 | private function getOracleMysqlVersionNumber(string $versionString) : string |
| 78 | { |
| 79 | if (preg_match('/^(?P<major>\\d+)(?:\\.(?P<minor>\\d+)(?:\\.(?P<patch>\\d+))?)?/', $versionString, $versionParts) !== 1) { |
| 80 | throw Exception::invalidPlatformVersionSpecified($versionString, '<major_version>.<minor_version>.<patch_version>'); |
| 81 | } |
| 82 | $majorVersion = $versionParts['major']; |
| 83 | $minorVersion = $versionParts['minor'] ?? 0; |
| 84 | $patchVersion = $versionParts['patch'] ?? null; |
| 85 | if ($majorVersion === '5' && $minorVersion === '7') { |
| 86 | $patchVersion ??= '9'; |
| 87 | } else { |
| 88 | $patchVersion ??= '0'; |
| 89 | } |
| 90 | return $majorVersion . '.' . $minorVersion . '.' . $patchVersion; |
| 91 | } |
| 92 | private function getMariaDbMysqlVersionNumber(string $versionString) : string |
| 93 | { |
| 94 | if (stripos($versionString, 'MariaDB') === 0) { |
| 95 | Deprecation::trigger('doctrine/orm', 'https://github.com/doctrine/dbal/pull/5779', 'Version detection logic for MySQL will change in DBAL 4. ' . 'Please specify the version as the server reports it, ' . 'e.g. "10.9.3-MariaDB" instead of "mariadb-10.9".'); |
| 96 | } |
| 97 | if (preg_match('/^(?:5\\.5\\.5-)?(mariadb-)?(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)/i', $versionString, $versionParts) !== 1) { |
| 98 | throw Exception::invalidPlatformVersionSpecified($versionString, '^(?:5\\.5\\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'); |
| 99 | } |
| 100 | return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch']; |
| 101 | } |
| 102 | public function getDatabasePlatform() |
| 103 | { |
| 104 | return new MySQLPlatform(); |
| 105 | } |
| 106 | public function getSchemaManager(Connection $conn, AbstractPlatform $platform) |
| 107 | { |
| 108 | Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5458', 'AbstractMySQLDriver::getSchemaManager() is deprecated.' . ' Use MySQLPlatform::createSchemaManager() instead.'); |
| 109 | assert($platform instanceof AbstractMySQLPlatform); |
| 110 | return new MySQLSchemaManager($conn, $platform); |
| 111 | } |
| 112 | public function getExceptionConverter() : ExceptionConverter |
| 113 | { |
| 114 | return new MySQL\ExceptionConverter(); |
| 115 | } |
| 116 | } |
| 117 |