Commit 3e6e92bd authored by Benni Mack's avatar Benni Mack
Browse files

[TASK] Unify TSFE usage consistently in HMENU

Some code in HMENU stems back from TYPO3 v3.x days,
and this code aims to streamline the functionality
given current functionality.

HMENU now has its own sys_page object, which should
be used. In addition, HMENU should fetch TSFE->id
consistently across all its code base.

Resolves: #96492
Releases: main, 11.5
Change-Id: I971a5958417077d51ea5c5070fc4b9ef513cd738
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72928

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent e0783961
......@@ -320,7 +320,7 @@ abstract class AbstractMenuContentObject
if (($this->conf['special'] ?? '') === 'directory') {
$value = $this->parent_cObj->stdWrapValue('value', $this->conf['special.'] ?? [], null);
if ($value === '') {
$value = $tsfe->page['uid'];
$value = (string)$tsfe->id;
}
$directoryLevel = (int)$tsfe->tmpl->getRootlineLevel($value);
}
......@@ -590,7 +590,7 @@ abstract class AbstractMenuContentObject
$menuItems = [];
// Getting current page record NOT overlaid by any translation:
$tsfe = $this->getTypoScriptFrontendController();
$currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $tsfe->page['uid']);
$currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $tsfe->id);
if ($specialValue === 'auto') {
$site = $this->getCurrentSite();
......@@ -607,12 +607,12 @@ abstract class AbstractMenuContentObject
foreach ($languageItems as $sUid) {
// Find overlay record:
if ($sUid) {
$lRecs = $this->sys_page->getPageOverlay($tsfe->page['uid'], $sUid);
$lRecs = $this->sys_page->getPageOverlay($currentPageWithNoOverlay, $sUid);
} else {
$lRecs = [];
}
// Checking if the "disabled" state should be set.
$pageTranslationVisibility = new PageTranslationVisibility((int)($tsfe->page['l18n_cfg'] ?? 0));
$pageTranslationVisibility = new PageTranslationVisibility((int)($currentPageWithNoOverlay['l18n_cfg'] ?? 0));
if ($pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists() && $sUid &&
empty($lRecs) || $pageTranslationVisibility->shouldBeHiddenInDefaultLanguage() &&
(!$sUid || empty($lRecs)) ||
......@@ -648,9 +648,9 @@ abstract class AbstractMenuContentObject
$tsfe = $this->getTypoScriptFrontendController();
$menuItems = [];
if ($specialValue == '') {
$specialValue = $tsfe->page['uid'];
$specialValue = $tsfe->id;
}
$items = GeneralUtility::intExplode(',', $specialValue);
$items = GeneralUtility::intExplode(',', (string)$specialValue);
$pageLinkBuilder = GeneralUtility::makeInstance(PageLinkBuilder::class, $this->parent_cObj);
foreach ($items as $id) {
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps($id);
......@@ -740,9 +740,9 @@ abstract class AbstractMenuContentObject
$tsfe = $this->getTypoScriptFrontendController();
$menuItems = [];
if ($specialValue == '') {
$specialValue = $tsfe->page['uid'];
$specialValue = $tsfe->id;
}
$items = GeneralUtility::intExplode(',', $specialValue);
$items = GeneralUtility::intExplode(',', (string)$specialValue);
if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'] ?? null)) {
$depth = MathUtility::forceIntegerInRange($this->conf['special.']['depth'], 1, 20);
} else {
......@@ -807,7 +807,7 @@ abstract class AbstractMenuContentObject
$menuItems = [];
[$specialValue] = GeneralUtility::intExplode(',', $specialValue);
if (!$specialValue) {
$specialValue = $tsfe->page['uid'];
$specialValue = $tsfe->id;
}
if (($this->conf['special.']['setKeywords'] ?? false) || ($this->conf['special.']['setKeywords.'] ?? false)) {
$kw = (string)$this->parent_cObj->stdWrapValue('setKeywords', $this->conf['special.'] ?? []);
......@@ -903,7 +903,7 @@ abstract class AbstractMenuContentObject
$result = $queryBuilder->execute();
while ($row = $result->fetchAssociative()) {
$tsfe->sys_page->versionOL('pages', $row, true);
$this->sys_page->versionOL('pages', $row, true);
if (is_array($row)) {
$menuItems[$row['uid']] = $this->sys_page->getPageOverlay($row);
}
......
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