FriendsOfTYPO3/content-blocks

TYPO3 12 (composer) crashes when clearing system cache (custom FlexForm fields not recognized)

Closed this issue · 6 comments

Using TYPO3 12, installed with composer it seems not to be possible to use custom fields, defined als FlexForm anymore.
After either clicking the function to flush the system's cache in the backend of using the command line version of it, TYPO3 crashes with an exception:

PHP Warning: Undefined array key "name_of_the_custom_field" in /var/www/web-sector27/data/sc27-typo3-installation/vendor/contentblocks/content-blocks/Classes/Generator/TcaGenerator.php line 620

Using the same version 0.7.7 of "content_blocks" with a legacy TYPO3 12 installation and the same site package, there are no crashes occurring.

After manually using the typo3 console command with the "extension:setup" parameter, TYPO3 works again without the exception until the next time the cache ist cleared.
Because of the exception the TYPO3 backend module "Analyze Database Structure" crashes even without clearing the system cache manually (it seems to clear the cache indirectly).

When trying to debug the problem within the function "TcaGenerator.php::processExistingFlexForm()", there are is not a single of my defined custom fields listed!
In the TYPO3 12 legacy installation, all fields are available within the array.

All custom fields are defined in the file "Configuration/TCA/Overrides/tt_content.php" of the same extension (site package) where my content_blocks definitions are defined.
In the content_blocks definition, the option "useExistingField" is set to true.
Within the composer.json of my site package, the "content_blocks" extension is listed as to be required as well as in the project composer.json.

Changing the order of the TYPO3 extension within the project's "composer.json" (content_blocks first, own site package afterwards) and the removing the requirement from the site package's "composer.json" seems to do the trick. Now it works again (hopefully for ever).

Thanks for reporting this issue. I re-opened this tickets as it seems to be a real problem re-using FlexForm fields defined in other extensions TCA/Overrides. Problem: TcaGenerator depends on config option ds_pointerField which is not available at that point. You probably fixed it by changing the loading order of the extensions so that the site package is loaded before Content Blocks. But this means you can't override TCA of Content Blocks anymore. I need to think about this situation. Re-using pi_flexform is no problem however as it is defined in base TCA setup, not in overrides.

@tntrpsw How does your custom FlexForm field look like? Do you make use of ds_pointerfield or do you just define default ?

Here the FlexForm config from within the "TCA/Overrides/tt_content.php" file:

'type' => 'flex',
'ds_pointerField' => 'list_type',
'ds' => [
'default' => 'FILE:EXT:name_of_the_sitepackage/Configuration/FlexForm/FilenameOfTheFlexForm.xml',
],

Actually I'm not sure, if the definition of the option "ds_pointerField" is really defined the right, but it works with TYPO3 versions 10, 11 (without "content_blocks") and 12 (with and without "content_blocks"). The field is being used within every content element.

@tntrpsw Ah, thank you. Looks like ds_pointerField is not needed in your case, as you only define "default". The problem is, right now Content Blocks just overrides your "default". Does this not break other usages of this field for you?

@tntrpsw Ok, I could reproduce your error and added compatibility for this use-case. Please add Content Blocks back as requirement for your site package and remove ds_pointerField from your FlexForm config as it is not used.