Commit 82f807bd authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Streamline mount page resolving for HMENU special=list

TYPO3 used RelationHandler for HMENU special=list to
fetch all pages for this menu once, but fetched
the full records again for MountPoint relation, and
manual language + workspace overlay was taken care later-on.

Once menus were generated with mountpoints and workspace and language
overlays, the ordering was not in line, and existing
queries were not used.

Instead, the code is now simplified and fully relies on
PageRepository functionality, just as most other
Frontend-related code.

Resolves: #94643
Releases: master
Change-Id: Ib86116a74c7db6739c474e5efb13b77284e41b08
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70112

Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent a22be10b
......@@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\RelationHandler;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Page\AssetCollector;
use TYPO3\CMS\Core\Site\Entity\Site;
......@@ -720,55 +719,41 @@ abstract class AbstractMenuContentObject
if ($specialValue == '') {
$specialValue = $this->id;
}
$skippedEnableFields = [];
if (!empty($this->mconf['showAccessRestrictedPages'])) {
$skippedEnableFields = ['fe_group' => 1];
}
/** @var RelationHandler $loadDB*/
$loadDB = GeneralUtility::makeInstance(RelationHandler::class);
$loadDB->setFetchAllFields(true);
$loadDB->start($specialValue, 'pages');
$loadDB->additionalWhere['pages'] = $this->sys_page->enableFields('pages', -1, $skippedEnableFields);
$loadDB->getFromDB();
$pageIds = GeneralUtility::intExplode(',', (string)$specialValue);
$disableGroupAccessCheck = !empty($this->mconf['showAccessRestrictedPages']);
$pageLinkBuilder = GeneralUtility::makeInstance(PageLinkBuilder::class, $this->parent_cObj);
foreach ($loadDB->itemArray as $val) {
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps((int)$val['id']);
foreach ($pageIds as $pageId) {
$row = $this->sys_page->getPage($pageId, $disableGroupAccessCheck);
if (!is_array($row)) {
continue;
}
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps($pageId);
// Keep mount point?
$mount_info = $this->sys_page->getMountPointInfo($val['id']);
// There is a valid mount point.
$mount_info = $this->sys_page->getMountPointInfo($pageId, $row);
// $pageId is a valid mount point
if (is_array($mount_info) && $mount_info['overlay']) {
$mountedPageId = (int)$mount_info['mount_pid'];
// Using "getPage" is OK since we need the check for enableFields
// AND for type 2 of mount pids we DO require a doktype < 200!
$mp_row = $this->sys_page->getPage($mount_info['mount_pid']);
if (!empty($mp_row)) {
$row = $mp_row;
$mountedPageRow = $this->sys_page->getPage($mountedPageId, $disableGroupAccessCheck);
if (empty($mountedPageRow)) {
// If the mount point could not be fetched with respect to
// enableFields, the page should not become a part of the menu!
continue;
}
$row = $mountedPageRow;
$row['_MP_PARAM'] = $mount_info['MPvar'];
// Overlays should already have their full MPvars calculated
if ($mount_info['overlay']) {
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps((int)$mount_info['mount_pid']);
// Overlays should already have their full MPvars calculated, that's why we unset the
// existing $row['_MP_PARAM'], as the full $MP will be added again below
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps($mountedPageId);
if ($MP) {
unset($row['_MP_PARAM']);
}
}
} else {
// If the mount point could not be fetched with respect to
// enableFields, unset the row so it does not become a part of the menu!
unset($row);
}
} else {
$row = $loadDB->results['pages'][$val['id']] ?? [];
}
// Add versioning overlay for current page (to respect workspaces)
if (isset($row) && is_array($row)) {
$this->sys_page->versionOL('pages', $row, true);
}
// Add external MP params, then the row:
if (isset($row) && is_array($row)) {
if ($MP) {
$row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
}
$menuItems[] = $this->sys_page->getPageOverlay($row);
}
$menuItems[] = $row;
}
return $menuItems;
}
......
Markdown is supported
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