Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to register a custom facet package with FacetRegistry #4280

Open
b3nkai opened this issue Jan 13, 2025 · 0 comments
Open

[BUG] Unable to register a custom facet package with FacetRegistry #4280

b3nkai opened this issue Jan 13, 2025 · 0 comments

Comments

@b3nkai
Copy link
Contributor

b3nkai commented Jan 13, 2025

Describe the bug

If we declare a custom facet package with the FacetRegistry, the type is right stored in $classMap property. But with TYPO3 12, the class is declared as shared in services.yml so the class is not used as a Singleton anymore and all custom facets types registered with FacetRegistry are lost.

To Reproduce

Declare a custom facet package:

$facetRegistry = GeneralUtility::makeInstance(FacetRegistry::class);
$facetRegistry->registerPackage(
    CustomFacetPackage::class,
    'customfacet'
);

Use this facet type:

plugin.tx_solr {
    search {
        faceting = 1
        faceting {
            facets {
                customfield {
                    label = Custom facet
                    field = customfield_stringS
                    type = customfacet
                    partialName = CustomFacet
                }
          }
     }
}

Expected behavior

We expect to receive the CustomFacet object in the CustomFacet template but we receive the default "OptionFacet".

Reason

The FacetRegistry extends the AbstractClassRegistry class which implements the TYPO3 SingletonInterface.
As TYPO3 12 now use the Symfony container manager, this class must not be declared as shared in Services.yml.

Solution

Exclude the FacetRegistry class in Services.yml so won't be shared:

  facets:
    namespace: ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\
    resource: '../Classes/Domain/Search/ResultSet/Facets/*'
    exclude:
      - '../Classes/Domain/Search/ResultSet/Facets/{OptionBased/Hierarchy/Node.php,*/Abstract*}'
      - '../Classes/Domain/Search/ResultSet/Facets/*/*/*Facet.php'
      - '../Classes/Domain/Search/ResultSet/Facets/RangeBased/*/*RangeCount.php'
      - '../Classes/Domain/Search/ResultSet/Facets/FacetRegistry.php'
    public: true
    autowire: true
    shared: false

Used versions (please complete the following information):

  • TYPO3 Version: [e.g. 12.4.0]
  • EXT:solr Version: [e.g. 12.0.5]
  • Used Apache Solr Version: [e.g. 9.3.0]
  • PHP Version: [e.g. 8.2.x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant