Skip to content

Commit

Permalink
[TASK] Raise doctrine/dbal:^4.1
Browse files Browse the repository at this point in the history
The Doctrine Team recently released minor version
release `4.1.0` including a couple of bugfixes,
internal changes and also new features [1].

The aforementioned internal changes introduces
breaking stuff within internal implementation,
for example the TYPO3 Database Analyzer stack
enforcing adoption [2][3][4]. Sadly, it's not
possible to provide backwards compatible code
and thus minimum version raise is "absolutly"
required.

Doctrine DBAL 4.1.0 also includes new platform
implementation for some database platforms and
this change adds them as extend replacements
to ensure working state with TYPO3 DB Analyzer.

Note that previous TYPO3 v13.x composer instances
needs to limit doctrine/dbal to 4.0.x on their own
to avoid breaking behaviour.

Used command(s):

\
  composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^4.1" \
  && composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^4.1" \
  && composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^4.1" \
  && composer require "doctrine/dbal":"^4.1"

[1] https://github.com/doctrine/dbal/releases/tag/4.1.0
[2] doctrine/dbal#6280
[3] doctrine/dbal#6482
[4] doctrine/dbal#6490

Resolves: #104628
Releases: main
Change-Id: I53c86feed17abc6a90625e27fb135f606a57fc9f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85620
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Kienast <a.fernandez@scripting-base.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Andreas Kienast <a.fernandez@scripting-base.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
sbuerk committed Aug 15, 2024
1 parent a585626 commit 72b3729
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 158 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"bacon/bacon-qr-code": "^3.0",
"christian-riesen/base32": "^1.6",
"doctrine/annotations": "^1.13.3 || ^2.0",
"doctrine/dbal": "^4.0.2",
"doctrine/dbal": "^4.1",
"doctrine/event-manager": "^2.0",
"doctrine/instantiator": "^1.5 || ^2.0",
"doctrine/lexer": "^3.0",
Expand Down
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions typo3/sysext/core/Classes/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use Doctrine\DBAL\Exception as DbalException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform;
Expand Down Expand Up @@ -332,24 +331,6 @@ public function count(string $item, string $tableName, array $identifiers): int
return (int)$query->executeQuery()->fetchOne();
}

/**
* Returns the version of the current platform if applicable.
*
* If no version information is available only the platform name will be shown.
* If the platform name is unknown or unsupported the driver name will be shown.
*
* @internal only and not part of public API.
*/
public function getServerVersion(): string
{
try {
return parent::getServerVersion();
} catch (DbalException) {
}
// Return empty server version due to database connection error.
return '';
}

/**
* Returns the version of the current platform if applicable, containing the platform as prefix.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@

use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDB1010Platform as DoctrineMariaDB1010Platform;
use Doctrine\DBAL\Platforms\MariaDB1052Platform as DoctrineMariaDB1052Platform;
use Doctrine\DBAL\Platforms\MariaDB1060Platform as DoctrineMariaDB1060Platform;
use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQL80Platform as DoctrineMySQL80Platform;
use Doctrine\DBAL\Platforms\MySQL84Platform as DoctrineMySQL84Platform;
use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform as DoctrinePostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform as DoctrineSQLitePlatform;
use Doctrine\DBAL\ServerVersionProvider;
use TYPO3\CMS\Core\Database\Platform\MariaDB1010Platform as Typo3MariaDB1010Platform;
use TYPO3\CMS\Core\Database\Platform\MariaDB1052Platform as Typo3MariaDB1052Platform;
use TYPO3\CMS\Core\Database\Platform\MariaDB1060Platform as Typo3MariaDB1060Platform;
use TYPO3\CMS\Core\Database\Platform\MariaDBPlatform as Typo3MariaDBPlatform;
use TYPO3\CMS\Core\Database\Platform\MySQL80Platform as Typo3MySQL80Platform;
use TYPO3\CMS\Core\Database\Platform\MySQL84Platform as Typo3MySQL84Platform;
use TYPO3\CMS\Core\Database\Platform\MySQLPlatform as Typo3MySQLPlatform;
use TYPO3\CMS\Core\Database\Platform\PostgreSQLPlatform as Typo3PostgreSQLPlatform;
use TYPO3\CMS\Core\Database\Platform\SQLitePlatform as Typo3SQLitePlatform;
Expand Down Expand Up @@ -58,9 +62,11 @@ private function elevatePlatform(AbstractPlatform $platform): AbstractPlatform
return match ($platform::class) {
DoctrineMySQLPlatform::class => new Typo3MySQLPlatform(),
DoctrineMySQL80Platform::class => new Typo3MySQL80Platform(),
DoctrineMySQL84Platform::class => new Typo3MySQL84Platform(),
DoctrineMariaDBPlatform::class => new Typo3MariaDBPlatform(),
DoctrineMariaDB1052Platform::class => new Typo3MariaDB1052Platform(),
DoctrineMariaDB1060Platform::class => new Typo3MariaDB1060Platform(),
DoctrineMariaDB1010Platform::class => new Typo3MariaDB1010Platform(),
DoctrineSQLitePlatform::class => new Typo3SQLitePlatform(),
DoctrinePostgreSQLPlatform::class => new Typo3PostgreSQLPlatform(),
default => $platform,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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\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 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));
}
}
48 changes: 48 additions & 0 deletions typo3/sysext/core/Classes/Database/Platform/MySQL84Platform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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\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 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));
}
}
Loading

0 comments on commit 72b3729

Please sign in to comment.