86958[BUGFIX] Avoid $e->getPrevious() on doctrine exceptions
Commit message
Review
-
Code review CR +2 Done
- Christian Kuhn +2
- Oli Bartsch +1
- Stefan Bürk +1
-
Verified V +2 Done
- Christian Kuhn +2
- Oli Bartsch +1
- Stefan Bürk +1
- core-ci +1 CI
Issues 1
Files 9
- Build/phpstan/phpstan-baseline.neon+0 −6
- typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php+3 −11
- typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php+1 −1
- typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php+2 −2
- typo3/sysext/core/Classes/DataHandling/DataHandler.php+27 −35
- typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php12+10 −10
- typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php+1 −1
- typo3/sysext/scheduler/Classes/Task/OptimizeDatabaseTableTask.php+1 −1
- typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php+3 −3
Review log 2124
-
Oli Bartsch uploaded patch set 1 11/11/24, 19:44
-
core-ci voted on patch set 1 V +1 11/11/24, 19:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69320
-
Garvin Hicking voted on patch set 1 CR +1 V +1 11/11/24, 20:53
-
Benni Mack voted on patch set 1 CR +1 V +1 11/11/24, 22:13
-
Andreas Kienast commented on patch set 1 11/12/24, 07:15
-
Benjamin Franzke commented on patch set 1 CR -1 11/12/24, 07:19
Typo3DbBackend.php:90Why is DBALexception message ignored at all? And why did we previously assume that it has always a parent? I guess because DBALException is supposed to wrap platform exceptions. That means I guess we either workaround a doctrine bug in here or we throw these exceptions ourselves and forgot to add a parent. I think it would be good to analyze this in detail.Typo3DbBackend.php:90Replyack, was about to say the same. Just posting an additional grep output: ``` git grep "getPrevious()->getMessage" typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php: $databaseError = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/DataHandling/DataHandler.php: $databaseErrorMessage = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/DataHandling/DataHandler.php: $databaseErrorMessage = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/DataHandling/DataHandler.php: $databaseErrorMessage = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/DataHandling/DataHandler.php: $updateErrorMessage = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/DataHandling/DataHandler.php: $insertErrorMessage = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php: $result[$statement] = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php: $result[$hash] = $e->getPrevious()->getMessage(); typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php: $result[$statement] = $e->getPrevious()->getMessage(); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230766, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230767, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230768, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230769, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074485, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064721, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1481281404, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064775, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074379, $e); typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php: throw new SqlErrorException($e->getPrevious()->getMessage(), 1470231748, $e); typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php: $this->getTimeTracker()->setTSlogMessage($e->getPrevious()->getMessage()); typo3/sysext/scheduler/Classes/Task/OptimizeDatabaseTableTask.php: $e->getPrevious()->getMessage(), typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php: $sqlErrors[] = $e->getPrevious()->getMessage(); typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php: $sqlErrors[] = $e->getPrevious()->getMessage(); typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php: $dataHandler->log($table, $id, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::SYSTEM_ERROR, 'During Publishing: SQL errors happened: {reason}', -1, ['reason' => $e->getPrevious()->getMessage()]); ``` -
Benjamin Franzke commented on patch set 1 11/12/24, 07:31
Typo3DbBackend.php:90ReplyI haven't performed a test yet, but my assumption is that a `Doctrine\DBAL\Schema\Exception\TableDoesNotExist` is thrown because the table is tried to be introspected since: > 76553: [FEATURE] Introduce native JSON database field type support | https://review.typo3.org/c/Packages/TYPO3.CMS/+/76553 -
Stefan Bürk commented on patch set 1 11/12/24, 07:37
Typo3DbBackend.php:90ReplyDoctrine converts exceptions, depending on the platform (generic to concrete onces), not attaching the parent exception: ``` vendor/doctrine/dbal/src/Driver/API/*/ExceptionConverter.php (Implementation) vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php (Interface) ``` We should investigate if exception has been wrapped in old PDO driver wrapping in older versions rethrowing exceptions or if that has changed in Doctrine, but not annouced because of beeing internal implementation. -
Benjamin Franzke commented on patch set 1 11/12/24, 07:41
Typo3DbBackend.php:90Replyack, and `TableDoesNotExist` is one of those cases that is not wrapped (maybe because we use API that's considered internal?) but this shows that we should harden all cases. -
Benjamin Franzke commented on patch set 1 11/12/24, 07:45
Typo3DbBackend.php:90ReplyI think my message may be hard to understand without context: Our `insert()` wrapper calls `ensureDatabaseValueTypes()`: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/Database/Connection.php#L191 which request a table introspection: https://github.com/TYPO3/typo3/blob/42f21d4b7e2067f9a0a48f28e1ad76141063b2c3/typo3/sysext/core/Classes/Database/Connection.php#L407 …and that fails (and is not wrapped by DBAL) -
Stefan Bürk commented on patch set 1 11/12/24, 07:46
Typo3DbBackend.php:90ReplyAn insert / plain insert query on the plain doctrine connection would also throw this exception without the parent when the table does not exists. Inserting something into a table that does not exists returns an error from the database, which is converted to `TableDoesNotExists` in general. And I'd say using insert/executeStatement alonw with a insert query is not internal by doctrine. But yes, needs a global look and hardenin. Still don't get why the "parent" exception message has been used here and in other places anyway (instead of the message of the last exception). -
Lina Wolf commented on patch set 1 11/20/24, 16:15
Typo3DbBackend.php:90ReplyDo what exactly do we need to fix the issue? Are there changes required? -
Christian Kuhn commented on patch set 1 01/31/25, 10:44
Typo3DbBackend.php:90Replyi think this has been decided with #105897: ditch getPrevious() is most sane solution. i'll update the patch. -
Christian Kuhn uploaded patch set 2
CR +1V +101/31/25, 11:04 -
Christian Kuhn commented on patch set 1 01/31/25, 11:05
Typo3DbBackend.php:90ReplyDoneTypo3DbBackend.php:90ReplyDone -
Christian Kuhn voted on patch set 2 CR +1 V +1 01/31/25, 11:07
-
core-ci voted on patch set 2 V -1 01/31/25, 11:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73255
-
Christian Kuhn uploaded patch set 3
CR +1V +101/31/25, 11:17 -
Christian Kuhn voted on patch set 3 CR +1 V +1 01/31/25, 11:17
-
core-ci voted on patch set 3 V +1 01/31/25, 11:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73256
-
Stefan Bürk voted on patch set 3 CR +1 V +1 01/31/25, 11:24
-
Oli Bartsch voted on patch set 3 CR +1 V +1 01/31/25, 11:25
-
Christian Kuhn voted on patch set 3 CR +2 V +2 01/31/25, 12:25
-
Christian Kuhn merged patch set 4 01/31/25, 12:25
Typo3DbBackend.php:90