Bug #105897
closedUsage of Exception getPrevious() in DataHandler may throw excpeption
100%
Description
in v12 DataHandler line 7817:
try {
// Execute the INSERT query:
$connection->insert($table, $fieldArray);
} catch (DBALException $e) {
$insertErrorMessage = $e->getPrevious()->getMessage();
}
If an exception is thrown in insert and the "catch" block reached, Using the following line may cause another error / exception, where the original exception is no longer displayed:
$insertErrorMessage = $e->getPrevious()->getMessage();
Reason is the getPrevious() will not always return something.
- original exception: Doctrine\DBAL\Types\ConversionException: "Could not convert PHP value 1736118000 to type date. Expected one of the following types: null, string, DateTime", previous=null
- displayed Error: Call to a member function getMessage() on null
Reproduce¶
Can be reproduced, if you have configured a field with type "datetime", but the field in the database is DATE (not int) and 'dbType' => 'date' is not set, then try to create a new record in the BE.
TCA config:
'config' => [
'type' => 'datetime',
'format' => 'date',
//'dbType' => 'date',
'size' => 7,
'default' => null,
]
SQL schema:
| date_published | date | YES | | NULL |
Versions¶
- reproduced in v12
- code for v14 looks similar
Screenshot¶
Files
Updated by Gerrit Code Review 1 day ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Garvin Hicking 1 day ago
- Related to Bug #105565: Call to a member function getMessage() on null in Typo3DbBackend.php added
Updated by Gerrit Code Review 1 day ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Gerrit Code Review 1 day ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Benni Mack 1 day ago
- Related to Task #105919: Evaluate all Doctrine DBAL Exceptions added
Updated by Gerrit Code Review 1 day ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Gerrit Code Review 1 day ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Gerrit Code Review about 7 hours ago
Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Gerrit Code Review about 7 hours ago
Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87711
Updated by Gerrit Code Review about 3 hours ago
Patch set 1 for branch 13.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87762
Updated by Gerrit Code Review about 2 hours ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87763
Updated by Christian Kuhn about 2 hours ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 705b5bf51516821047b47ff0d4a1d643f35ed594.