From b9871efd327b2a9a9f849f1df948971be35cd08e Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Wed, 31 Aug 2022 11:38:11 +0200 Subject: [PATCH] [BUGFIX] Shortcircuit work in SolrRoutingMiddleware 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 --- Classes/Middleware/SolrRoutingMiddleware.php | 5 +++++ Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Classes/Middleware/SolrRoutingMiddleware.php b/Classes/Middleware/SolrRoutingMiddleware.php index 42a5a38e71..c1fd8a603b 100644 --- a/Classes/Middleware/SolrRoutingMiddleware.php +++ b/Classes/Middleware/SolrRoutingMiddleware.php @@ -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; @@ -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() diff --git a/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php b/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php index a2d08d36f5..13d28f0ccf 100644 --- a/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php +++ b/Tests/Unit/Middleware/SolrRoutingMiddlewareTest.php @@ -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; @@ -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()