[BUG] Backend summary output settings are merged
Describe the bug If you create several result plugins on a TYPO3 page with different settings, then these settings are merged down in the backend output for the plugins and thus output incorrectly.
This file is the trigger: https://github.com/TYPO3-Solr/ext-solr/blob/main/Classes/Backend/SettingsPreviewOnPlugins.php
Here $this->settings is used, which would probably have to be reset with __invoke.
Alternatively, you can also add an intermediate level to $this->settings: $this->settings[$this->pluginsTtContentRecord['uid']]
To Reproduce Steps to reproduce the behavior:
- Create two result plugins with different settings on one TYPO3 page
Used versions (please complete the following information):
- TYPO3 Version: 12.4.21
- EXT:solr Version: 12.0.5
- PHP Version: 8.3
@ayacoo Thanks for reporting that issue. Could you provide a PR, against release-12.0.x branch?
~~That is strange, SettingsPreviewOnPlugins is not a singleton, therefore is it a TYPO3 Core bug?~~
OK, that is defined in Services.yaml:
https://github.com/TYPO3-Solr/ext-solr/blob/dc7162b25a34cc819bfee6e43642777a7a83a1e0/Configuration/Services.yaml#L53-L61
Is there a way to set DI to always deliver new instances?
@dkd-kaehm Unfortunately, I am not aware of this DI topic. I would prefer the variant with the integration of the Content UID in the settings array. What is your opinion?
Basically, this event listener integration is working.
@dkd-kaehm Unfortunately, I am not aware of this DI topic. I would prefer the variant with the integration of the Content UID in the settings array. What is your opinion?
Basically, this event listener integration is working.
Preferred way is to make that class to "Data object"-Type aka non singleton. To avoid the hacks to reset state. The SettingsPreviewOnPlugins-Object is not necessary anymore after it did its job.
@bmack Is there a way in Services.yaml to mark/define the things as data object?
"Is there a way to set DI to always deliver new instances?"
Services are shared (= same instance all the time) by default. In "classic" TYPO3-speak this is similar to SingletonInterface as we know from the past, but done in Configuration, not via a Marker interface.
So, to achieve this to always get a new instance, you need to set shared: false in Services.yaml.
@bmack thanks.
So, to achieve this to always get a new instance, you need to set
shared: falsein Services.yaml.
@ayacoo ;) Please try it:
# BE modules, plugins
ApacheSolrForTypo3\Solr\Backend\SettingsPreviewOnPlugins:
arguments:
$flexFormService: '@TYPO3\CMS\Core\Service\FlexFormService'
tags:
- name: event.listener
identifier: 'solr.plugin.be.settings.preview'
event: TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent
shared: false
# END: BE modules