Skip to content

Commit

Permalink
[BUGFIX] Shortcircuit work in SolrRoutingMiddleware
Browse files Browse the repository at this point in the history
Shortcircuit work in SolrRoutingMiddleware like in PageIndexerFinisher: When a request does not have the X-Tx-Solr-Iq header, then it's not interesting for the Solr extension.

Background: Superflous logging 'Could not resolve page by path...' to Solr logfile.

Relates: #3202
  • Loading branch information
Christoph Lehmann authored and dkd-kaehm committed Sep 9, 2022
1 parent 88f3b97 commit 320be8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Classes/Middleware/SolrRoutingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace ApacheSolrForTypo3\Solr\Middleware;

use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerRequest;
use ApacheSolrForTypo3\Solr\Routing\RoutingService;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -100,6 +101,10 @@ public function injectRoutingService(RoutingService $routingService)
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if (!$request->hasHeader(PageIndexerRequest::SOLR_INDEX_HEADER)) {
return $handler->handle($request);
}

/* @var SiteRouteResult $routeResult */
$routeResult = $this->getRoutingService()
->getSiteMatcher()
Expand Down
6 changes: 5 additions & 1 deletion Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace ApacheSolrForTypo3\Solr\Tests\Unit\Middleware;

use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerRequest;
use ApacheSolrForTypo3\Solr\Middleware\SolrRoutingMiddleware;
use ApacheSolrForTypo3\Solr\Routing\RoutingService;
use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest;
Expand Down Expand Up @@ -90,7 +91,10 @@ public function missingEnhancerHasNoEffectTest()
{
$serverRequest = new ServerRequest(
'GET',
'https://domain.example/facet/bar,buz,foo'
'https://domain.example/facet/bar,buz,foo',
[
PageIndexerRequest::SOLR_INDEX_HEADER => '1',
]
);
$siteMatcherMock = $this->getMockBuilder(SiteMatcher::class)
->disableOriginalConstructor()
Expand Down

0 comments on commit 320be8e

Please sign in to comment.