Issue Bug Closed

#101805PHP deprecation error in BackendUtility::getProcessedValue()

Georg Tiefenbrunn 08/30/23, 18:10 updated 07/09/24, 15:19

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.

Reviews 4

History 37

  1. Christian Kuhn commented 08/31/23, 12:13

    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).

  2. Gerrit Code Review pushed patch set 1 for main to change 80792 status New Under Review 08/31/23, 12:18

  3. Gerrit Code Review pushed patch set 1 for main to change 80793 08/31/23, 12:48

  4. Gerrit Code Review pushed patch set 2 for 12.4 to change 80771 08/31/23, 12:50

  5. Gerrit Code Review pushed patch set 1 for 11.5 to change 80796 08/31/23, 13:36

  6. Anonymous commented and changed status Under Review Resolved done 0 % 100 % 08/31/23, 13:55

    Applied in changeset commit:385fd74f459b1351027013f07379c19756e1da0d.

  7. Benni Mack changed status Resolved Closed 07/09/24, 15:19