Review main Merged

78311[TASK] Prevent unnecessary rootline lookups in PageLinkBuilder

Christoph Lehmann CR +2 V +2 Normal +135 −1 updated 11/09/26, 20:19

Commit message

The PageLinkBuilder needs to find the site of a page to be able
to link it. For every page link, the rootline of the target page
is resolved, although the page record itself is already known.

SiteFinder::getSiteByPage() now receives the resolved page and
only looks up the rootline of its parent page. This rootline is
usually already in the runtime cache when rendering menus, as all
siblings share the same parent, so fetching, enriching and caching
the record of every linked page is avoided.

This speeds up the link generation especially for pages without
mount points and on pages with the same PID.

Links with a mount point parameter still resolve the full rootline
of the target page.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benni Mack +2
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 87133

Show 68108 earlier messages
  1. Christoph Lehmann uploaded patch set 1 03/28/23, 19:20

  2. Christoph Lehmann uploaded patch set 2 03/28/23, 20:17

  3. core-ci voted on patch set 1 V -1 03/28/23, 20:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39788

  4. Christoph Lehmann updated the commit message in patch set 3 03/28/23, 20:55

  5. core-ci voted on patch set 2 V -1 03/28/23, 21:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39790

  6. core-ci voted on patch set 3 V -1 03/28/23, 22:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39791

  7. Christoph Lehmann uploaded patch set 4 V -1 03/29/23, 18:59

  8. Christoph Lehmann updated the commit message in patch set 5 03/29/23, 19:56

  9. core-ci voted on patch set 4 V -1 03/29/23, 20:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39844

  10. Christoph Lehmann updated the commit message in patch set 6 03/29/23, 20:03

  11. core-ci voted on patch set 5 V -1 03/29/23, 20:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39845

  12. core-ci voted on patch set 6 V -1 03/29/23, 21:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39846

  13. Christoph Lehmann uploaded patch set 7 V -1 03/30/23, 01:04

  14. core-ci voted on patch set 7 V +1 03/30/23, 01:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39848

  15. Christoph Lehmann uploaded patch set 8 V +1 04/01/23, 00:05

  16. core-ci voted on patch set 8 V +1 04/01/23, 00:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39921

  17. Christoph Lehmann updated the commit message in patch set 9 V +1 04/01/23, 10:44

  18. core-ci voted on patch set 9 V +1 04/01/23, 10:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39935

  19. Christian Eßl commented on patch set 9 04/01/23, 11:33

    Some classes in backend, that could potentially benefit from this new method: TYPO3\CMS\Backend\Form\FormDataProvider - (in case pages are used as inline relations? but not 100% sure about that) TYPO3\CMS\Backend\Routing\PreviewUriBuilder - is called in list module many times for each child page. TYPO3\CMS\Backend\Search\LiveSearch\PageRecordProvider - calls ->getSiteByPageId() for each single search result. TYPO3\CMS\Core\DataHandling\SlugHelper - in case, a page slug is updated and all its child pages's slugs are recursively updated as well. TYPO3\CMS\Linkvalidator\Result\LinkAnalyzerResult - when many broken links exist in the linkvalidator results TYPO3\CMS\Seo\Widgets\Provider\PagesWithoutDescriptionDataProvider - when any pages without description are listed in the widget
  20. Christoph Lehmann uploaded patch set 10 V +1 04/01/23, 22:29

  21. core-ci voted on patch set 10 V +1 04/01/23, 22:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39950

  22. Christoph Lehmann commented on patch set 9 04/01/23, 22:39

    Reply

    Thanks for investigation. TYPO3\CMS\Backend\Routing\PreviewUriBuilder => We have no pid here, so getSiteForPage() can't be used. TYPO3\CMS\Core\DataHandling\SlugHelper There is a flushRootLineCaches() in isUniqueInSite(), so i guess the cache would be useless. TYPO3\CMS\Backend\Search\LiveSearch\PageRecordProvider TYPO3\CMS\Linkvalidator\Result\LinkAnalyzerResult TYPO3\CMS\Seo\Widgets\Provider\PagesWithoutDescriptionDataProvider => Added them for best effort in https://review.typo3.org/c/Packages/TYPO3.CMS/+/78356
  23. Christoph Lehmann rebased onto patch set 11 V +1 04/02/23, 13:46

  24. core-ci voted on patch set 11 V -1 04/02/23, 14:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39981

  25. Christoph Lehmann rebased onto patch set 12 V -1 04/04/23, 19:12

  26. core-ci voted on patch set 12 V +1 04/04/23, 19:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40117

  27. Christoph Lehmann updated the commit message in patch set 13 V +1 04/04/23, 20:57

  28. core-ci voted on patch set 13 V +1 04/04/23, 21:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40123

  29. Stefan Bürk commented on patch set 13 CR -1 04/06/23, 10:45

    SiteFinder.php:146

    I'm quite unsure, but would it not be better to handle that kind of thing in the "RootlineUtillity" directly, and implement this up/down looking there as additional think. Other places would benefit from that change than also. And would avoid a caching level for a specific case instead of a generic one in one place (and tomorrow on the next place). What do you think ? Have you investigaged that on the RootlineUtility level ?
  30. Christoph Lehmann commented on patch set 13 04/07/23, 19:44

    SiteFinder.php:146 Reply

    >Have you investigaged that on the RootlineUtility level ? Nevermind...No, i started in PageLinkBuilder and saw, that all Rootline lookups come through "finding a site". I see your point and thus spend some hours on it. Goal: Pass Page object from PageLinkBuilder to SiteFinder to RootlineUtility, to be able to use the pid to craft an in-memory cache entry from parent page cache entry. Use the cache in the RootlineUtility, because other places may benefit from it, too. Clarification: Only the parent page id can make us benefit from this "looking up" in cache. Here are some points i have with adding in the RootlineUtility: * Page object might be modified by ModifyPageLinkConfigurationEvent on that way. Lets hope nothing essential was changed (and when, then see it as 'own fault'), because the Page will be part of a new rootline cache entry. Okay, it will be in-memory only, but this has kind of a bad touch. * The Context used for creating the Page object needs to be verified against the incoming Context, see constructor in RootlineUtility. Language and workspace Aspects can be verified. How about the visibility Aspect? * FE/addRootLineFields can make RootlineUtility to enrich rootline entries with extra data (for example connected records, see enrichWithRelationFields()) resulting in extra database lookups. Okay, its currently the case and will be the case afterwards. No win for people using that FE/addRootLineFields. Given a rootline is generated only, because the PageLinkBuilder needs to find the Site for the page in order to link it, then this enrichment is useless. At this point we have to say the new cache in the SiteFinder is better than in RootlineUtility. * I see no usage of the RootlineUtility, where we have the pid to be able to benefit from the cache. You? I'm really up for a rewrite of this patch, when there is a better place for the cache, but according to the points i see it under a better star in the SiteFinder.
  31. Christoph Lehmann uploaded patch set 14 CR -1 V +1 04/10/23, 20:18

  32. Christoph Lehmann uploaded patch set 15 04/10/23, 20:24

  33. core-ci voted on patch set 14 V +1 04/10/23, 20:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40425

  34. core-ci voted on patch set 15 V +1 04/10/23, 20:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40427

  35. Christoph Lehmann updated the commit message in patch set 16 V +1 04/11/23, 19:00

  36. core-ci voted on patch set 16 V +1 04/11/23, 19:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40476

  37. Christian Kuhn rebased onto patch set 17 V +1 04/20/23, 14:44

  38. core-ci voted on patch set 17 V +1 04/20/23, 14:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40982

  39. Christian Eßl commented on patch set 17 04/24/23, 18:33

    SiteFinder.php:146 Reply

    RootLineUtility alone can never solve the many performance issues, that SiteFinder currently has, when handling a large amount of pages or on large mult-site setups. See https://forge.typo3.org/issues/95690, which summarizes many of the bottlenecks with SiteFinder at the moment on large websites. This patch won't fix all of the performance bottlenecks (only those that occur, when generating large page trees), but I think such a "getSiteByPage" method, that accepts a Page object instead of just page ids is the best starting point for future improvements.
  40. Christian Kuhn commented on patch set 17 04/24/23, 18:42

    let's have a detail look at this one after 12 lts dot zero for the first bugfix release.
  41. Benni Mack updated the commit message in patch set 18 V +1 05/03/23, 09:47

  42. Christoph Lehmann rebased onto patch set 19 06/16/23, 19:03

  43. core-ci voted on patch set 19 V +1 06/16/23, 19:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/42753

  44. Christoph Lehmann commented on patch set 19 06/16/23, 20:18

    SiteFinder.php:146 Reply

    Done
  45. Benni Mack commented on patch set 19 06/16/23, 22:02

    let's inject $runtimeCache into SiteFinder please.
  46. Benni Mack commented on patch set 19 06/16/23, 22:08

    We also should document (in the code) the structure of the cacheEntry. This seems complex.
  47. Christoph Lehmann uploaded patch set 20 V +1 06/29/23, 20:19

  48. core-ci voted on patch set 20 V -1 06/29/23, 20:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43125

  49. Christoph Lehmann uploaded patch set 21 V -1 06/29/23, 20:40

  50. core-ci voted on patch set 21 V -1 06/29/23, 20:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43126

  51. Christoph Lehmann uploaded patch set 22 V -1 06/30/23, 21:06

  52. core-ci voted on patch set 22 V -1 06/30/23, 21:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43167

  53. Christoph Lehmann commented on patch set 22 06/30/23, 21:17

    For the failing acceptance tests i added testing instructions to commit message and the created a PR https://github.com/TYPO3/styleguide/pull/409
  54. Benni Mack rebased onto patch set 23 V -1 07/05/23, 13:01

  55. core-ci voted on patch set 23 V -1 07/05/23, 13:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43514

  56. Christoph Lehmann uploaded patch set 24 V -1 10/27/23, 16:43

  57. core-ci voted on patch set 24 V -1 10/27/23, 16:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48305

  58. Christoph Lehmann uploaded patch set 25 V -1 10/27/23, 18:27

  59. core-ci voted on patch set 25 V -1 10/27/23, 18:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48310

  60. Christoph Lehmann uploaded patch set 26 V -1 10/27/23, 18:47

  61. core-ci voted on patch set 26 V -1 10/27/23, 18:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48312

  62. Christoph Lehmann uploaded patch set 27 V -1 10/27/23, 19:06

  63. core-ci voted on patch set 27 V +1 10/27/23, 19:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48315

  64. Christoph Lehmann uploaded patch set 28 V +1 10/27/23, 20:06

  65. Christoph Lehmann commented on patch set 28 10/27/23, 20:10

    Its ready to review. The caching behaviour previously in SiteFinder is moved to RootlineUtility.
  66. core-ci voted on patch set 28 V +1 10/27/23, 20:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48316

  67. Oliver Klee commented on patch set 28 10/28/23, 08:12

    SiteFinder.php:130

    I propose removing the PHPDoc annotation (that is redundant to the native type annotation) and making the native type annotation nullable instead (to make this explicit).

    SiteFinder.php:136

    `$pageIdsInRootline` is not defined at this point yet. So we need to declar it first.

    SiteFinder.php:144

    Maybe we can move this up to the start of the method.

    RootlineUtility.php:191

    `@return list<int<1, max>>`
  68. Christoph Lehmann uploaded patch set 29 V +1 10/28/23, 10:44

  69. Christoph Lehmann commented on patch set 29 10/28/23, 10:51

    SiteFinder.php:130 Reply

    Done

    SiteFinder.php:136 Reply

    Done

    SiteFinder.php:144 Reply

    Done

    RootlineUtility.php:191 Reply

    Done
  70. core-ci voted on patch set 29 V +1 10/28/23, 10:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48322

  71. Christoph Lehmann updated the commit message in patch set 30 V +1 10/28/23, 14:29

  72. core-ci voted on patch set 30 V +1 10/28/23, 14:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48328

  73. Benni Mack voted on patch set 30 CR +1 12/04/23, 09:16

  74. Stefan Bürk commented on patch set 30 01/12/24, 17:15

    RootlineUtility.php:217

    Do we really need the page ids as cacheTags ? First, this is a runtime cache. That means, it's cleared for the next request anyway. In the whole page, there is no remove of this change entry by identifier or the tag. Even a lookup by the tag is never used. Seems superflous to me. What do I miss ?
  75. Christoph Lehmann commented on patch set 31 CR +1 V +1 01/16/24, 08:09

    Published edit on patch set 30.
  76. Christoph Lehmann commented on patch set 31 01/16/24, 08:10

    RootlineUtility.php:217 Reply

    Yes, its superfluous for now. I removed the cache tags, but kept self::RUNTIME_CACHE_TAG like in the other functions.
  77. core-ci voted on patch set 31 V -1 01/16/24, 12:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51624

  78. Christoph Lehmann uploaded patch set 32 01/16/24, 13:31

    Copied Votes: * Verified-1 (copy condition: "**changekind:NO_CHANGE**")
  79. Oliver Klee commented on patch set 32 01/16/24, 14:20

    FYI, this change still has some merge conflicts that need resolving.
  80. Oliver Klee voted on patch set 32 CR -1 01/16/24, 14:20

  81. Christoph Lehmann uploaded patch set 33 CR -1 V -1 01/16/24, 14:26

  82. core-ci voted on patch set 33 V +1 01/16/24, 14:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51645

  83. core-ci voted on patch set 32 V -1 01/16/24, 17:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51642

  84. Stefan Bürk commented on patch set 33 01/17/24, 01:40

    RootlineUtility.php:217 Reply

    self::RUNTIME_CACHE_TAGS is ok.
  85. Stefan Bürk commented on patch set 33 01/17/24, 01:58

    SiteFinder.php:131

    As this is a brand new method, and the `$mountPintParameter` is not checked in this method, and only passed one time to the `RootlineUtility` with a string cast I would suggest to mage the second argument not nullable and with empty string as fallback value. That should eliminate the `(string)` cast in L138. Or do I miss something ?

    RootlineUtility.php:126

    Just thinking if it would be possible to resolve a Page object here to set it in case just an integer is provied. TBH not checked, what do you think ?

    RootlineUtility.php:203

    I guess we could simplify this by using an arrow function here: ```php return array_map( fn (array $item):int => (int)$item['uid'], array_reverse($rootlineParentPage), ); ```

    RootlineUtility.php:219

    Same question as for L203.

    RootlineUtility.php:234

    Same question as for L203.
  86. Christoph Lehmann uploaded patch set 34 V +1 02/27/24, 17:26

  87. core-ci voted on patch set 34 V -1 02/27/24, 17:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53648

  88. Christoph Lehmann uploaded patch set 35 V -1 02/27/24, 17:37

  89. Christoph Lehmann commented on patch set 35 02/27/24, 17:43

    SiteFinder.php:131 Reply

    Good catch!

    RootlineUtility.php:126 Reply

    Resolving the Page object would mean to do a PageRepository lookup and i *guess* there is a good reason resolving the page id in this class is "manually". Not checked. Lets leave it away for now.

    RootlineUtility.php:203 Reply

    Done

    RootlineUtility.php:219 Reply

    Done

    RootlineUtility.php:234 Reply

    Done
  90. core-ci voted on patch set 35 V +1 02/27/24, 17:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53650

  91. Christoph Lehmann uploaded patch set 36 V +1 05/07/24, 08:05

  92. Christoph Lehmann commented on patch set 36 05/07/24, 08:06

    Rebased
  93. core-ci voted on patch set 36 V +1 05/07/24, 08:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57322

  94. Christoph Lehmann rebased onto patch set 37 V +1 09/05/24, 18:08

  95. core-ci voted on patch set 37 V -1 09/05/24, 18:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64882

  96. Christoph Lehmann commented on patch set 37 09/06/24, 11:30

    Is it targeted to get merged? Even with the introduction of CTEs (credits to Christian and Stefan, whoop whoop) its still valid.
  97. Oliver Klee wrote 09/06/24, 11:50

    Removed reviewer Oliver Klee.
  98. Benni Mack updated the commit message in patch set 38 V -1 10/18/24, 13:49

  99. Christoph Lehmann uploaded patch set 39 03/12/25, 19:59

  100. core-ci voted on patch set 39 V -1 03/12/25, 20:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75526

  101. Christoph Lehmann uploaded patch set 40 V -1 03/12/25, 20:11

  102. core-ci voted on patch set 40 V -1 03/12/25, 20:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75527

  103. Christoph Lehmann uploaded patch set 41 V -1 03/12/25, 22:55

  104. core-ci voted on patch set 41 V +1 03/12/25, 23:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75530

  105. Benni Mack uploaded patch set 42 V +1 03/19/25, 09:24

  106. core-ci voted on patch set 42 V +1 03/19/25, 09:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75812

  107. Simon Schaufelberger commented on patch set 42 03/23/25, 23:31

    RootlineUtility.php:176

    Can we check explicitly here for a value, otherwise PHP is doing it's own thing
  108. Benni Mack wrote 04/16/25, 10:46

    Hashtag added: lolli-feedback
  1. Benni Mack uploaded patch set 43 V +1 10/29/25, 08:40

  2. core-ci voted on patch set 43 V +1 10/29/25, 08:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87914

  3. Benni Mack commented on patch set 43 11/03/25, 15:27

    RootlineUtility.php:176 Reply

    What thing? It's either Page or null :)
  4. Simon Schaufelberger commented on patch set 43 11/03/25, 17:12

    RootlineUtility.php:176 Reply

    !== null or instanceof check
  5. Benni Mack commented on patch set 43 11/19/25, 15:56

    RootlineUtility.php:176 Reply

    does it matter substantially or is it more a personal preference?
  6. Simon Schaufelberger commented on patch set 43 11/19/25, 17:36

    RootlineUtility.php:176 Reply

    Just be reading that line you don't immediately know that it can only be null or Page. In line 98 there is also a check so it would be consistent here as well and we know we are not dealing with an integer here.
  7. Christian Kuhn commented on patch set 43 11/19/25, 21:56

    RootlineUtility.php:162

    two new public methods - one here and one in sitefinder. rootline stuff is *still* a mess and we need a bigger rewrite. i think we should do some measurements to see if the change is performance wise as effective as stated, and if so, go with the change but maybe with some additional disclaimers. i'll finally try to review this one soonish.
  8. Simon Schaufelberger uploaded patch set 44 V +1 11/29/25, 12:06

  9. Simon Schaufelberger commented on patch set 44 11/29/25, 12:07

    RootlineUtility.php:176 Reply

    Done
  10. core-ci voted on patch set 44 V +1 11/29/25, 12:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91250

  11. Benni Mack wrote 04/21/26, 14:51

    Removed reviewer Benni Mack.
  12. Benni Mack updated the commit message in patch set 45 V +1 04/22/26, 06:50

  13. core-ci voted on patch set 45 V -1 04/22/26, 11:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100809

  14. Benni Mack rebased onto patch set 46 V -1 05/15/26, 08:14

  15. core-ci voted on patch set 46 V +1 05/15/26, 08:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102047

  16. Christian Kuhn wrote 06/18/26, 23:03

    Hashtag removed: lolli-feedback
  17. Christian Kuhn wrote 06/18/26, 23:03

    Removed cc Christian Kuhn.
  18. Benni Mack uploaded patch set 47 V +1 11/09/26, 14:09

  19. core-ci voted on patch set 47 V +1 11/09/26, 14:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113698

  20. Benni Mack updated the commit message in patch set 48 V +1 11/09/26, 14:51

  21. Benni Mack commented on patch set 48 11/09/26, 14:52

    RootlineUtility.php:162 Reply

    thanks to a lot of other pre-patches, this change is now super-simple. And adds one - IMHO valid - public method.
  22. Simon Schaufelberger voted on patch set 48 CR +1 V +1 11/09/26, 14:57

  23. core-ci voted on patch set 48 V +1 11/09/26, 15:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113714

  24. Benni Mack voted on patch set 48 CR +2 V +2 11/09/26, 20:19

  25. Benni Mack merged patch set 49 11/09/26, 20:19