Issue Bug Closed

#109175Object of class DateTimeImmutable could not be converted to string

Xavier Perseguers 03/06/26, 08:48 updated 03/31/26, 08:09

Description

Context

I have an extension for managing concerts of my choirs. We have:

  • A program (with various musical works)
    • 1 or more concert (various dates, various locations)
      • other details such as performers associated to the corresponding concert (a solist may be another one for instance)

Program TCA has IRRE for concerts:

        'concerts' => [
            'exclude' => false,
            'label' => 'LLL:EXT:concerts/Resources/Private/Language/locallang_db.xlf:tx_concerts_domain_model_program.concerts',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_concerts_domain_model_concert',
                'foreign_field' => 'program',
                'maxitems' => 9999,
                'appearance' => [
                    'collapseAll' => 0,
                    'levelLinksPosition' => 'top',
                    'showSynchronizationLink' => 1,
                    'showPossibleLocalizationRecords' => 1,
                    'showAllLocalizationLink' => 1,
                ],
            ],
        ],

And concert, as said, has various properties such as date and location, the date is the “key” and as such as been defined as label for the record:

return [
    'ctrl' => [
        'title' => 'LLL:EXT:concerts/Resources/Private/Language/locallang_db.xlf:tx_concerts_domain_model_concert',
        'label' => 'date',
        'label_alt' => 'location',
        'label_alt_force' => true,
        'tstamp' => 'tstamp',
     ...
    'columns' => [
    ...
        'date' => [
            'exclude' => false,
            'label' => 'LLL:EXT:concerts/Resources/Private/Language/locallang_db.xlf:tx_concerts_domain_model_concert.date',
            'config' => [
                'type' => 'datetime',
                'required' => true,
                'default' => 0,
            ],
        ],

Behaviour

1. Content > Records: no problem showing the programs and the concerts
2. Editing a program record: crash with Object of class DateTimeImmutable could not be converted to string

Problem

- Seems only limited to the usage of a date as label for a record *in the context of IRRE*
- Works fine up to TYPO3 v13, running PHP 8.3
- Crash with TYPO3 v14 (main), PHP 8.5
- Crash with TYPO3 v14 (main), PHP 8.3

Stacktrace

stacktrace.png

Reviews 1

Files 2

History 35

  1. Xavier Perseguers commented and changed attached processedValue.png <span data-processor="relativetime" data-value="2026-03-06T09:05:15+00:00" > 03/06/26, 09:05 </span>

    Debugging a bit, I see the difference in BackendUtility::getRecordTitle()

    Content > Records (listing of all records)

    In that context (listing of concert records), we have ctrlLabelValue being an int:

    processedValue.png

    and thus the label of the concert is properly converted to a human-readable date and time

    IRRE

    Instead of getting the Unix timestamp of the date, the same method BackendUtility::getRecordTitle()@ is a \DateTimeImmutable and the (string) cast of the parameter causes the crash.

    I’d suggest converting to an int first in that case, with a check just as we have for is_array()

  2. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-03-06T12:25:09+00:00" > 03/06/26, 12:25 </span>

    Applied in changeset commit:b4dcdded118f2767ce1f0f090f3d3fd8787e02f2.