diff --git a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php index 561d89e0036df1378ecafd5ccb3f4e6748ce32c6..4e1f4db6eb1114bbe3505c79d4528e2ab098e6c5 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php @@ -1299,9 +1299,6 @@ abstract class AbstractMenuContentObject [], true ); - if (isset($menuItem['_PAGES_OVERLAY_LANGUAGE'])) { - $shortcut = $tsfe->sys_page->getPageOverlay($shortcut, $menuItem['_PAGES_OVERLAY_LANGUAGE']); - } } catch (\Exception $ex) { } if (!is_array($shortcut)) { @@ -1311,7 +1308,7 @@ abstract class AbstractMenuContentObject // Only setting url, not target $LD['totalURL'] = $this->parent_cObj->typoLink_URL([ 'parameter' => $shortcut['uid'], - 'language' => $shortcut['_PAGES_OVERLAY_REQUESTEDLANGUAGE'] ?? 'current', + 'language' => $menuItem['_PAGES_OVERLAY_REQUESTEDLANGUAGE'] ?? 'current', 'additionalParams' => $addParams . $this->I['val']['additionalParams'] . ($menuItem['_ADD_GETVARS'] ?? ''), 'linkAccessRestrictedPages' => !empty($this->mconf['showAccessRestrictedPages']), ]); diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioG.yaml b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioG.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe414c98062ef5017293d5c2ce0b4d34816ce6ea --- /dev/null +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioG.yaml @@ -0,0 +1,52 @@ +__variables: + - &pageStandard 0 + - &pageShortcut 4 + - &contentText 'text' + - &idAcmeRootPage 1000 + +entitySettings: + '*': + nodeColumnName: 'pid' + columnNames: {id: 'uid', language: 'sys_language_uid'} + defaultValues: {pid: 0} + page: + isNode: true + tableName: 'pages' + parentColumnName: 'pid' + languageColumnNames: ['l10n_parent', 'l10n_source'] + columnNames: {type: 'doktype', root: 'is_siteroot', mount: 'mount_pid', visitorGroups: 'fe_group'} + defaultValues: {hidden: 0, doktype: *pageStandard} + valueInstructions: + shortcut: + first: {shortcut: 0, shortcut_mode: 1} + content: + tableName: 'tt_content' + languageColumnNames: ['l18n_parent', 'l10n_source'] + columnNames: {title: 'header', type: 'CType', column: 'colPos'} + defaultValues: {hidden: 0, type: *contentText, column: 0} + language: + tableName: 'sys_language' + columnNames: {code: 'language_isocode'} + typoscript: + tableName: 'sys_template' + valueInstructions: + type: + site: {root: 1, clear: 1} + +entities: + language: + - self: {id: 1, title: 'German', code: 'de'} + - self: {id: 2, title: 'Swiss German', code: 'de'} + page: + - self: {id: *idAcmeRootPage, title: 'EN: Root', root: true, slug: '/'} + children: + - self: {id: 1100, title: 'EN: Welcome', slug: '/hello'} + languageVariants: + - self: { id: 1101, title: 'DE: Willkommen', language: 1, slug: '/willkommen' } + - self: { id: 1102, title: 'DE-CH: Willkommen', language: 2, slug: '/willkommen' } + - self: {id: 1200, title: 'EN: About us', slug: '/about-us'} + languageVariants: + - self: {id: 1201, title: 'DE: Über uns', language: 1, slug: '/ueber-uns'} + - self: {id: 1300, title: 'EN: Shortcut to about', slug: '/shortcut-to-about', type: *pageShortcut, shortcut: 1200, l18n_cfg: 0, l10n_state: '{"shortcut":"custom"}'} + languageVariants: + - self: {id: 1301, title: 'DE: Abkürzung zu Über uns', language: 1, slug: '/shortcut-to-about', type: *pageShortcut, shortcut: 1200, l18n_cfg: 0, l10n_state: '{"shortcut":"custom"}'} diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioGTest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioGTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7b686d9a81bc333849763c502dd79b5829a63565 --- /dev/null +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioGTest.php @@ -0,0 +1,84 @@ +<?php + +declare(strict_types=1); + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRendering; + +/** + * Scenario prerequisites: + * Site configuration has localizations + * default language: EN + * first language: DE + * no fallbacks configured + * second language: DE-CH + * fallback to DE, EN + * + * Home page is localized into DE + * + * This scenario covers the issue for https://forge.typo3.org/issues/94677 + * + * Generated menu shortcut links, which point to an untranslated page, but + * have a fallback in place, should keep the current language and not switch + * to the translation language. + */ +class ScenarioGTest extends AbstractLocalizedPagesTestCase +{ + protected function setUp(): void + { + parent::setUp(); + + $this->writeSiteConfiguration( + 'acme-com', + $this->buildSiteConfiguration(1000, 'https://acme.com/'), + [ + $this->buildDefaultLanguageConfiguration('EN', 'https://acme.com/en'), + $this->buildLanguageConfiguration('DE', 'https://acme.com/de'), + $this->buildLanguageConfiguration('DE-CH', 'https://acme.com/de-ch', ['DE', 'EN']), + ] + ); + + $this->setUpDatabaseWithYamlPayload(__DIR__ . '/Fixtures/ScenarioG.yaml'); + } + + /** + * @return array + */ + public function menuDataProvider(): array + { + return [ + [ + 'url' => 'https://acme.com/de-ch/willkommen', + 'menu' => [ + ['title' => 'DE-CH: Willkommen', 'link' => '/de-ch/willkommen'], + ['title' => 'DE: Über uns', 'link' => '/de-ch/ueber-uns'], + ['title' => 'DE: Abkürzung zu Über uns', 'link' => '/de-ch/ueber-uns'], + ], + ], + ]; + } + + /** + * @param string $url + * @param array $expectedMenu + * + * @test + * @dataProvider menuDataProvider + */ + public function pageMenuIsRendered(string $url, array $expectedMenu): void + { + $this->assertMenu($url, $expectedMenu); + } +}