Commit 2b898bc9 authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Stefan Bürk
Browse files

[TASK] Use runtime cache in `PageRepository::getPageOverlaysForLanguage()`

The function is called several times during menu/page generation with
the same arguments.

Its query results are now cached in the runtime cache to spend less
time doing SQL queries.

This streamlines the behaviour in default lanuage where
`PageRepository::getPage()` already uses the runtime cache.

Resolves: #97525
Releases: main
Change-Id: I2515e66f8bfd102cc5c9ed624c75a4b91b3084b5

Tested-by: core-ci's avatarcore-ci <>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <>
Tested-by: Stefan Bürk's avatarStefan Bürk <>
Tested-by: Georg Ringer's avatarGeorg Ringer <>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <>
parent 80e573f4
......@@ -618,7 +618,7 @@ class PageRepository implements LoggerAwareInterface
$candidates = [];
$maxChunk = PlatformInformation::getMaxBindParameters($queryBuilder->getConnection()->getDatabasePlatform());
foreach (array_chunk($pageUids, (int)floor($maxChunk / 3)) as $pageUidsChunk) {
$result = $queryBuilder
$query = $queryBuilder
......@@ -630,10 +630,18 @@ class PageRepository implements LoggerAwareInterface
$queryBuilder->createNamedParameter($pageUidsChunk, Connection::PARAM_INT_ARRAY)
// This has cache hits for the current page and for menus (little performance gain).
$cacheIdentifier = 'PageRepository_getPageOverlaysForLanguage_'
. hash('xxh3', $query->getSQL() . json_encode($query->getParameters()));
$rows = $this->getRuntimeCache()->get($cacheIdentifier);
if (!is_array($rows)) {
$rows = $query->executeQuery()->fetchAllAssociative();
$this->getRuntimeCache()->set($cacheIdentifier, $rows);
// Fetch and bring in priority order
while ($row = $result->fetchAssociative()) {
foreach ($rows as $row) {
$pageId = $row[$transOrigPointerField];
$priority = array_search($row[$languageField], $languageUids);
$candidates[$pageId][$priority] = $row;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment