-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Reestablish manipulation of EXT:indexed_search query
Due to huge performance implications on searching bigger sites, it's now possible again to manipulate the QueryBuilder instance, before the final indexed search query is executed. This achieved by introducing a new PSR-14 event. Additionally a @todo is resolved by adjusting the repository to execute the final query centrally in `doSearch()`. Resolves: #105007 Related: #97530 Related: #102937 Releases: main, 13.4 Change-Id: Ibf428be5f3554010fb9a18e8d030f7428ce5d954 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86593 Tested-by: Garvin Hicking <[email protected]> Reviewed-by: Benni Mack <[email protected]> Reviewed-by: Garvin Hicking <[email protected]> Tested-by: Oliver Bartsch <[email protected]> Reviewed-by: Oliver Bartsch <[email protected]> Tested-by: Benni Mack <[email protected]> Tested-by: core-ci <[email protected]>
- Loading branch information
Showing
4 changed files
with
160 additions
and
30 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...g/13.4.x/Important-105007-ManipulationOfFinalSearchQueryInEXTindexed_search.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.. include:: /Includes.rst.txt | ||
|
||
.. _important-105007-1728977233: | ||
|
||
============================================================================= | ||
Important: #105007 - Manipulation of final search query in EXT:indexed_search | ||
============================================================================= | ||
|
||
See :issue:`105007` | ||
|
||
Description | ||
=========== | ||
|
||
By removing the :typoscript:`searchSkipExtendToSubpagesChecking` option in | ||
:issue:`97530`, there might have been performance implications for installations | ||
with a lot of sites. This could be circumvented by adjusting the search query | ||
manually, using available hooks. Since those hooks have also been removed with | ||
:issue:`102937`, developers were no longer be able to handle the query | ||
behaviour. | ||
|
||
Therefore, the PSR-14 :php:`BeforeFinalSearchQueryIsExecutedEvent` has been | ||
introduced which allows developers to manipulate the :php:`QueryBuilder` | ||
instance again, just before the query gets executed. | ||
|
||
Additional context information, provided by the new event: | ||
|
||
* :php:`searchWords` - The corresponding search words list | ||
* :php:`freeIndexUid` - Pointer to which indexing configuration should be searched in. | ||
-1 means no filtering. 0 means only regular indexed content. | ||
|
||
.. important:: | ||
|
||
The provided query (the :php:`QueryBuilder` instance) is controlled by | ||
TYPO3 and is not considered public API. Therefore, developers using this | ||
event need to keep track of underlying changes by TYPO3. Such changes might | ||
be further performance improvements to the query or changes to the | ||
database schema in general. | ||
|
||
Example | ||
======= | ||
|
||
.. code-block:: php | ||
<?php | ||
declare(strict_types=1); | ||
namespace MyVendor\MyExtension\EventListener; | ||
use TYPO3\CMS\Core\Attribute\AsEventListener; | ||
use TYPO3\CMS\IndexedSearch\Event\BeforeFinalSearchQueryIsExecutedEvent; | ||
final readonly class EventListener | ||
{ | ||
#[AsEventListener(identifier: 'manipulate-search-query')] | ||
public function beforeFinalSearchQueryIsExecuted(BeforeFinalSearchQueryIsExecutedEvent $event): void | ||
{ | ||
$event->queryBuilder->andWhere( | ||
$event->queryBuilder->expr()->eq('some_column', 'some_value') | ||
); | ||
} | ||
} | ||
.. index:: PHP-API, ext:indexed_search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
typo3/sysext/indexed_search/Classes/Event/BeforeFinalSearchQueryIsExecutedEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\IndexedSearch\Event; | ||
|
||
use TYPO3\CMS\Core\Database\Query\QueryBuilder; | ||
|
||
/** | ||
* Listeners are able to manipulate the QueryBuilder before the search query gets executed | ||
*/ | ||
final class BeforeFinalSearchQueryIsExecutedEvent | ||
{ | ||
public function __construct( | ||
public QueryBuilder $queryBuilder, | ||
public readonly array $searchWords, | ||
public readonly int $freeIndexUid, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters