#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 <span data-processor="relativetime" data-value="2025-06-02T21:05:19+00:00" > 06/02/25, 21:05 </span> -
Reto Gehrig commented and changed attached ImportRoutesSiteConfiguration.php attached Routes.yaml attached config.yaml <span data-processor="relativetime" data-value="2025-06-03T05:47:34+00:00" > 06/03/25, 05:47 </span>
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 <span data-processor="relativetime" data-value="2025-06-03T10:00:59+00:00" > 06/03/25, 10:00 </span>
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 <span data-processor="relativetime" data-value="2025-06-03T14:58:50+00:00" > 06/03/25, 14:58 </span>
(Note to self: reproduce and change docs for this on github)
-
Garvin Hicking changed assigned to Garvin Hicking <span data-processor="relativetime" data-value="2025-06-03T14:59:01+00:00" > 06/03/25, 14:59 </span>
-
Reto Gehrig commented <span data-processor="relativetime" data-value="2025-06-03T18:07:54+00:00" > 06/03/25, 18:07 </span>
I have now solved it with the function ArrayUtility::mergeRecursiveWithOverrule($configuration, $settingsConfiguration).
-
Garvin Hicking commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2025-06-06T06:38:35+00:00" > 06/06/25, 06:38 </span>Thanks 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 )