Project

General

Profile

Actions

Bug #78800

closed

TCEForms Broken when TSFE is initialized during datamap-hook

Added by Florian Bachmann almost 8 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2016-11-25
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

I have created an extension which makes use of typolink when a record is saved in the backend.
The save-procedure works flawless, but the resulting form (save, not save and close) is empty, instead of showing the updated data.

To reproduce register a datamap-hook in ext_localconf.php

$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['company_redirects'] = Vendor\Company\TceDatamap::class;

In the most minimal version that class contains the following code (which does nothing but produce the error)

namespace Vendor\Company;
class TceDatamap
{
    public function processDatamap_afterDatabaseOperations($status, $table, $recordId, $databaseData, $pObj)
    {
     if ($table=='pages' && $status == 'update') {
        $this->ensureTSFE($recordId);
     }   
    }
    protected function ensureTSFE($id = 1, $typeNum = 0)
    {
        if (!$GLOBALS['TSFE']) {
            \TYPO3\CMS\Frontend\Utility\EidUtility::initTCA();
            if (!is_object($GLOBALS['TT'])) {
                $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
                $GLOBALS['TT']->start();
            }
            $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $id, $typeNum);
            $GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
            $GLOBALS['TSFE']->sys_page->init(TRUE);
            $GLOBALS['TSFE']->initFEuser();
            $GLOBALS['TSFE']->determineId();
            $GLOBALS['TSFE']->initTemplate();
            $GLOBALS['TSFE']->rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($id, '');
            $GLOBALS['TSFE']->getConfigArray();
        }
    }
}
Actions

Also available in: Atom PDF