Project

General

Profile

Actions

Bug #99444

open

Core: Exception handler (WEB: FE): Error, code #0, file TypoScriptFrontendController.php, line 2099: Attempt to assign property "rootLine" on null

Added by Ian Solo almost 2 years ago. Updated 4 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2023-01-02
Due date:
% Done:

0%

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

Description

Generated by Googlebot visiting a translated page that is a shortcut to another page like:
http://domain.ext/es/soporte/
that is a shortcut to page with uid=3

PHP error log:
Mon, 02 Jan 2023 08:38:14 +0100 [WARNING] request="31bc2c162961e" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: Undefined array key "uid" in typo3/sysext/core/Classes/Domain/Repository/PageRepository.php line 1101
Mon, 02 Jan 2023 08:38:14 +0100 [WARNING] request="31bc2c162961e" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: Undefined array key "uid" in typo3/sysext/core/Classes/Domain/Repository/PageRepository.php line 1112
Mon, 02 Jan 2023 08:38:14 +0100 [CRITICAL] request="31bc2c162961e" component="TYPO3.CMS.Core.Error.ProductionExceptionHandler": Core: Exception handler (WEB: FE): Error, code #0, file typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php, line 2099: Attempt to assign property "rootLine" on null - {"mode":"WEB","application_mode":"FE","exception_class":"Error","exception_code":0,"file":"typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php","line":2099,"message":"Attempt to assign property \"rootLine\" on null","request_url":"https://domain.ext/es/soporte/","exception":null}

Actions #1

Updated by Gerhard Pazout almost 2 years ago

I have the same error!

Steps to reproduce:
  1. Translate a page thats a shortcut (doktype = shortcut)
  2. For "Shortcut Mode" set "Translation behaviour" to "Custom value".
  3. For "Shortcut Target" set "Translation behaviour" to "Custom value".
  4. For the translated page the "Shortcut Target" has to be different than in the original page (important)

Expected result:
Exception in Frontend that says:

Attempt to assign property "rootLine" on null

The error occurs because in \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $this->tmpl is not set before the function checkTranslatedShortcut gets called!

How I fixed it:
In the class \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController inside the function checkTranslatedShortcut add the following line so that $this->tmpl is not null anymore:

if (!$this->tmpl instanceof TemplateService) {
   $this->tmpl = GeneralUtility::makeInstance(TemplateService::class, $this->context, null, $this);
}

So the function checkTranslatedShortcut looks like this:

    /**
     * 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->tmpl instanceof TemplateService) {
            $this->tmpl = GeneralUtility::makeInstance(TemplateService::class, $this->context, null, $this);
        }

        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);
            }
        }
    }

Actions #2

Updated by Bernhard Eckl over 1 year ago

Same here. Your fix works also for me. Thank you!

TYPO3 11.5.30
PHP 8.2

Actions #3

Updated by Garvin Hicking 4 months ago

  • Category set to TypoScript
Actions

Also available in: Atom PDF