Project

General

Profile

Actions

Bug #72600

open

Singleton ConfigurationManager creates problems with nested extbase plugins

Added by Robert Vock over 8 years ago. Updated over 5 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2016-01-08
Due date:
% Done:

0%

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

Description

This bug is a bit complicated to describe.

Currently the extbase ConfigurationManager is a singleton which has a state, for example AbstractConfigurationManager::$extensionName

When one extbase plugin calls cObjGetSingle on typoscript which also contains an extbase plugin, the configuration manager will hold incorrect values for the first plugin after the call.

This happens for example in the powermail extension, which allows fields to render a TypoScript object path. After rendering the typoscript, all calls to configurationManager->getConfiguration will return the configuration of the other plugin.

Another shortened example:

# TypoScript
page = PAGE
page.10  = USER
page.10 {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Plugin1
    pluginName = plugin1
    vendorName = Plugin1
}

lib.plugin2  = USER
lib.plugin2 {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Plugin2
    pluginName = plugin2
    vendorName = Plugin2
}

# Plugin1Controller.php
class Plugin1Controller extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
    public function plugin1Action() {
        $correct = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
        $string = $this->configurationManager->getContentObject()->cObjGetSingle('USER', $GLOBALS['TSFE']->tmpl->setup['lib.']['plugin2.']);
        $incorrect = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
    }
}

Plugin1 renders TypoScript which contains Plugin2. Afterwards Plugin1 cannot get it's own configuration.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #82033: extbase parameters in FLUIDTEMPLATE : configuration lost for extension FormNew2017-08-03

Actions
Actions #1

Updated by Robert Vock over 8 years ago

It might be possible to fix this problem in Bootstrap::run.

If the current configuration is cached before the request is handled, it can be restored AFTER the request has finished:

public function run($content, $configuration)
{
    // cache current state of configuration manager
    $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
    $configurationManager = $objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
    $oldCObject = $configurationManager->getContentObject();
    $oldConfiguration = $configurationManager->getConfiguration($configurationManager::CONFIGURATION_TYPE_FRAMEWORK);
    $typoScriptService = $objectManager->get(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
    $oldConfiguration = $typoScriptService->convertPlainArrayToTypoScriptArray($oldConfiguration);

    // perform normal initialization and request
    $this->initialize($configuration);

    $result = $this->handleRequest();

    // restore state of configuration manager
    $this->configurationManager->setContentObject($oldCObject);
    $this->configurationManager->setConfiguration($oldConfiguration);

    return $result;
}

This worked for me, but I am not sure if there are any downsides to this.

Actions #2

Updated by Manfred Egger over 5 years ago

I can confirm this problem and I also have a similar problem with FLUIDTEMPLATE ContentObject, but I couldn't get the workaround code working. Problem occurs in TYPO3 8.7 and 9.5 as well.

Edit: I guess that https://forge.typo3.org/issues/82033 has the same cause.

Actions #3

Updated by Benni Mack about 4 years ago

  • Related to Bug #82033: extbase parameters in FLUIDTEMPLATE : configuration lost for extension Form added
Actions

Also available in: Atom PDF