Project

General

Profile

Actions

Bug #104963

open

Undefined array key 0 exception in FullRecordContainer

Added by Franz Holzinger about 1 month ago. Updated 8 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2024-09-13
Due date:
% Done:

0%

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

Description

The opening of IRRE records ends in an Exception:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1476107295: PHP Warning: Undefined array key 0 in /path/typo3_src-13.2.1.test/typo3/sysext/backend/Classes/Form/Container/FullRecordContainer.php line 47 | TYPO3\CMS\Core\Error\Exception thrown in file /path/typo3_src-13.2.1.test/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 138. Requested URL: https://demo13.website.com/typo3/ajax/record/inline/details?token=--AnonymizedToken--

Files

Product-Article-Relation-IRRE.png (85.6 KB) Product-Article-Relation-IRRE.png relation of product to many articles Franz Holzinger, 2024-09-13 18:29
empty-field-array-in-full-record-container.json (208 KB) empty-field-array-in-full-record-container.json file_put_contents of $this->data Franz Holzinger, 2024-09-30 16:21
Actions #1

Updated by Garvin Hicking about 1 month ago

  • Status changed from New to Needs Feedback

Thanks for the report!

Can you please provide a minimal example to reproduce this, mabye using EXT:styleguide as an example? What do I need to click where to reproduce it?

Actions #2

Updated by Franz Holzinger about 1 month ago

You can reproduce this in tt_products. Create a product and some articles inside of the IRRE relation of the product.

Actions #3

Updated by Garvin Hicking about 1 month ago

Thanks for the feedback. If you are able to provide a smaller, isolated example at some point, we might be able to help. tt_products is too big and loaded with dependencies we cannot properly debug within reasonable time.

Actions #4

Updated by Stefan Bürk about 1 month ago

I guess we could here add an early check if the expolded array does not contain any elements:

https://github.com/TYPO3/typo3/blob/35c9b96336d8644b52ef9045969a47475f559da5/typo3/sysext/backend/Classes/Form/Container/FullRecordContainer.php#L44

        $fieldsArray = GeneralUtility::trimExplode(',', $itemList, true);
// add here a $fieldsArray === [] check and return early - or ensure that handling below is guarded properly
        // Streamline the fields array
        // First, make sure there is always a --div-- definition for the first element
        if (!str_starts_with($fieldsArray[0], '--div--')) {
            array_unshift($fieldsArray, '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general');

Thanks for reportng this. Not sure how this occured or can be reproduced, but guarding that make sense I guess.

Actions #5

Updated by Garvin Hicking about 1 month ago

Unsure about this. The rest of the method really expects that fieldArray contains information. The method returns something vital which an 'early return' IMO would break.

This kind of sounds to me like a TCA misconfiguration issue. I think we need an EXT:styleguide reproducible example for it first.

Actions #6

Updated by Stefan Bürk about 1 month ago

Garvin Hicking wrote in #note-5:

Unsure about this. The rest of the method really expects that fieldArray contains information. The method returns something vital which an 'early return' IMO would break.

This kind of sounds to me like a TCA misconfiguration issue. I think we need an EXT:styleguide reproducible example for it first.

ack. should not investigate such things laying tired on hells floor - being there now again ;)

@Franz Holzinger

Could you please fully dump / save the content of $this->data before the `if (!str_starts_with(....` when $fieldArray is an empty array ?

Something like

$fieldsArray = GeneralUtility::trimExplode(',', $itemList, true);

//--------------------------------------
file_put_contents(
  \TYPO3\CMS\Core\Core\Environment::getVarPath() . '/empty-field-array-in-full-record-container.json',
  \json_encode($this->data, JSON_PRETTY_PRINT),
);
//--------------------------------------

if (!str_starts_with($fieldsArray[0], '--div--')) {

at this place: https://github.com/TYPO3/typo3/blob/35c9b96336d8644b52ef9045969a47475f559da5/typo3/sysext/backend/Classes/Form/Container/FullRecordContainer.php#L44

Actions #8

Updated by Benni Mack 20 days ago

Hey Franz,

you can actually fix this by using this configuration in your parent table when defining the type=inline:

'appearance' => [
'collapseAll' => 1,
]

if you don't have any visible fields in your child table, then collapseAll should be sufficient

Actions #9

Updated by Franz Holzinger 20 days ago · Edited

@Benni Mack :

I have tried it out:

'article_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:' . $extensionKey . $languageSubpath . 'locallang_db.xlf:' . $table . '.article_uid',
'config' => [
'type' => 'inline',
'appearance' => [
'collapseAll' => true,
// 'newRecordLinkAddTitle' => true,
// 'useCombination' => true,
],
'foreign_table' => 'tt_products_products_mm_articles',
'foreign_field' => 'uid_local',
'foreign_sortby' => 'sorting',
'foreign_label' => 'uid_foreign',
'foreign_selector' => 'uid_foreign',
'foreign_unique' => 'uid_foreign',
'maxitems' => 1000,
'default' => 0,
],
],

No difference. There is still the same error message.

Actions #10

Updated by Franz Holzinger 9 days ago

Actions #11

Updated by Benni Mack 8 days ago

Thanks, I suggest closing this ticket now, and actually adding some information to docs.typo3.org that showitem should include at least one field. OK?

Actions #12

Updated by Franz Holzinger 8 days ago

It would be more helpful if TYPO3 could warn about this (log file or somewhere else) or even throw an exception in such a case like this one.

Actions

Also available in: Atom PDF