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

[BUG] SolrRoutingMiddleware does not work when using route enhancer on root page

Open EmanuelOster opened this issue 3 years ago • 2 comments

Describe the bug I have a PageType route enhancer and map a PageType to the suffix menu.json like so:

routeEnhancers:
  PageTypeSuffix:
    type: PageType
    default: ''
    map:
      menu.json: 50003

This works as expected for every page but the root page. On the root page the extension loggs

Could not resolve page by path "menu.json" and language "de"

The problem seems to be revolving around how retrievePageInformation splits the URL and then wrongly comes to the conclusion that the page does not exist.

To Reproduce Steps to reproduce the behavior:

  1. Define a PageTypeSuffix route enhancer and use it on the root page

Expected behavior The Middleware should detect the root page in the middleware and not log an error

Used versions (please complete the following information):

  • TYPO3 Version: 10.4.24
  • Browser: N/A
  • EXT:solr Version: 11.1.3 (however code is the same on master)
  • Used Apache Solr Version: N/A
  • PHP Version: 7.4
  • MySQL Version: N/A

EmanuelOster avatar Feb 14 '22 17:02 EmanuelOster

@EmanuelOster Thanks for reporting that issue. Could you provide a pull-request or point to the exact trouble-place in code? The SolrRoutingMiddleware::retrievePageInformation() is about 70 rows, which of them makes the trouble?

dkd-kaehm avatar Feb 15 '22 07:02 dkd-kaehm

Hello @dkd-kaehm,

the trouble-place is Line 330 } elseif (empty($path)) {

If you call a page like demo.org/de/robots.txt or demo.org/de/sitemap.xml, the path for the first loop is /robots.txt and for the second empty, because it's the rootpage. This should not log an error.

jagodzinski avatar Mar 23 '22 15:03 jagodzinski