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

[BUGFIX] Check for excludeUidList in HMENU of default language

This change now always checks for the actual page ID
in the default language, not of the translated page
to see if the page should be excluded.

Resolves: #94427
Releases: main, 11.5
Change-Id: I89c67b7955ccb69af28accbcf573576156919481
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72802


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent ad0aa9a5
......@@ -1109,7 +1109,11 @@ abstract class AbstractMenuContentObject
if (in_array((int)($data['doktype'] ?? 0), $this->excludedDoktypes, true)) {
return false;
}
// PageID should not be banned
$languageId = $this->getCurrentLanguageAspect()->getId();
// PageID should not be banned (check for default language pages as well)
if (($data['_PAGES_OVERLAY_UID'] ?? 0) > 0 && in_array((int)($data['_PAGES_OVERLAY_UID'] ?? 0), $banUidArray, true)) {
return false;
}
if (in_array((int)($data['uid'] ?? 0), $banUidArray, true)) {
return false;
}
......@@ -1122,10 +1126,10 @@ abstract class AbstractMenuContentObject
return false;
}
// Checking if the link should point to the default language so links to non-accessible pages will not happen
if ($this->getCurrentLanguageAspect()->getId() > 0 && !empty($this->conf['protectLvar'])) {
if ($languageId > 0 && !empty($this->conf['protectLvar'])) {
$pageTranslationVisibility = new PageTranslationVisibility((int)($data['l18n_cfg'] ?? 0));
if ($this->conf['protectLvar'] === 'all' || $pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists()) {
$olRec = $this->sys_page->getPageOverlay($data['uid'], $this->getCurrentLanguageAspect()->getId());
$olRec = $this->sys_page->getPageOverlay($data['uid'], $languageId);
if (empty($olRec)) {
// If no page translation record then page can NOT be accessed in
// the language pointed to, therefore we protect the link by linking to the default language
......@@ -1478,8 +1482,11 @@ abstract class AbstractMenuContentObject
if ($pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists() && $languageId > 0 && !($theRec['_PAGES_OVERLAY'] ?? false)) {
continue;
}
// No valid subpage if the subpage is banned by excludeUidList
if (in_array((int)$theRec['uid'], $bannedUids, true)) {
// No valid subpage if the subpage is banned by excludeUidList (check for default language pages as well)
if (($theRec['_PAGES_OVERLAY_UID'] ?? 0) > 0 && in_array((int)($theRec['_PAGES_OVERLAY_UID'] ?? 0), $bannedUids, true)) {
continue;
}
if (in_array((int)($theRec['uid'] ?? 0), $bannedUids, true)) {
continue;
}
$hasSubPages = true;
......
......@@ -988,6 +988,70 @@ class SlugLinkGeneratorTest extends AbstractTestCase
self::assertSame($expectation, $json);
}
public function hierarchicalMenuAlwaysResolvesToDefaultLanguageDataProvider(): array
{
return [
'no banned IDs in default language' => [
'language' => 0,
'banned IDs' => '',
'expected menu items' => 13,
],
'no banned IDs in FR' => [
'language' => 1,
'banned IDs' => '',
'expected menu items' => 13,
],
'banned IDs in default language' => [
'language' => 0,
'banned IDs' => '1100,1200,1300,1400,403,404',
'expected menu items' => 7,
],
'banned IDs in FR language' => [
'language' => 1,
'banned IDs' => '1100,1200,1300,1400,403,404',
'expected menu items' => 7,
],
'banned translated IDs in default language' => [
'language' => 0,
'banned IDs' => '1101,1200,1300,1400,403,404',
'expected menu items' => 8,
],
'banned translated IDs in FR language' => [
'language' => 1,
'banned IDs' => '1101,1200,1300,1400,403,404',
'expected menu items' => 7,
],
];
}
/**
* Checks that excludeUidList checks against translated pages and default-language page IDs.
*
* @test
* @dataProvider hierarchicalMenuAlwaysResolvesToDefaultLanguageDataProvider
*/
public function hierarchicalMenuAlwaysResolvesToDefaultLanguage(int $languageId, string $excludedUidList, int $expectedMenuItems): void
{
$response = $this->executeFrontendSubRequest(
(new InternalRequest('https://acme.us/'))
->withPageId(1100)
->withLanguageId($languageId)
->withInstructions([
$this->createHierarchicalMenuProcessorInstruction([
'levels' => 1,
'entryLevel' => 0,
'excludeUidList' => $excludedUidList,
'expandAll' => 1,
'includeSpacer' => 1,
'titleField' => 'title',
]),
])
);
$json = json_decode((string)$response->getBody(), true);
self::assertSame($expectedMenuItems, count($json));
}
public function directoryMenuIsGeneratedDataProvider(): array
{
return [
......
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