Commit 0079b13a authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Stefan Bürk
Browse files

[TASK] Prevent superflous SQL queries in HMENU

When isSubMenu() decides, that the current page has no subpages, then do not try to fetch its subpages.

Resolves: #99657
Releases: main
Change-Id: I7f3395ad9caf17c3db3aaea7927b7bfb9acb924c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77519


Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 9092b231
......@@ -530,7 +530,10 @@ abstract class AbstractMenuContentObject
$menuItems = $this->sectionIndex($alternativeSortingField);
} else {
// Default: Gets a hierarchical menu based on subpages of $this->id
$menuItems = $this->sys_page->getMenu($this->id, '*', $alternativeSortingField, $additionalWhere, true, $this->disableGroupAccessCheck);
$subMenuDecision = $this->getRuntimeCache()->get($this->getCacheIdentifierForSubMenuDecision($this->id));
if (!isset($subMenuDecision['result']) || $subMenuDecision['result'] === true) {
$menuItems = $this->sys_page->getMenu($this->id, '*', $alternativeSortingField, $additionalWhere, true, $this->disableGroupAccessCheck);
}
}
return $menuItems;
}
......@@ -1382,7 +1385,7 @@ abstract class AbstractMenuContentObject
*/
protected function isSubMenu($uid)
{
$cacheId = 'menucontentobject-is-submenu-decision-' . $uid . '-' . (int)($this->conf['includeNotInMenu'] ?? 0);
$cacheId = $this->getCacheIdentifierForSubMenuDecision($uid);
$runtimeCache = $this->getRuntimeCache();
$cachedDecision = $runtimeCache->get($cacheId);
if (isset($cachedDecision['result'])) {
......@@ -1446,6 +1449,11 @@ abstract class AbstractMenuContentObject
return $hasSubPages;
}
protected function getCacheIdentifierForSubMenuDecision($uid): string
{
return 'menucontentobject-is-submenu-decision-' . $uid . '-' . (int)($this->conf['includeNotInMenu'] ?? 0);
}
/**
* Used by processItemStates() to evaluate if a menu item (identified by $key) is in a certain state.
*
......
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