Bug #95978
open
DataHandler does not catch errors in database query
Added by Jan Delius about 3 years ago.
Updated almost 3 years ago.
Category:
DataHandler aka TCEmain
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
By briefly looking into the code, we might use \Doctrine\DBAL\Driver\AbstractException
instead...
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!
Oliver Hader wrote in #note-1:
By briefly looking into the code, we might use \Doctrine\DBAL\Driver\AbstractException
instead...
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\AbstractException
is marked as internal. As far as I understand the comments in the code correctly, one should use the interface Doctrine\DBAL\Driver\Exception
. This will catch the corresponding error message.
I must have specified the wrong class ( \Exception
) in the original ticket.
Also available in: Atom
PDF