#106813SiteConfigurationLoadedEvent
Description
I have included a YAML file for the “Enhanced Router” configuration for my extension using the “SiteConfigurationLoadedEvent”, as described in the documentation. This file is also included correctly the first time the site configuration is saved. (see screenshot 1)
After editing and saving the site configuration for the third time, an ERROR occurs:
TYPO3\CMS\Core\Configuration\Loader\YamlPlaceholderGuard::protectPlaceholders(): Argument #1 ($current) must be of type array, string given, called in /home/httpd/vhosts/mydomain.com/typo3_src-13.4.13/typo3/sysext/core/Classes/Configuration/Loader/YamlPlaceholderGuard.php on line 66
When checking the configuration in typo3 directly, the values are listed twice. (see screenshot 2)
It seems that something is being saved twice when saving.
Is this problem already known?
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 5
History 7
-
Garvin Hicking commented and changed status
NewNeeds Feedback 06/02/25, 21:05 -
Reto Gehrig commented and changed attached ImportRoutesSiteConfiguration.php attached Routes.yaml attached config.yaml 06/03/25, 05:47
I think it has something to do with the array_merge_recursive command. Attached is my event listener file, the YAML file to be included with the routing parameters, and the resulting YAML config file.
-
Oliver Hader commented 06/03/25, 10:00
Use
array_replace_recursiveinstead ofarray_merge_recursive(which will cause the duplicate keys).Besides that, the
YamlPlaceholderGuardusually is only invoked when YAML configuration shall be persisted – I was not able to spot that in the event handler. -
Garvin Hicking commented 06/03/25, 14:58
(Note to self: reproduce and change docs for this on github)
-
Garvin Hicking changed assigned to Garvin Hicking 06/03/25, 14:59
-
Reto Gehrig commented 06/03/25, 18:07
I have now solved it with the function ArrayUtility::mergeRecursiveWithOverrule($configuration, $settingsConfiguration).
-
Garvin Hicking commented and changed status
Needs FeedbackClosed 06/06/25, 06:38Thanks a lot. I’ve created a docs PR to deal with an improved example:
https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/5704
Happy for feedback there.
Could you post the full YAML you’re using? Sounds a bit like you might be using imports/placeholders there, which might trigger this?
Otherwise, the PHP array_merge_recursive might introduce duplicate keys it seems (to be safe, the full code of your event listener could help, too – assuming you’re using the one from https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Events/Events/Core/Configuration/SiteConfigurationLoadedEvent.html )