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] Configuring tx_solr[q] as speaking URL part crashes faceting #2984

Closed
calien666 opened this issue Jul 20, 2021 · 2 comments · Fixed by #3562
Closed

[BUG] Configuring tx_solr[q] as speaking URL part crashes faceting #2984

calien666 opened this issue Jul 20, 2021 · 2 comments · Fixed by #3562

Comments

@calien666
Copy link

Our customer wanted to have the search param as part of the uri speaking. After introducing the faceting didn't work and produced bad link requests.

Steps to reproduce the behavior:
Configure a page with a Route enhancement for search query:

  Search:
    type: Plugin
    namespace: tx_solr
    routePath: '/{q}'
    limitToPages: [{your search page}]
    defaults:
      q: ''
    requirements:
      q: '^.*$'

Search is now callable like

https://example.com/search/my%20Search%20word

With active faceting the generated links for toggling will look like this:

https://example.com/search/%23%23%23tx_solr:q%23%23%23/?tx_solr%5Bfilter%5D%5B0%5D=keywords%3AWaste+plastics

As you see, the building structure and replacement of the placeholders could not work, because of url encoding the # to %23.

Expected behavior
Clean search URLs with speaking parameters like:

https://example.com/search/recycling/?tx_solr%5Bfilter%5D%5B0%5D=keywords%3AWaste+plastics

Used versions:

  • TYPO3 Version: 9.5.27
  • Browser: All browsers, server side problem
  • EXT:solr Version: 11.0.4
  • Used Apache Solr Version: 8.5.2
  • PHP Version: 7.4.21
  • MySQL Version: 5.7.34

Additional context

After debugging I found one line changing could solve the problem, but I am not sure, if this will fit to all cases.

Inside solr/Classes/Domain/Search/Uri/SearchUriBuilder.php, method buildLinkWithInMemoryCache the xtbase URI-Builder gets $structure as arguments, but $arguments is useful, too, since Extbase UriBuilder can accept multiple associative arrays, too.

changing

            self::$missCount++;
            $this->uriBuilder->reset()->setTargetPageUid($pageUid);
            $uriCacheTemplate = $this->uriBuilder->setArguments($structure)->setUseCacheHash(false)->build();

to

            self::$missCount++;
            $this->uriBuilder->reset()->setTargetPageUid($pageUid);
            $uriCacheTemplate = $this->uriBuilder->setArguments($arguments)->setUseCacheHash(false)->build();

solved the problem for me.

@trokohl
Copy link

trokohl commented Jun 20, 2022

I have a similar problem and this BugFix works

@trokohl
Copy link

trokohl commented Jun 20, 2022

But i think you must also change
$hash = md5($pageUid . json_encode($structure));

to

$hash = md5($pageUid . json_encode($structure). json_encode($values));

dkd-friedrich pushed a commit to dkd-friedrich/ext-solr that referenced this issue Sep 20, 2023
When there are route enhancers defined for a page containing
the Solr search plugin, e.g. to realize pretty URLs for the
search term, filters or pagination, there are issues with
the URI caching that utilizes placeholders.

Route Enhancers should specify the expected format using the
requirements setting of the route enhancer parameters. This
will then lead to an exception, which is caught and will then
proceed the URI building with the original arguments instead
of the placeholder arguments.

Ports: TYPO3-Solr#3562
Resolves: TYPO3-Solr#2984
dkd-friedrich pushed a commit to dkd-friedrich/ext-solr that referenced this issue Sep 20, 2023
When there are route enhancers defined for a page containing
the Solr search plugin, e.g. to realize pretty URLs for the
search term, filters or pagination, there are issues with
the URI caching that utilizes placeholders.

Route Enhancers should specify the expected format using the
requirements setting of the route enhancer parameters. This
will then lead to an exception, which is caught and will then
proceed the URI building with the original arguments instead
of the placeholder arguments.

Ports: TYPO3-Solr#3562
Resolves: TYPO3-Solr#2984
dkd-friedrich pushed a commit that referenced this issue Sep 20, 2023
When there are route enhancers defined for a page containing
the Solr search plugin, e.g. to realize pretty URLs for the
search term, filters or pagination, there are issues with
the URI caching that utilizes placeholders.

Route Enhancers should specify the expected format using the
requirements setting of the route enhancer parameters. This
will then lead to an exception, which is caught and will then
proceed the URI building with the original arguments instead
of the placeholder arguments.

Resolves: #2984
dkd-friedrich pushed a commit that referenced this issue Sep 20, 2023
When there are route enhancers defined for a page containing
the Solr search plugin, e.g. to realize pretty URLs for the
search term, filters or pagination, there are issues with
the URI caching that utilizes placeholders.

Route Enhancers should specify the expected format using the
requirements setting of the route enhancer parameters. This
will then lead to an exception, which is caught and will then
proceed the URI building with the original arguments instead
of the placeholder arguments.

Ports: #3562
Resolves: #2984
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

Successfully merging a pull request may close this issue.

2 participants