Project

General

Profile

Actions

Bug #101805

closed

PHP deprecation error in BackendUtility::getProcessedValue()

Added by Georg Tiefenbrunn 10 months ago. Updated 10 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2023-08-30
Due date:
% Done:

100%

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

Description

Nullable columns of TCA type datetime (introduced in v12) cause a PHP deprecation error in record info popup if the stored value is NULL.

#1476107295 TYPO3\CMS\Core\Error\Exception
PHP Runtime Deprecation Notice: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in vendor/typo3/cms-backend/Classes/Utility/BackendUtility.php line ...

The exception is caused by passing NULL to strtotime() in BackendUtility.php:1691 (format=datetime) and BackendUtility.php:1731 (format=date).

Steps to reproduce

Add some columns of TCA type datetime:

-- ext_tables.sql

CREATE TABLE fe_users (
    `test_date` date DEFAULT NULL,
    `test_datetime` datetime DEFAULT NULL,
    `test_time` time DEFAULT NULL
);
<?php
// EXT/Configuration/TCA/Overrides/fe_users.php

defined('TYPO3') or die();

$tca = [
    'columns' => [
        'test_date' => [
            'label' => 'test_date',
            'config' => [
                'type' => 'datetime',
                'dbType' => 'date',
            ],
        ],
        'test_datetime' => [
            'label' => 'test_datetime',
            'config' => [
                'type' => 'datetime',
                'dbType' => 'datetime',
            ],
        ],
        'test_time' => [
            'label' => 'test_time',
            'config' => [
                'type' => 'datetime',
                'dbType' => 'time',
                'nullable' => true,
            ],
        ],
    ],
    'palettes' => [
        '2' => ['showitem' => 'first_name,--linebreak--,middle_name,--linebreak--,last_name,--linebreak--,test_date,test_datetime,test_time'],
    ],
];

$GLOBALS['TCA']['fe_users'] = array_replace_recursive($GLOBALS['TCA']['fe_users'], $tca);

  • Open any existing fe_users record or create a new one leaving all three test columns empty (NULL value in database).
  • Open the record info (list module → More options ... → Display information; BE route show_item) to throw the exception.
Actions #1

Updated by Christian Kuhn 10 months ago

First: Thanks for great reproduce example!

Confirmed.

Note: Check default php.ini error_reporting ... I had to set "error_reporting=E_ALL" since E_DEPRECATED was suppressed in web context for me by default (I verified this is not an issue in tests, which use E_ALL, though).

Note this would be a higher error level if BackendUtility would be strict_types=1 (which we're introducing more and more).

Actions #2

Updated by Gerrit Code Review 10 months 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/+/80792

Actions #3

Updated by Gerrit Code Review 10 months ago

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/+/80793

Actions #4

Updated by Gerrit Code Review 10 months ago

Patch set 2 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/+/80771

Actions #5

Updated by Gerrit Code Review 10 months ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80796

Actions #6

Updated by Anonymous 10 months ago

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

Also available in: Atom PDF