Bug #101805
closedPHP deprecation error in BackendUtility::getProcessedValue()
100%
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.
Updated by Christian Kuhn 8 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).
Updated by Gerrit Code Review 8 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
Updated by Gerrit Code Review 8 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
Updated by Gerrit Code Review 8 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
Updated by Gerrit Code Review 8 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
Updated by Anonymous 8 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 385fd74f459b1351027013f07379c19756e1da0d.