Review main Merged

87549[FEATURE] Add search by page URI in page tree filter and livesearch

Garvin Hicking CR +2 V +2 Expert +1331 −50 updated 01/24/26, 05:47

Commit message

The backend page tree can now be filtered by entering one or more
frontend URIs, similiar to the search by page UID.

It can be combined with the other search methods by page/nav title
or page uid.

It uses the existing page/workspace/permission checks, and resolves
the URI using the existing SiteMatcher/PageRouter API (via a new
intermediate internal helper class `SiteUrlResolver`).

The filter is implemented through the existing PSR-14 event
`BeforePageTreeIsFilteredEvent`.

Additionally, the same functionality is provided to the Live Search,
utilizing a new PSR-14 event `ModifyConstraintsForLiveSearchEvent`,
which was added because `ModifyQueryForLiveSearchEvent` did not allow
to influence the OR-constraints. The event is dispatched from both
the `PageRecordProvider` and the `DatabaseRecordProvider`, and the
event listener `AddLiveSearchFrontendUriResolverListener` acts on this
on the `PageRecordProvider` only. Database record's do not have
frontend URIs. The dispatched event however can be used for other listener
implementations in the future.

Similar to the translation page search, both a User TSConfig
setting and a persisted user setting control whether this feature
is enabled (default setting):

  options.pageTree.searchByFrontendUri = 1

A runtime cache is used to store matched frontend URI
uids so that labels with hints at the match reasons can be
embedded.

Matches in translated pages are specifically labelled in the
page tree result, and live search yields two entries for
both the translated page as well as the default language
variant of it.

(Please note there is a seperate bug that currently multilingual
results in the live search do not point/link to the proper
target backend functionality. This is unrelated and needs
to be fixed seperately)

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Anja Leichsenring +1
    • Sven Liebert +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Anja Leichsenring +1
    • Sven Liebert +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 3

Files 22

Show 2 more files

Review log 4662

