Bug #99518
closedCustom page shortcut target for translated page causes errors
0%
Description
If you want to set a custom shortcut target for a translated page, TYPO3 does not resolve the shortcut correctly but runs into an error. I am aware of the already reported bugs relating the shortcuts, but this specific issue seems to be new / undocumented.
Setup:- TYPO3 version 11.5.22
- Simple multilanguage setup
- Shortcut target for default language is Page A
- Shortcut target for second language is Page B with translation behavior "Custom value")
- Shortcut page and shortcut targets are all visible and translated
If you call the translated shortcut page you get an error response depending on the current mode:
In DEBUG mode:
PHP Warning: Undefined array key "uid" in /shared/httpd/vonardenne/files/typo3/public/typo3/sysext/core/Classes/Domain/Repository/PageRepository.php line 1101
The transferred page array does not contain uid / pid as it is an overlay record. Source of this call is the function "checkTranslatedShortcut" in "TyposcriptFrontendController.php".
$originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $languageId);
...
$shortcut = $this->sys_page->resolveShortcutPage($originalShortcutPageOverlay, true);
The call of "resolveShortcutPage" causes the problem. As far as i understand it is correct that "$originalShortcutPageOverlay" does not have uid / pid. Thereby this should not be used as direct argument for "resolveShortcutPage()".
If you call resolveShortcutPage with a merged array of original and overlay record, the warning disappears and we get a valid response from this function. However the shortcut still won't work because there is a followup error, which is the same as in production mode.
In PRODUCTION mode:
Error: Attempt to assign property "rootLine" on null in /shared/httpd/vonardenne/files/typo3/public/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php line 2101
The responsible code (also from function "checkTranslatedShortcut") is:
$this->tmpl->rootLine = array_reverse($this->rootLine);
It looks like the template service is not initilized yet. I am bowing out at this point as i don't know where to fix this.
Updated by Ina Beckmann almost 2 years ago
- Related to Bug #98565: Page type shortcut does not respect translated shortcut target added
- Related to Bug #98566: Wrong link to Shortcut Page target added
Updated by Alexander Schnitzler over 1 year ago
I can confirm this bug with the same TYPO3 and PHP version.
\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::$tmpl
is possibly null
in \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::checkTranslatedShortcut()
.
Updated by Denis Mir over 1 year ago
I can confirm this bug in 11.5.30.
The cause of error lies here in the "\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController"
protected function checkTranslatedShortcut(int $languageId, ServerRequestInterface $request)
{
if (!is_null($this->originalShortcutPage)) {
$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);
}
}
}
"$this->tmpl->rootLine = array_reverse($this->rootLine);" fails due to "$this->tmpl" being null.
Updated by Astrid Haubold about 1 year ago
- Related to Story #101565: Frontend related translation issues added
Updated by Bernhard Eckl 12 months ago · Edited
Same here.
TYPO3 11.5.33
PHP 8.2
Not a real fix, but I avoided the error like this:
if (!is_null($this->tmpl)) {
$this->tmpl->rootLine = array_reverse($this->rootLine);
}
Updated by Riccardo De Contardi 3 months ago
- Related to Bug #100809: Undefined array key when translated shortcut has shortcut as target added
Updated by Riccardo De Contardi 3 months ago
This looks still present on TYPO3 11.5.39 but resolved on 12 and 13 (latest main)
Updated by Riccardo De Contardi 3 months ago
- Status changed from New to Closed
Sorry but I close this issue as it seems solved on version 12 and higher. If you think that this is the wrong decision or experience the issue again or I have misunderstood something, please reopen it or ping me on Slack and I'll do it
Thank you