Bug #78800
closedTCEForms Broken when TSFE is initialized during datamap-hook
0%
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(); } } }
Updated by Florian Bachmann almost 8 years ago
- Subject changed from TCEForms Broker when TSFE is initialized during datamap-hook to TCEForms Broken when TSFE is initialized during datamap-hook
Updated by Mathias Schreiber almost 8 years ago
- Status changed from New to Needs Feedback
- Assignee set to Mathias Schreiber
can you describe the usecase a bit better?
We're under the impression that your way of solving the issue is... somewhat wrong.
Updated by Florian Bachmann almost 8 years ago
Dear Mathias,
I have the requirement, that whenever an url in the cms changes, an entry to a redirects-table is written, which causes old urls to 301-redirect to new ones. This should consider pages, pages_language_overlay as well as news and some kind of custom record.
I am fully aware, that this function will not work for every thinkable variant of possible realurl-configuration, but for the scope of this project it should be doable that way.
I think this hook is the place the code should run. As far as I know, the only other option would be, to fill that entry in the redirect-table without destination-url, and update it asynchronously. E.g. after typolink-generation in frontend (same typolink-hook, that realurl-encoding makes use of), or via scheduler with manually instantiated frontend as well.
For proper typolink-ing I need an instantiated frontend. The typolink-functionality also does currently work, it is just stripped from the example above, since it is independend from the bug, and I wanted to provide a most minimal example for reproduction.
To clarify - everything already build in that extension works. The exception is, that after (fully successful) saving a record in the backend, the TCE-Form of the page-object is empty (all values in the form are blank). After reload (close/edit) the correct data is shown in the form.
Updated by Frederik Holz over 7 years ago
Mathias Schreiber wrote:
can you describe the usecase a bit better?
We're under the impression that your way of solving the issue is... somewhat wrong.
Hey Mathias,
I got a similar problem using a "fake" TSFE in the processDatamap_afterDatabaseOperations hook. I just want to use typolink_URL. Everythink works fine and the TSFE is generated and used by the hook, but after saving the form and reloading the frame, I can't interact with any tabs or the form. The problem is a JS-Error in the console
404 - not found mydomain.com/typo3/typo3/sysext/core/Resources/Public/JavaScript/Contrib/jquery/jquery-2.1.4.min.js
so after that i get like 4-5 errors like "jQuery is not defined" etc. The path /typo3/typo3/ is most probably wrong, but why? If I trigger the hook without initialising the TSFE everthing works fine.
By choosing the same page or form via the pagetree the error is gone and the form is correctly saved. So its just a JS-Error on reload of the form after initialising the TSFE via a hook.
Used/Tested in the current 7 LTS (7.6.16)
Updated by Alexander Opitz about 7 years ago
- Category set to DataHandler aka TCEmain
- Status changed from Needs Feedback to New
- Assignee deleted (
Mathias Schreiber)
Updated by Paul Beck over 6 years ago
I had the same problem. It seems like initializing the TSFE in the Backend changed the "backPath" property of the typo3_src-7.6.23/typo3/sysext/core/Classes/Page/PageRenderer.php to "typo3/" which causes included JS libs to contain /typo3/typo3/ in their resulting backend URI. Setting the backPath in the Hook after initializing the TSFE solves the issue provisionally.
/** @var \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer */
$pageRenderer = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->setBackPath('');
Updated by Georg Ringer about 6 years ago
- Status changed from New to Closed
with 9 it is now possible to create correct links everywhere without faking stuff. therefore I am closing this issue. nothing will be changed in 8