From 29b02f9bb2bac70a44cf94b757a7fddaab1b88ab Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Thu, 1 Jul 2021 22:18:52 +0200 Subject: [PATCH] [BUGFIX] Ensure sys_log.level is varchar The update wizard should make sure that the level field is migrated from integer to varchar otherwise a BE login is not possible. The Database Schema Upgrade can handle new fields properly, but for existing installations the existing "level" field is an integer and would not allow new log messages to the database. For this reason, this workaround is added. Resolves: #94460 Releases: master Change-Id: I0ccb43239970030b50c2e59e288b0d830dbc2024 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69684 Tested-by: core-ci <typo3@b13.com> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- .../sysext/install/Classes/Updates/SysLogChannel.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/typo3/sysext/install/Classes/Updates/SysLogChannel.php b/typo3/sysext/install/Classes/Updates/SysLogChannel.php index 643bd0f9a07f..15f000c79ef1 100644 --- a/typo3/sysext/install/Classes/Updates/SysLogChannel.php +++ b/typo3/sysext/install/Classes/Updates/SysLogChannel.php @@ -17,6 +17,10 @@ declare(strict_types=1); namespace TYPO3\CMS\Install\Updates; +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\ColumnDiff; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types\StringType; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\SysLog\Type; @@ -67,6 +71,14 @@ END; $statement->executeQuery([$channel, $type]); } + // Ensure the level field is a varchar, otherwise we are in trouble when logging into TYPO3 Backend. + $schema = $this->sysLogTable->getSchemaManager(); + $schema->alterTable(new TableDiff( + 'sys_log', + [], + [new ColumnDiff('level', new Column('level', new StringType(), ['length' => 10, 'default' => 'info', 'notnull' => true]))], + )); + $statement = $this->sysLogTable->prepare('UPDATE sys_log SET level = ? WHERE type = ?'); foreach (Type::levelMap() as $type => $level) { $statement->executeQuery([$level, $type]); -- GitLab