You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Solr Plugins within mount points uses the wrong site hash.
The site hash from the page where the element is saved is used instead of the page where the content is mounted.
This was not an Problem with TYPO3 10. With TYPO3 12 the problem exist.
The source of the problem is that \ApacheSolrForTypo3\Solr\Domain\Search\Query\QueryBuilder::useSiteHashFromTypoScript only use the page id to get the current context.
That is not correct if the page is mounted on an other page tree.
This method need to use the detected page from TYPO3, like within \ApacheSolrForTypo3\Solr\Controller\AbstractBaseController:initializeSearch
To Reproduce
Need two page trees
Solr plugin is configured on first page tree
The page with the solr plugin is mounted on second page tree
Open the mounted page. No results are displayed
Expected behavior
Solr use the site hash from the current page within the frontend context and show the results for the second page tree.
Used versions (please complete the following information):
TYPO3 Version: 12.4.26
Browser: Chrome
EXT:solr Version: 12.0.5
Used Apache Solr Version: 9.8.0
PHP Version: 8.3
MariaDB Version: 10.11
Additional context
Current workaround need to execute before ApacheSolrForTypo3\Solr\Search\AccessComponent
useApacheSolrForTypo3\Solr\Domain\Search\Query\QueryBuilder;
usePsr\Http\Message\ServerRequestInterface;
useTYPO3\CMS\Core\Http\ApplicationType;
useTYPO3\CMS\Core\Site\Entity\Site;
class AfterSearchQueryHasBeenPreparedEvent
{
publicfunction__construct(protectedQueryBuilder$queryBuilder)
{
}
/** * Use site hash from correct page within mount points. */publicfunction__invoke(\ApacheSolrForTypo3\Solr\Event\Search\AfterSearchQueryHasBeenPreparedEvent$event): void
{
/** @var ServerRequestInterface|null $request */$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
$site = $request?->getAttribute('site');
if (
!($siteinstanceof Site) ||
!($requestinstanceof ServerRequestInterface) ||
!ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()
) {
return;
}
$configuration = $event->getTypoScriptConfiguration();
$queryConfiguration = $configuration->getObjectByPathOrDefault('plugin.tx_solr.search.query.');
$allowSiteConfig = $queryConfiguration['allowedSites'] ?? '__solr_current_site';
if (!in_array($allowSiteConfig, ['__solr_current_site', '__current_site'], true)) {
return;
}
$query = $this->queryBuilder
->startFrom($event->getQuery())
->useSiteHashFromAllowedSites($site->getBase()->getHost())
->getQuery();
$event->setQuery($query);
}
}
The text was updated successfully, but these errors were encountered:
Describe the bug
Solr Plugins within mount points uses the wrong site hash.
The site hash from the page where the element is saved is used instead of the page where the content is mounted.
This was not an Problem with TYPO3 10. With TYPO3 12 the problem exist.
The source of the problem is that
\ApacheSolrForTypo3\Solr\Domain\Search\Query\QueryBuilder::useSiteHashFromTypoScript
only use the page id to get the current context.That is not correct if the page is mounted on an other page tree.
This method need to use the detected page from TYPO3, like within
\ApacheSolrForTypo3\Solr\Controller\AbstractBaseController:initializeSearch
To Reproduce
Expected behavior
Solr use the site hash from the current page within the frontend context and show the results for the second page tree.
Used versions (please complete the following information):
Additional context
Current workaround need to execute before
ApacheSolrForTypo3\Solr\Search\AccessComponent
The text was updated successfully, but these errors were encountered: