Project

General

Profile

Actions

Bug #105897

closed

Usage of Exception getPrevious() in DataHandler may throw excpeption

Added by Sybille Peters 7 days ago. Updated about 2 hours ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2025-01-07
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

exception.png (55.8 KB) exception.png Sybille Peters, 2025-01-07 15:17

Related issues 2 (2 open0 closed)

Related to TYPO3 Core - Bug #105565: Call to a member function getMessage() on null in Typo3DbBackend.phpUnder ReviewLina Wolf2024-11-11

Actions
Related to TYPO3 Core - Task #105919: Evaluate all Doctrine DBAL ExceptionsNew2025-01-13

Actions
Actions #1

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

Actions #2

Updated by Garvin Hicking 1 day ago

  • Related to Bug #105565: Call to a member function getMessage() on null in Typo3DbBackend.php added
Actions #3

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

Actions #4

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

Actions #5

Updated by Benni Mack 1 day ago

  • Related to Task #105919: Evaluate all Doctrine DBAL Exceptions added
Actions #6

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

Actions #7

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

Actions #8

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

Actions #9

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

Actions #10

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

Actions #11

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

Actions #12

Updated by Christian Kuhn about 2 hours ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF