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 <[email protected]>
Reviewed-by: Andreas Kienast <[email protected]>
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Andreas Kienast <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
  • Loading branch information
sbuerk committed Aug 15, 2024
1 parent f4f8ed7 commit 3e942de
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 141 deletions.
19 changes: 0 additions & 19 deletions 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
6 changes: 6 additions & 0 deletions Classes/Database/Driver/CustomPlatformDriverDecorator.php
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
46 changes: 46 additions & 0 deletions Classes/Database/Platform/MariaDB1010Platform.php
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 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 3e942de

Please sign in to comment.