TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDB1010Platform as DoctrineMariaDB1010Platform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MariaDB1010Platform extends DoctrineMariaDB1010Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDB1052Platform as DoctrineMariaDB1052Platform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MariaDB1052Platform extends DoctrineMariaDB1052Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDB1060Platform as DoctrineMariaDB1060Platform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MariaDB1060Platform extends DoctrineMariaDB1060Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDB110700Platform as DoctrineMariaDB110700Platform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MariaDB110700Platform extends DoctrineMariaDB110700Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* Note: `doctrine/dbal 4` raised minimal supported MariaDB version to 10.4.3 which the MariaDBPlatform reflects now.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MariaDBPlatform extends DoctrineMariaDBPlatform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MySQL80Platform as DoctrineMySQL80Platform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLDefaultValueDeclarationSQLOverrideTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MySQL80Platform extends DoctrineMySQL80Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use MySQLDefaultValueDeclarationSQLOverrideTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MySQL84Platform as DoctrineMySQL84Platform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLDefaultValueDeclarationSQLOverrideTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MySQL84Platform extends DoctrineMySQL84Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use MySQLDefaultValueDeclarationSQLOverrideTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\MySQLDefaultValueDeclarationSQLOverrideTrait;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* Normally, this platform should not be used anymore since TYPO3 v12 due to the minimal MySQL requirement of 8.0.
|
||||
* However, keep this at least as a default during migration phases.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class MySQLPlatform extends DoctrineMySQLPlatform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
use MySQLCompatibleAlterTablePlatformAwareTrait;
|
||||
use MySQLDefaultValueDeclarationSQLOverrideTrait;
|
||||
|
||||
/**
|
||||
* Gets the SQL statements for altering an existing table.
|
||||
*
|
||||
* This method returns an array of SQL statements, since some platforms need several statements.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff|DoctrineTableDiff $diff): array
|
||||
{
|
||||
return $this->getCustomAlterTableSQLEngineOptions($this, $diff, parent::getAlterTableSQL($diff));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform as DoctrineAbstractPlatform;
|
||||
|
||||
/**
|
||||
* @internal not part of public core API.
|
||||
*/
|
||||
final class PlatformHelper
|
||||
{
|
||||
/**
|
||||
* Doctrine DBAL 4 removed the `getIdentifierQuoteCharacter()` method from the platform classes and suggest to
|
||||
* use `Platform::quoteIdentifier()` instead. As this invoke the need to provide a fake identifier and extract
|
||||
* the character, this helper method is used throughout the core.
|
||||
*
|
||||
* @see https://github.com/doctrine/dbal/blob/4.0.x/UPGRADE.md#bc-break-removed-abstractplatform-methods-exposing-quote-characters
|
||||
* @see https://github.com/doctrine/dbal/blob/3.7.x/UPGRADE.md#deprecated-abstractplatform-methods-exposing-quote-characters
|
||||
*
|
||||
* @param DoctrineAbstractPlatform $platform
|
||||
* @return string
|
||||
*
|
||||
* @internal Used in capsuled code and should not be needed to called by extension code. Not part of public API.
|
||||
*/
|
||||
public function getIdentifierQuoteCharacter(DoctrineAbstractPlatform $platform): string
|
||||
{
|
||||
// Note: Albeit not used yet, $platform is handed over from usages to allow easier adjustments if required.
|
||||
return $platform->quoteSingleIdentifier('fake')[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Exception as DBALException;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform as DoctrineAbstractPlatform;
|
||||
use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform;
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform as DoctrinePostgreSQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\SQLitePlatform as DoctrineSQLitePlatform;
|
||||
|
||||
/**
|
||||
* Helper to handle platform specific details
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PlatformInformation
|
||||
{
|
||||
protected static array $identifierLimits = [
|
||||
'mysql' => 63,
|
||||
'postgresql' => 63,
|
||||
'sqlite' => 1024, // arbitrary limit, SQLite is only limited by the total statement length
|
||||
];
|
||||
|
||||
protected static array $bindParameterLimits = [
|
||||
'mysql' => 65535,
|
||||
'postgresql' => 34464,
|
||||
'sqlite' => 999,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected static array $charSetMap = [
|
||||
'mysql' => 'utf8mb4',
|
||||
'postgresql' => 'UTF8',
|
||||
'sqlite' => 'utf8',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected static array $databaseCreateWithCharsetMap = [
|
||||
'mysql' => 'CHARACTER SET %s',
|
||||
'postgresql' => "ENCODING '%s'",
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the encoding of the given platform
|
||||
*/
|
||||
public static function getCharset(DoctrineAbstractPlatform $platform): string
|
||||
{
|
||||
$platformName = static::getPlatformIdentifier($platform);
|
||||
return static::$charSetMap[$platformName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the statement to create a database with the desired encoding for the given platform
|
||||
*/
|
||||
public static function getDatabaseCreateStatementWithCharset(DoctrineAbstractPlatform $platform, string $databaseName): string
|
||||
{
|
||||
try {
|
||||
$createStatement = $platform->getCreateDatabaseSQL($databaseName);
|
||||
} catch (DBALException $exception) {
|
||||
// just silently ignore that error as the selected database does not support any creation of a database
|
||||
return '';
|
||||
}
|
||||
|
||||
$platformName = static::getPlatformIdentifier($platform);
|
||||
$charset = static::getCharset($platform);
|
||||
|
||||
return $createStatement . ' ' . sprintf(static::$databaseCreateWithCharsetMap[$platformName], $charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return information about the maximum supported length for a SQL identifier.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function getMaxIdentifierLength(DoctrineAbstractPlatform $platform): int
|
||||
{
|
||||
$platformName = static::getPlatformIdentifier($platform);
|
||||
return self::$identifierLimits[$platformName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return information about the maximum number of bound parameters supported on this platform
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function getMaxBindParameters(DoctrineAbstractPlatform $platform): int
|
||||
{
|
||||
$platformName = static::getPlatformIdentifier($platform);
|
||||
return self::$bindParameterLimits[$platformName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the platform shortname to use as a lookup key
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @internal
|
||||
*/
|
||||
protected static function getPlatformIdentifier(DoctrineAbstractPlatform $platform): string
|
||||
{
|
||||
// @todo: In doctrine/dbal 3 MariaDBPlatform extended from MySQLPlatform, since doctrine/dbal 4+ from
|
||||
// AbstractMySQLPlatform. Consider to returning directly 'mariadb' here if consuming code is
|
||||
// prepared for the change.
|
||||
if ($platform instanceof DoctrineMariaDBPlatform) {
|
||||
return 'mysql';
|
||||
}
|
||||
if ($platform instanceof DoctrineMySQLPlatform) {
|
||||
return 'mysql';
|
||||
}
|
||||
if ($platform instanceof DoctrinePostgreSqlPlatform) {
|
||||
return 'postgresql';
|
||||
}
|
||||
if ($platform instanceof DoctrineSQLitePlatform) {
|
||||
return 'sqlite';
|
||||
}
|
||||
throw new \RuntimeException(
|
||||
'Unsupported Databaseplatform "' . get_class($platform) . '" detected in PlatformInformation',
|
||||
1500958070
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\PostgreSQL120Platform as DoctrinePostgreSQL120Platform;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* Note: Albeit empty, we keep it now. Future refactoring may add stuff here, for example columnEquals() modifications.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class PostgreSQL120Platform extends DoctrinePostgreSQL120Platform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform as DoctrinePostgreSQLPlatform;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* Note: Albeit empty, we keep it now. Future refactoring may add stuff here, for example columnEquals() modifications.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class PostgreSQLPlatform extends DoctrinePostgreSQLPlatform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform;
|
||||
|
||||
use Doctrine\DBAL\Platforms\SQLitePlatform as DoctrineSQLitePlatform;
|
||||
use TYPO3\CMS\Core\Database\Platform\Traits\GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
|
||||
/**
|
||||
* doctrine/dbal 4+ removed the old doctrine event system. The new way is to extend the platform
|
||||
* class(es) and directly override the methods instead of consuming events. Therefore, we need to
|
||||
* extend the platform classes to provide some changes for TYPO3 database schema operations.
|
||||
*
|
||||
* Note: Albeit empty, we keep it now. Future refactoring may add stuff here, for example columnEquals() modifications.
|
||||
*
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
class SQLitePlatform extends DoctrineSQLitePlatform
|
||||
{
|
||||
use GetColumnDeclarationSQLCommentTypeAwareTrait;
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform\Traits;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDBPlatform;
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\SQLitePlatform;
|
||||
use Doctrine\DBAL\Types\GuidType;
|
||||
use Doctrine\DBAL\Types\JsonType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
|
||||
/**
|
||||
* This trait provides some methods to restore removed behaviour of Doctrine DBAL within the extended
|
||||
* {@see AbstractPlatform} hierarchy.
|
||||
*
|
||||
* Related code places code has been taken from or adopted for it:
|
||||
*
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Platforms/AbstractPlatform.php#L555-L572
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Platforms/AbstractPlatform.php#L574-L597
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Types/Type.php#L275-L295
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Types/JsonType.php#L80-L95
|
||||
*/
|
||||
trait GetColumnDeclarationSQLCommentTypeAwareTrait
|
||||
{
|
||||
/**
|
||||
* Note that this provides a method override to combine type based comments with the column comment on platforms.
|
||||
*
|
||||
* Obtains DBMS specific SQL code portion needed to declare a generic type
|
||||
* column to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy.
|
||||
*
|
||||
* @param string $name The name the column to be declared.
|
||||
* @param mixed[] $column An associative array with the name of the properties
|
||||
* of the column being declared as array indexes. Currently, the types
|
||||
* of supported column properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* column. If this argument is missing the column should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
* default
|
||||
* Text value to be used as default for this column.
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this column is constrained
|
||||
* to not be set to null.
|
||||
* charset
|
||||
* Text value with the default CHARACTER SET for this column.
|
||||
* collation
|
||||
* Text value with the default COLLATION for this column.
|
||||
* columnDefinition
|
||||
* a string that defines the complete column
|
||||
*
|
||||
* @return string DBMS specific SQL code portion that should be used to declare the column.
|
||||
*/
|
||||
public function getColumnDeclarationSQL(string $name, array $column): string
|
||||
{
|
||||
return parent::getColumnDeclarationSQL($name, $this->addTypeCommentIfNeeded($column));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add type comment (`DC2Type:<TypeName>`) to column comment if required.
|
||||
*
|
||||
* Adopted from Doctrine DBAL 3.9:
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Platforms/AbstractPlatform.php#L555-L572
|
||||
* returning comment addition for column comment.
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Platforms/AbstractPlatform.php#L574-L597
|
||||
* adding the type comment to column comment, if overall type comments has not been disabled (not the case for TYPO3)
|
||||
* and the column type method `requiresSQLCommentHint()` returned true for that type and platform, which no longer
|
||||
* exits and are now simplified processed with {@see self::typeRequiresCommentHint()}.
|
||||
*/
|
||||
private function addTypeCommentIfNeeded(array $column): array
|
||||
{
|
||||
if ($this->typeRequiresCommentHint($column['type'])) {
|
||||
$column['comment'] .= '(DC2Type:' . Type::lookupName($column['type']) . ')';
|
||||
}
|
||||
return $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform specific type selection requiring column comment type specification.
|
||||
*
|
||||
* Up to Doctrine DBAL v3, this has been handled throughout various places, for example using the removed
|
||||
* `requiresSQLCommentHint()` method on DoctrineType implementations.
|
||||
* https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Types/Type.php#L275-L295 for
|
||||
* the basic implementation, where each type could override that method.
|
||||
*
|
||||
* Instead of extending all types to restore that behaviour, a mapping logic is now added with that method,
|
||||
* for example:
|
||||
* - https://github.com/doctrine/dbal/blob/61446f07fcb522414d6cfd8b1c3e5f9e18c579ba/src/Types/JsonType.php#L80-L95
|
||||
*/
|
||||
private function typeRequiresCommentHint(Type $type): bool
|
||||
{
|
||||
$map = [
|
||||
SQLitePlatform::class => [
|
||||
JsonType::class,
|
||||
GuidType::class,
|
||||
],
|
||||
MariaDBPlatform::class => [
|
||||
GuidType::class,
|
||||
],
|
||||
MySQLPlatform::class => [
|
||||
GuidType::class,
|
||||
],
|
||||
];
|
||||
foreach ($map as $platformClass => $platformTypes) {
|
||||
if (!$this instanceof $platformClass) {
|
||||
continue;
|
||||
}
|
||||
foreach ($platformTypes as $platformType) {
|
||||
if ($type instanceof $platformType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform\Traits;
|
||||
|
||||
use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform;
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform;
|
||||
use Doctrine\DBAL\Schema\TableDiff as DoctrineTableDiff;
|
||||
use TYPO3\CMS\Core\Database\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* `doctrine/dbal` does not support handling engine options directly. This trait in combination with extended
|
||||
* platform classes substitutes the deprecated `doctrine/event-manager` approach to influence database schema
|
||||
* related comparison and DDL handling.
|
||||
*
|
||||
* @internal shared code for extended MySQL and MariDB platform doctrine classes.
|
||||
*/
|
||||
trait MySQLCompatibleAlterTablePlatformAwareTrait
|
||||
{
|
||||
/**
|
||||
* @param TableDiff|DoctrineTableDiff $tableDiff
|
||||
* @param list<string> $result
|
||||
* @return list<string>
|
||||
*/
|
||||
protected function getCustomAlterTableSQLEngineOptions(DoctrineMariaDBPlatform|DoctrineMySQLPlatform $platform, TableDiff|DoctrineTableDiff $tableDiff, array $result): array
|
||||
{
|
||||
// Original Doctrine TableDiff without table options, continue default processing
|
||||
if (!$tableDiff instanceof TableDiff) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// No changes in table options, continue default processing
|
||||
if (count($tableDiff->getTableOptions()) === 0) {
|
||||
return $result;
|
||||
}
|
||||
$options = '';
|
||||
|
||||
if ($tableDiff->hasTableOption('engine')) {
|
||||
$options .= ' ENGINE = ' . $tableDiff->getTableOption('engine');
|
||||
}
|
||||
|
||||
if ($tableDiff->hasTableOption('row_format')) {
|
||||
$options .= ' ROW_FORMAT = ' . $tableDiff->getTableOption('row_format');
|
||||
} elseif ($tableDiff->hasTableOption('engine') && $tableDiff->getOldTable()->hasOption('row_format')) {
|
||||
// Ensure ROW_FORMAT is always explicitly applied if ENGINE is changed,
|
||||
// as "old" CREATE TABLE ROW_FORMAT options are cached and are re-applied if ENGINE is changed
|
||||
// (which would result in a "Wrong create options" error if MyISAM/FIXED is tried to be changed to InnoDB(+implicit FIXED)
|
||||
//
|
||||
// See https://bugs.mysql.com/bug.php?id=26214#c104034 into account:
|
||||
// > Row_format column in SHOW TABLE STATUS shows the actual row format of the table.
|
||||
// > Create_options in SHOW TABLE STATUS and SHOW CREATE TABLE show the options (including row format) that you specified at CREATE TABLE time.
|
||||
// >
|
||||
// > The original options are preserved because you may do ALTER TABLE ... ENGINE= and change the storage engine of the table, and a new storage
|
||||
// > engine may support the row format that you specified back then during CREATE TABLE.
|
||||
$options .= ' ROW_FORMAT = ' . $tableDiff->getOldTable()->getOption('row_format');
|
||||
}
|
||||
|
||||
if ($tableDiff->hasTableOption('charset')) {
|
||||
$options .= ' DEFAULT CHARACTER SET = ' . $tableDiff->getTableOption('charset');
|
||||
}
|
||||
if ($tableDiff->hasTableOption('collation')) {
|
||||
$options .= ' COLLATE = ' . $tableDiff->getTableOption('collation');
|
||||
}
|
||||
|
||||
// Add an ALTER TABLE statement to change the table engine to the list of statements.
|
||||
if ($options !== '') {
|
||||
$quotedTableName = $tableDiff->getOldTable()->getQuotedName($platform);
|
||||
$result[] = 'ALTER TABLE ' . $quotedTableName . $options;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
namespace TYPO3\CMS\Core\Database\Platform\Traits;
|
||||
|
||||
use Doctrine\DBAL\Types;
|
||||
|
||||
/**
|
||||
* @internal not part of Public Core API.
|
||||
*/
|
||||
trait MySQLDefaultValueDeclarationSQLOverrideTrait
|
||||
{
|
||||
/**
|
||||
* Obtains DBMS specific SQL code portion needed to set a default value
|
||||
* declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* Oracle MySQL does not support default values on TEXT/BLOB columns until 8.0.13. Doctrine DBAL 4.x supports
|
||||
* earlier version of MySQL and decided to unset the column default value for TextType and BlobType generally
|
||||
* in the MySQL platform variants. This trait reintroduces the AbstractPlatform implementation to be used in
|
||||
* the TYPO3 platform overrides for MySQL to remove this limitation and allow the use of default value as
|
||||
* expressions.
|
||||
*
|
||||
* @see \Doctrine\DBAL\Platforms\MySQLPlatform::getDefaultValueDeclarationSQL()
|
||||
*
|
||||
* @param mixed[] $column The column definition array.
|
||||
*
|
||||
* @return string DBMS specific SQL code portion needed to set a default value.
|
||||
*/
|
||||
public function getDefaultValueDeclarationSQL(array $column): string
|
||||
{
|
||||
$type = $column['type'] ?? null;
|
||||
|
||||
// MySQL 8.0.13+ supports default for TEXT and BLOB fields only as expression, so we need to handle this
|
||||
// here properly for valid default value types.
|
||||
if ($type instanceof Types\TextType || $type instanceof Types\JsonType || $type instanceof Types\BlobType) {
|
||||
if (! isset($column['default'])) {
|
||||
return empty($column['notnull']) ? ' DEFAULT (NULL)' : '';
|
||||
}
|
||||
$default = $column['default'];
|
||||
if (is_int($default) || is_float($default)) {
|
||||
return ' DEFAULT (' . $default . ')';
|
||||
}
|
||||
return ' DEFAULT (' . $this->quoteStringLiteral($default) . ')';
|
||||
}
|
||||
|
||||
if (! isset($column['default'])) {
|
||||
return empty($column['notnull']) ? ' DEFAULT NULL' : '';
|
||||
}
|
||||
|
||||
$default = $column['default'];
|
||||
|
||||
if (! isset($column['type'])) {
|
||||
return " DEFAULT '" . $default . "'";
|
||||
}
|
||||
|
||||
if ($type instanceof Types\PhpIntegerMappingType) {
|
||||
return ' DEFAULT ' . $default;
|
||||
}
|
||||
|
||||
if ($type instanceof Types\PhpDateTimeMappingType && $default === $this->getCurrentTimestampSQL()) {
|
||||
return ' DEFAULT ' . $this->getCurrentTimestampSQL();
|
||||
}
|
||||
|
||||
if ($type instanceof Types\PhpTimeMappingType && $default === $this->getCurrentTimeSQL()) {
|
||||
return ' DEFAULT ' . $this->getCurrentTimeSQL();
|
||||
}
|
||||
|
||||
if ($type instanceof Types\PhpDateMappingType && $default === $this->getCurrentDateSQL()) {
|
||||
return ' DEFAULT ' . $this->getCurrentDateSQL();
|
||||
}
|
||||
|
||||
if ($type instanceof Types\BooleanType) {
|
||||
return ' DEFAULT ' . $this->convertBooleans($default);
|
||||
}
|
||||
|
||||
if (is_int($default) || is_float($default)) {
|
||||
return ' DEFAULT ' . $default;
|
||||
}
|
||||
|
||||
return ' DEFAULT ' . $this->quoteStringLiteral($default);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user