#95978DataHandler does not catch errors in database query
Description
In the DataHandler, an attempt is made to catch a DBALException when inserting or updating an existing entry. This class is deprecated, the code itself states that you should use \Exception. If I replace the catch block in the PHP code, the errors are caught again when executing the database query and the DataHandler notices that there was an error.
Example error that should be catched:
[Doctrine\DBAL\Driver\Mysqli\Exception\StatementError] Incorrect integer value: '' for column `typo3`.`tx_myext_domain_model_mymodel`.`number` at row 1
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 4
-
Jan Delius commented <span data-processor="relativetime" data-value="2021-11-16T11:59:34+00:00" > 11/16/21, 11:59 </span>
Oliver Hader wrote in #note-1:
> By briefly looking into the code, we might use\Doctrine\DBAL\Driver\AbstractExceptioninstead…
> However, since you have been working on code already, can you please share your current result – either on review.typo3.org or by simply adding a patch-file to this ticket? Thanks in advance!Unfortunately, I don’t have a clean system at the moment in which I could create or push a patch. However, the class
\Doctrine\DBAL\Driver\AbstractExceptionis marked as internal. As far as I understand the comments in the code correctly, one should use the interfaceDoctrine\DBAL\Driver\Exception. This will catch the corresponding error message.I must have specified the wrong class (
\Exception) in the original ticket. -
Jan Delius commented <span data-processor="relativetime" data-value="2022-02-08T09:33:44+00:00" > 02/08/22, 09:33 </span>
After closer investigation I came to the following conclusion: The “error” only occurs when “doctrine/dbal” is used in version 2.13.x. In 3.3.x (which is used in the branch main) a
Doctrine\DBAL\Driver\Exceptionis converted to aDoctrine\DBAL\Exception\DriverExceptioninsideDoctrine\DBAL\Connection. This “new” class extends the old exception and implements the Driver\Exception interface.As it seems, we need to catch both types of exception in the core. In the main branch everything can stay as it is.
2.13.x:
- https://github.com/doctrine/dbal/blob/5a175c9a3bd1e0f9fdfd25dfbbb509a712232f12/lib/Doctrine/DBAL/Connection.php#L1537
- https://github.com/doctrine/dbal/blob/5a175c9a3bd1e0f9fdfd25dfbbb509a712232f12/lib/Doctrine/DBAL/DBALException.php#L1773.3.x:
- https://github.com/doctrine/dbal/blob/484af342655f338dc0d279bfd112496d473fe3ec/src/Connection.php#L1163
- https://github.com/doctrine/dbal/blob/484af342655f338dc0d279bfd112496d473fe3ec/src/Connection.php#L1807
- https://github.com/doctrine/dbal/blob/484af342655f338dc0d279bfd112496d473fe3ec/src/Exception/DriverException.php#L16 -
Benni Mack commented and changed status
NewClosed <span data-processor="relativetime" data-value="2024-12-10T14:43:36+00:00" > 12/10/24, 14:43 </span>Hey Jan,
I’m gonna close this issue now, as we don’t support TYPO3 v11 anymore and it is obviously fixed in v12+.
Hope it’s OK. Benni.
By briefly looking into the code, we might use
\Doctrine\DBAL\Driver\AbstractExceptioninstead…However, since you have been working on code already, can you please share your current result – either on review.typo3.org or by simply adding a patch-file to this ticket? Thanks in advance!