Commit 82e79aed authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[TASK] Remove special handling of translated shortcuts

When a page is hit in TYPO3 v12.0, the page translation
is automatically applied nowadays. Before, this
was only possible if TypoScript was applied (finding out
the config.sys_language_uid TypoScript setting etc).

For this reason, the functionality can be removed.

Same applies for determineOriginalShortcutPage()
which is not needed anymore since "pages_language_overlay"
is migrated into "pages" and "allowLanguageSynchronization"
is active.

Resolves: #96540
Releases: main
Change-Id: I5158dc62dc5a404e14b0685f4d177fb47723cd82
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72864

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 702aa612
......@@ -393,7 +393,6 @@ abstract class AbstractMenuContentObject
$begin = is_array($beginConf) ? $this->parent_cObj->stdWrap($begin, $beginConf) : $begin;
$this->menuArr = [];
foreach ($menuItems as &$data) {
$data = $this->determineOriginalShortcutPage($data);
$data['isSpacer'] = ($data['isSpacer'] ?? false) || (int)($data['doktype'] ?? 0) === PageRepository::DOKTYPE_SPACER || ($data['ITEM_STATE'] ?? '') === 'SPC';
}
$menuItems = $this->removeInaccessiblePages($menuItems);
......@@ -1256,36 +1255,6 @@ abstract class AbstractMenuContentObject
return $attrs;
}
/**
* Determines original shortcut destination in page overlays.
*
* Since the pages records used for menu rendering are overlaid by default,
* the original 'shortcut' value is lost, if a translation did not define one.
*
* @param array $page
* @return array
*/
protected function determineOriginalShortcutPage(array $page)
{
// Check if modification is required
if (
$this->getCurrentLanguageAspect()->getId() > 0
&& empty($page['shortcut'])
&& !empty($page['uid'])
&& !empty($page['_PAGES_OVERLAY'])
&& !empty($page['_PAGES_OVERLAY_UID'])
) {
// Using raw record since the record was overlaid and is correct already:
$originalPage = $this->sys_page->getRawRecord('pages', $page['uid']);
if ($originalPage['shortcut_mode'] === $page['shortcut_mode'] && !empty($originalPage['shortcut'])) {
$page['shortcut'] = $originalPage['shortcut'];
}
}
return $page;
}
/**
* Creates a submenu level to the current level - if configured for.
*
......
......@@ -152,7 +152,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
public $contentPid = 0;
/**
* Gets set when we are processing a page of type mounpoint with enabled overlay in getPageAndRootline()
* Gets set when we are processing a page of type mountpoint with enabled overlay in getPageAndRootline()
* Used later in checkPageForMountpointRedirect() to determine the final target URL where the user
* should be redirected to.
*
......@@ -162,11 +162,9 @@ class TypoScriptFrontendController implements LoggerAwareInterface
/**
* Gets set when we are processing a page of type shortcut in the early stages
* of the request when we do not know about languages yet, used later in the request
* to determine the correct shortcut in case a translation changes the shortcut
* target
* of the request, used later in the request to resolve the shortcut and redirect again.
*
* @var array|null
* @see checkTranslatedShortcut()
*/
protected $originalShortcutPage;
......@@ -1873,10 +1871,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface
$pageTranslationVisibility = new PageTranslationVisibility((int)($this->page['l18n_cfg'] ?? 0));
// If sys_language_uid is set to another language than default:
if ($languageAspect->getId() > 0) {
// check whether a shortcut is overwritten by a translated page
// we can only do this now, as this is the place where we get
// to know about translations
$this->checkTranslatedShortcut($languageAspect->getId(), $request);
// Request the overlay record for the sys_language_uid:
$olRec = $this->sys_page->getPageOverlay($this->id, $languageAspect->getId());
if (empty($olRec)) {
......@@ -1990,31 +1984,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface
}
}
/**
* Checks whether a translated shortcut page has a different shortcut
* target than the original language page.
* If that is the case, things get corrected to follow that alternative
* shortcut
* @param int $languageId
* @param ServerRequestInterface $request
*/
protected function checkTranslatedShortcut(int $languageId, ServerRequestInterface $request)
{
if ($this->originalShortcutPage !== null) {
$originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $languageId);
if (!empty($originalShortcutPageOverlay['shortcut']) && $originalShortcutPageOverlay['shortcut'] != $this->id) {
// the translation of the original shortcut page has a different shortcut target!
// set the correct page and id
$shortcut = $this->sys_page->resolveShortcutPage($originalShortcutPageOverlay, true);
$this->id = ($this->contentPid = $shortcut['uid']);
$this->page = $this->sys_page->getPage($this->id);
// Fix various effects on things like menus f.e.
$this->fetch_the_id($request);
$this->tmpl->rootLine = array_reverse($this->rootLine);
}
}
}
/**
* Calculates and sets the internal linkVars based upon the current request parameters
* and the setting "config.linkVars".
......
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