ext-solr icon indicating copy to clipboard operation
ext-solr copied to clipboard

[BUG] Backend summary output settings are merged

Open ayacoo opened this issue 1 year ago • 7 comments

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:

  1. 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 avatar Oct 08 '24 15:10 ayacoo

@ayacoo Thanks for reporting that issue. Could you provide a PR, against release-12.0.x branch?

dkd-kaehm avatar Oct 08 '24 16:10 dkd-kaehm

~~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 avatar Oct 08 '24 16:10 dkd-kaehm

@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.

ayacoo avatar Oct 08 '24 18:10 ayacoo

@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.

dkd-kaehm avatar Oct 08 '24 19:10 dkd-kaehm

@bmack Is there a way in Services.yaml to mark/define the things as data object?

dkd-kaehm avatar Oct 08 '24 19:10 dkd-kaehm

"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 avatar Oct 08 '24 19:10 bmack

@bmack thanks.

So, to achieve this to always get a new instance, you need to set shared: false in 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 

dkd-kaehm avatar Oct 08 '24 20:10 dkd-kaehm