Skip to content

Commit

Permalink
[BUGFIX:BP:11.2] 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
Ports: #3339
  • Loading branch information
dkd-kaehm committed Sep 23, 2022
1 parent 494b52b commit fbf456d
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 @@ -14,6 +14,7 @@
* The TYPO3 project - inspiring people to share!
*/

use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerRequest;
use ApacheSolrForTypo3\Solr\Routing\RoutingService;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -97,6 +98,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 @@ -15,6 +15,7 @@
* The TYPO3 project - inspiring people to share!
*/

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 @@ -87,7 +88,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 fbf456d

Please sign in to comment.