Project

General

Profile

Actions

Bug #88572

open

ConfigurationManager returns wrong configuration

Added by Michael Stopp over 5 years ago. Updated about 3 years ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2019-06-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 4 (1 open3 closed)

Related to TYPO3 Core - Feature #90429: ConfigurationManager should offer a way to define the site it is fetching a configuration forClosed2020-02-19

Actions
Related to TYPO3 Core - Task #54813: BackendConfigurationManager figures out wrong pidClosed2014-01-07

Actions
Related to TYPO3 Core - Bug #93251: getCurrentPageId not working correctly in multisite systemsNew2021-01-08

Actions
Related to TYPO3 Core - Bug #102380: Resolve correct page UID in BackendConfigurationManagerClosed2023-11-16

Actions
Actions #1

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

Actions #2

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
Actions #3

Updated by Georg Ringer over 4 years ago

  • Related to Task #54813: BackendConfigurationManager figures out wrong pid added
Actions #4

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

Actions #5

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

Actions #6

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.

Actions #7

Updated by Georg Ringer almost 4 years ago

  • Related to Bug #93251: getCurrentPageId not working correctly in multisite systems added
Actions #8

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;
Actions #9

Updated by Benni Mack about 3 years ago

  • Status changed from Under Review to Accepted
Actions #10

Updated by Stefan Froemken almost 1 year ago

  • Related to Bug #102380: Resolve correct page UID in BackendConfigurationManager added
Actions

Also available in: Atom PDF