Show 2737 earlier messages
  1. Garvin Hicking uploaded patch set 1 12/18/24, 07:55

  2. Garvin Hicking uploaded patch set 2 12/18/24, 07:57

  3. core-ci voted on patch set 1 V +1 12/18/24, 08:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71342

  4. core-ci voted on patch set 2 V +1 12/18/24, 08:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71343

  5. Oli Bartsch commented on patch set 3 V +1 12/18/24, 08:12

    Published edit on patch set 2.
  6. core-ci voted on patch set 3 V +1 12/18/24, 08:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71344

  7. Benni Mack commented on patch set 3 CR -1 03/27/25, 20:01

    Comment removed by: Benni Mack; Reason: discussed otherwise
  8. Benni Mack commented on patch set 3 03/27/25, 20:07

    SiteMatcher.php:142

    does not belong to SiteMatcher. It matches a page for a URL, not a site for a URL :) so... The chain is: - a new class, that uses site matcher, then page router...
  9. Garvin Hicking commented on patch set 3 CR -1 03/27/25, 20:15

    SiteMatcher.php:142 Reply

    Ack. please let me rework this patch as an eventlistener, also reworking this aspect. Then let's see if this is acceptable. I'd not like to provide this functionality as an extension because that would be fragile to maintain and people will likely not use it. the positive effect this search could have for editors is quite large in my opinion, because TYPO3 does not easily let you edit the exact page you're seeing in the frontend. I think the performance penalty only occurs when a "http(s)://" URI is entered as a search term. if you don't, nothing impactful will be performed.
  10. Garvin Hicking marked it work in progress 03/27/25, 20:15

  11. Garvin Hicking uploaded patch set 4 CR -1 V +1 07/07/25, 18:31

  12. core-ci voted on patch set 4 V +1 07/07/25, 18:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81440

  13. Garvin Hicking updated the commit message in patch set 5 V +1 07/07/25, 19:07

  14. Garvin Hicking commented on patch set 5 07/07/25, 19:07

    This change is ready for review.

    SiteMatcher.php:142 Reply

    Done
  15. core-ci voted on patch set 5 V +1 07/07/25, 19:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81441

  16. Simon Schaufelberger commented on patch set 5 07/07/25, 23:30

    SiteUrlResolver.php:31

    final : therefore can be Private
  17. Garvin Hicking commented on patch set 6 V +1 07/08/25, 05:18

    Published edit on patch set 5.
  18. core-ci voted on patch set 6 V +1 07/08/25, 05:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81458

  19. Garvin Hicking commented on patch set 6 07/08/25, 06:11

    SiteUrlResolver.php:31 Reply

    thx done and readonly'd.
  20. Simon Schaufelberger voted on patch set 6 CR +1 07/08/25, 08:31

  21. Stefan Bürk commented on patch set 6 CR -1 07/08/25, 13:43

    Reviewing / talking with Garvin ...
  22. Garvin Hicking commented on patch set 6 CR -1 07/30/25, 14:31

    will iterate further.

    SiteUrlResolver.php:49

    Todo: Feedback from Stefan: Could be superflous? Use: ``` $pageArguments = $site->getRouter()->matchRequest($request, $previousResult); ``` instead of instantiating PageRouter on its own? Also check "isDirty" and further things. Comes from middleware `typo3/sysext/frontend/Classes/Middleware/PageResolver.php`.
  23. Garvin Hicking commented on patch set 6 07/30/25, 14:32

    Add basic event listener test for the constraints event
  24. Garvin Hicking marked it work in progress 07/30/25, 14:32

  25. Garvin Hicking commented on patch set 6 07/30/25, 14:47

    ModifyConstraintsForLiveSearchEvent.php:48

    Only let the event implement "addConstraint", ensure type safety for it (use a single string|CompositeExpression): ``` public function addConstraints(string|CompositeExpression ...$constraints) public function addConstraint(string|CompositeExpression $constraint) ``` Explain why we don't want to modify the whole constraint setup (eventlisteners should not override everything, only add to it) ``` $constraints = [...array_values($coreConstraints), ...array_values($eventConstraints)]; ``` (or use foreach, whatever)
  26. Garvin Hicking uploaded patch set 7 CR +1 V +1 12/11/25, 11:04

  27. core-ci voted on patch set 7 V -1 12/11/25, 11:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/92060

  28. Garvin Hicking uploaded patch set 8 V -1 12/11/25, 11:30

  29. core-ci voted on patch set 8 V +1 12/11/25, 11:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/92063

  30. Garvin Hicking commented on patch set 8 12/11/25, 11:45

    This change is ready for review.

    Reply

    Done

    Reply

    Done
    I've iterated on this, added tests, and implemented suggestions made by @stefan@buerk.tech I'd be happy for further feedback as I think this search functionality would be a very welcome thing for editors, and was recently brought up again on slack (https://typo3.slack.com/archives/C024TUMM7/p1765365904964569)

    ModifyConstraintsForLiveSearchEvent.php:48 Reply

    Done

    SiteUrlResolver.php:49 Reply

    Done
  31. Garvin Hicking uploaded patch set 9 V +1 12/14/25, 18:31

    fix merge conflict
  32. core-ci voted on patch set 9 V +1 12/14/25, 18:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/92218

  33. Georg Ringer voted on patch set 9 CR +1 V +1 12/18/25, 06:57

  34. Guido Schmechel commented on patch set 9 V -1 12/19/25, 21:36

    Currently, pages found in PageTreeFilter are not marked in orange because the TYPO3\CMS\Backend\Dto\Tree\Label is not set. What helped? Extend attachSearchResultLabel() with this query: if (str_starts_with($searchPhrase, 'http://';) || str_starts_with($searchPhrase, 'https://';)) { // If a search pattern uses "http(s)://...." then a frontend URL will be resolved. $resolvedPageUid = $this->siteUrlResolver->resolvePageUidBySiteUrl($searchPhrase); if ($resolvedPageUid === $page['uid']) { $matchedDirectly = true; } } Of course, you should keep an eye on performance here and not add to the for loop like I did ;-) Successfully tested: ‘https://t3main.ddev.site/unterseite’ finds the original page and a page with this URL in the title field.
  35. Garvin Hicking uploaded patch set 10 CR +1 V +1 12/20/25, 12:33

    Use labels and add tests
  36. Garvin Hicking commented on patch set 10 12/20/25, 12:36

    Reply

    Thanks for the nudge. Indeed the "Page translation" thing changed a lot more that the patch did not yet cover. I now: - added tests for both the new intermediate helper class and the filter event - added attaching a label - added having a user TS config / setting to control if the event is used There's a bug that the clicking on the checkbox of the page tree filter to toggle the "frontend URI search" functionality is not updated in the UI. The checkbox for me does not get updated like "search by translation". I could not find how the JavaScript determines this UI state. @bo@cedev.de help? 😄
  37. core-ci voted on patch set 10 V -1 12/20/25, 12:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/92513

  1. Garvin Hicking uploaded patch set 11 V -1 12/20/25, 12:53

    adjust namespace of test
  2. Garvin Hicking uploaded patch set 12 12/20/25, 13:02

    juggle fixtures
  3. core-ci voted on patch set 11 V -1 12/20/25, 13:06 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/92514

  4. core-ci voted on patch set 12 V +1 12/20/25, 13:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/92515

  5. Garvin Hicking uploaded patch set 13 V +1 01/14/26, 20:05

  6. core-ci voted on patch set 13 V +1 01/14/26, 20:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93473

  7. Guido Schmechel commented on patch set 13 CR +1 V +1 01/17/26, 13:07

    My URL example now works too, and the page is marked in the backend. Thank you :-)
  8. Garvin Hicking uploaded patch set 14 CR +1 V +1 01/20/26, 13:47

  9. core-ci voted on patch set 14 V +1 01/20/26, 14:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93866

  10. Josua Vogel uploaded patch set 15 V +1 01/22/26, 07:49

  11. Josua Vogel voted on patch set 15 CR +1 V +1 01/22/26, 07:54

  12. Garvin Hicking commented on patch set 15 01/22/26, 07:54

    @j.vogel97@web.de Thanks so much for spotting my JS mistake!!!! <3
  13. core-ci voted on patch set 15 V +1 01/22/26, 07:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94014

  14. Josua Vogel voted on patch set 15 CR 0 V 0 01/22/26, 08:03

  15. Josua Vogel commented on patch set 15 01/22/26, 08:08

    Two enhancement suggestions: 1. When searching by translated URI, could we display the translated page in the results instead of the default language version? 2. For consistency with the title search, could we use "Found in translation: ..." as the page tree label for URI search results as well?
  16. Garvin Hicking commented on patch set 15 01/22/26, 08:35

    Reply

    1. I think this also does not happen for multilingual title search, the link always goes to the "parent" page. We could maybe address this in a folllwup? 2. The URI search will only find one page ever, since multiple pages cannot have the same URI. So I would argue such a tooltip would not help very much - and the code to attach labels is a bit complicated and requires extra listeners, so I intentioally left this out...?
  17. Garvin Hicking uploaded patch set 16 V +1 01/23/26, 17:36

  18. core-ci voted on patch set 16 V +1 01/23/26, 17:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94192

  19. Garvin Hicking commented on patch set 16 01/23/26, 17:49

    Reply

    Thanks for pointing me towards this. I've now refactored the code a bit: * Page tree receives a label for "found in uri translation: xxx" to distinguish pages found as a translation * Live search now shows both the specific language version of a link and its default page variant
  20. Georg Ringer voted on patch set 16 CR +1 V +1 01/23/26, 18:03

  21. Simon Schaufelberger voted on patch set 16 CR +1 V +1 01/23/26, 18:54

  22. Sven Liebert voted on patch set 16 CR +1 V +1 01/23/26, 20:14

  23. Anja Leichsenring voted on patch set 16 CR +1 V +1 01/24/26, 05:06

  24. Georg Ringer voted on patch set 16 CR +2 V +2 01/24/26, 05:47

  25. Georg Ringer merged patch set 17 01/24/26, 05:47