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
54 stars 17 forks source link

[SOLVED] missing required type on T3 V13.2 with CB Branch typo3-v13 #215

Closed APM-Thomas-Hempel closed 1 week ago

APM-Thomas-Hempel commented 1 month ago

Ahoi,

I try to set up a V13 with Content Blocks and I found that the "typo3-v13" branch is supposed to be the one that will become the official cms/ package. So I used that one for my setup.

But I get an error when I use the built in Basics like TYPO3/Header.

The field "header" is missing the required "type" in Content Block "contents/textmedia".

ddev typo3 cache:flush -g system && ddev typo3 extension:setup --extension=contents

  [ InvalidArgumentException ]                                                              
  The field "header" is missing the required "type" in Content Block "contents/textmedia".  

cache:flush [-g|--group [GROUP]]

Failed to run typo3 cache:flush -g system: exit status 255

My EditorInterface.yaml looks like this:

name: contents/textmedia
title: Textmedia
description: "Description for Content Element Textmedia"
group: common
prefixFields: true
prefixType: vendor
fields:

  - identifier: TYPO3/Header
    type: Basic

  - identifier: bodytext
    type: Textarea
    enableRichtext: true
    useExistingField: true

  - identifier: assets
    useExistingField: true
    type: File
    allowed: common-image-types
    minitems: 1
    maxitems: 1

I also have another issue, where it would not find my own Basics because they where not registered. Not sure if those things are related. The entire setup is working in a T3V12 with CB 0.6.4

nhovratov commented 1 month ago

Are you on a classic or composer installation?

nhovratov commented 1 month ago

Can you try it again with the v0.8.0 release? In my local installation I don't get any errors.

APM-Thomas-Hempel commented 1 month ago

Yes it's a composer install, and no the 0.8.0 still has this issue.

I can work around this if I add the type to all fields in the Header Basic. So I guess something has changed that determines the default if no type is set!?

I get this error in the backend as well. For example when I open any page in the page module.

Unfortunately I don't have the time right now to dig deeper into this. Let me know if I can help with any further information.

I will try to create a demo project to reproduce this. Maybe it's some weird side-effect in my project.

nhovratov commented 1 month ago

I also suspect a side effect in your project setup. Maybe some TCA override or loading order issue. But it's weird, as the TCA for "header" should always be available. Does this occur only in the console or also in the backend?

nhovratov commented 1 month ago

Thomas found out the error on TYPO3 camp Hamburg today: The problem was a call to IconRegistry in ext_localconf.php. Content Blocks extends dependency injection of this class. However, when called before TCA is ready, the error stated here occurs.

A solution would be to move the icon registration after "BootCompleted" event. At this point TCA is available and Content Blocks can be compiled. This is the way it is done in v0.7/TYPO3v12.

We can of course also force our users to use Configuration/Icons.php instead. But third-party extensions can still do it, which will break it again. So this is not an alternative.

Edit: I've thought about it and actually it would be better to force extension authors to register icons properly. Either via Icons.php or Services.php if it needs to be dynamic. The ext_localconf.php should never be used to instantiate service classes. It should only be used for static configuration calls.

nhovratov commented 3 weeks ago

I want to deprecate and eventually get rid of IconRegistry in ext_localconf.php. See: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85662