nhovratov / content-blocks

TYPO3 CMS Content Blocks - Content Types API
https://docs.typo3.org/p/contentblocks/content-blocks/main/en-us/
GNU General Public License v2.0
55 stars 17 forks source link

Using existing fields of type group with internal_type folder fails with an exception #209

Closed mediaessenz closed 3 weeks ago

mediaessenz commented 3 months ago

To reproduce create a content block (content element) with the following yaml config:

name: vendor/test
group: common
fields:
  - identifier: file_folder
    useExistingField: true

The field file_folder in this example come from EXT:bootrap_package and has this old school, but under TYPO3 12 still valid TCA configuration:

$GLOBALS['TCA']['tt_content']['columns']['file_folder'] = [
    'exclude' => true,
    'label' => 'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:field.file_folder',
    'config' => [
        'type' => 'group',
        'internal_type' => 'folder',
    ]
];

This is the producted exception in the backend:

(1/1) TypeError
TYPO3\CMS\ContentBlocks\DataProcessing\RelationResolver::getRelations(): Argument #2 ($tableList) must be of type string, null given, called in /var/www/html/vendor/contentblocks/content-blocks/Classes/DataProcessing/RelationResolver.php on line 167

It seems that this backport is not able to handle this old school definition of the newly TYPO3 12 TCA type "folder".

One more thing I realized during debugging is, that the TCA inspector of the TYPO3 Backend shows this field config:

file_folder
  config
    internal_type = folder
    type = folder
  exclude = 1
  label = file_folder

It seems there is some "streamlining on the flow" inside TYPO3 which changes the type group to folder but this seems to happen after content_block reads the tca.

nhovratov commented 3 months ago

Ah, yeah TYPO3's TCA migration happens at the very end, after Content Blocks checks the TCA type. But you can simply define the type beforehand, when you know it:

fields:
  - identifier: file_folder
    useExistingField: true
    type: Folder

You should do this anyway, if the re-used field is defined in TCA/Overrides of another extension: https://docs.typo3.org/p/contentblocks/content-blocks/main/en-us/Guides/ReuseExistingFields/Index.html#reusing-custom-fields

Let me know, if this works.

mediaessenz commented 3 months ago

Nope, but this works for me:

fields: 
  - identifier: file_folder
    type: Folder
    prefixField: false
nhovratov commented 3 months ago

But this would cause the TCA and SQL generation of this field, which we don't want as it is already there. What happens if you use the other way?

mediaessenz commented 3 months ago

I get the exception again.

Just look in the discussion at slack I had with André Kraus today

nhovratov commented 3 months ago

Okay, this might be really a bug then. Thanks. I will investigate.

nhovratov commented 3 weeks ago

Fixed for the v13 version.

RelationResolver is now a Core feature and based on TcaSchema with migrated TCA.