Bug #88572
openConfigurationManager returns wrong configuration
0%
Description
My (simplified) page tree looks something like this:
[0] ├─[1] Root Page Site A │ ├─[2] Page 1 │ └─[3] Root Page Site B │ └─[4] Root Page Site C └─[5] MyExt Plugin
This is the configuration for these pages:
[1] Root TS template, site configuration
[3] Root TS template (clear setup + constants NOT set), site configuration
[4] Root TS template (includes static template for MyExt), site configuration
[5] Plugin flexform has an itemsProcFunc which requires a TS setting
In the itemsProcFunc I try to read the TS for MyExt like this:
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManager::class);
$tsConf = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
But this didn't give me the TS for MyExt. However, when I added the static template to [1], I did get the TS for MyExt.
I then debugged $configurationManager and noticed the following, when opening the plugin flexform:
concreteConfigurationManager => TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager
currentPageId => 3 (integer)
The currentPageId doesn't make any sense. But at least it explains, why I'd get the TS for MyExt after adding the static template to page uid [1]...
The Extbase controller of the plugin on [5] gets the correct TS settings. In the TS object browser I get the correct TS configuration when standing on [5]. It's only in the itemsProcFunc, where things seem to go wrong.
I have used this kind of function many times before (T3 < V9) without any problems, but never with site configurations.
Updated by Gerrit Code Review over 4 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63637
Updated by Georg Ringer over 4 years ago
- Related to Feature #90429: ConfigurationManager should offer a way to define the site it is fetching a configuration for added
Updated by Georg Ringer over 4 years ago
- Related to Task #54813: BackendConfigurationManager figures out wrong pid added
Updated by Gerrit Code Review over 4 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63637
Updated by Stefan Froemken over 4 years ago
Hello Michael,
IMO it is wrong to retrieve the TS in BE with Extbase's ConfigurationManager in itemsProcFunc. Please use the TemplateService directly and set ID by yourself instead of using magic of Extbase.
Stefan
Updated by Michael Stopp over 4 years ago
Hi Stefan
Ok. Can you give me a hint on how to do that with TemplateService? I had a quick glance into the API reference, but it wasn't immediately clear to me how this would work.
Updated by Georg Ringer almost 4 years ago
- Related to Bug #93251: getCurrentPageId not working correctly in multisite systems added
Updated by Bastian Zagar over 3 years ago
This is the approach, we are using now.
Thanks to Stefan for the Idea.
Just wanted to share, maybe it can be improved.
$pid = $config['row']['pid']; $rootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($pid); $siterootRow = []; foreach($rootline as $_uid=>$_row) { if($_row['is_siteroot'] == '1') { $siterootRow = $_row; break; } } try { $ts = $this->objectManager->get(\TYPO3\CMS\Core\TypoScript\TemplateService::class,[$siterootRow['uid']]); $ts->rootLine = $rootline; $ts->runThroughTemplates($rootline, 0); $ts->generateConfig(); } catch (\Exception $e) { die($e->getMessage()); } $typoScriptConfig = $ts->setup;
Updated by Benni Mack about 3 years ago
- Status changed from Under Review to Accepted
Updated by Stefan Froemken almost 1 year ago
- Related to Bug #102380: Resolve correct page UID in BackendConfigurationManager added