Project

General

Profile

Actions

Bug #99518

open

Custom page shortcut target for translated page causes errors

Added by Ina Beckmann over 1 year ago. Updated 5 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2023-01-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 3 (1 open2 closed)

Related to TYPO3 Core - Bug #98565: Page type shortcut does not respect translated shortcut targetResolved2022-10-10

Actions
Related to TYPO3 Core - Bug #98566: Wrong link to Shortcut Page targetResolved2022-10-10

Actions
Related to TYPO3 Core - Story #101565: Frontend related translation issuesNew2023-08-03

Actions
Actions #1

Updated by Ina Beckmann over 1 year 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
Actions #2

Updated by Alexander Schnitzler about 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().

Actions #3

Updated by Denis Mir 9 months 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.

Actions #4

Updated by Astrid Haubold 6 months ago

  • Related to Story #101565: Frontend related translation issues added
Actions #5

Updated by Bernhard Eckl 5 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);
}

Actions

Also available in: Atom PDF