Project

General

Profile

Actions

Bug #99957

closed

configurationManager::getConfiguration sometimes returns empty result when called from Middleware

Added by Mordamir about 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2023-02-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

For our website we have 2 middleware scripts. They both are near the end of the frontend middleware stack.

frontend
    typo3/cms-frontend/timetracker = TYPO3\CMS\Frontend\Middleware\TimeTrackerInitialization
    typo3/cms-core/normalized-params-attribute = TYPO3\CMS\Core\Middleware\NormalizedParamsAttribute
*** REMOVED LOTS OF MIDDLEWARES ***
    typo3/cms-frontend/content-length-headers = TYPO3\CMS\Frontend\Middleware\ContentLengthResponseHeader
    dirkpersky/plain-rendering-handler = DirkPersky\DpCookieconsent\Middleware\PlainRenderingMiddleware
->    ***/***/current-project = ***\***\Middleware\CurrentProject
->    ***/***/project-update = ***\***\Middleware\ProjectUpdate
    aoe/crawler/initialization = AOE\Crawler\Middleware\CrawlerInitialization
    typo3/cms-frontend/output-compression = TYPO3\CMS\Frontend\Middleware\OutputCompression

For them to work correctly the need some values from the typoscript configuration. We do this by:
    $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
    $settings = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'EXTENSION_KEY');

It was working a long time. Since 2 weeks now this call does return inconsistent results. Sometimes the $settings-Array is empty and sometimes it contains the values it should have.
The question now is, how it could be possible that the result of the getConfiguration call is sometimes empty?
There was no update in typo3 or php version. The request url is always the same.
Currently i dont know if the configuration array is empty at all or if only the extension related entries are missing.
What could i do to debug this issue?

Actions #1

Updated by Alexander Schnitzler about 1 year ago

I cannot say why it doesn't behave deterministic but I can tell that in order to work, the configuration manager needs to access the typoscript which is set up while booting the TypoScriptFrontendController. If a middleware is executed before this step, TS is missing and the configuration manager returns null.

Actions #2

Updated by Mordamir about 1 year ago

Alexander Schnitzler wrote in #note-1:

the configuration manager needs to access the typoscript which is set up while booting the TypoScriptFrontendController. If a middleware is executed before this step, TS is missing and the configuration manager returns null.

Thats my understanding of this process. One of the middleware i removed from listing above was:

typo3/cms-frontend/tsfe = TYPO3\CMS\Frontend\Middleware\TypoScriptFrontendInitialization

i, think thats the middleware initializing the typoscript. Thats also the reason why i placed my own middlewares near the end of the stack so it is running after initializing typoscript.

Actions #3

Updated by Mordamir about 1 year ago

Further investigations show that the whole $GLOBALS['TSFE']->tmpl->setup is null, so the getConfiguration call could not find anything.
Also it turns out that the getConfiguration call works as expected as long as there is no homepage cached. If i clear the cache of the homepage, the middleware works as expected as long as there is no normal homepage call. The relation to the homepage comes from the normal call to the middleware as this uses the old eID schema (http://some.where/?eID=middleware). So i think what happens is that if i call the middleware with a cached homepage, typo3 thinks it do not need to initialize the TSFE typoscript array, because the cached homepage does not need that.
So i think the solution is that i have somehow to manage that typo3 do not think the page is cached if there is an eID parameter in the url.

Actions #4

Updated by Henrik Jensen about 1 year ago

We also have the issue. It happens very sporadic but we had the it twice now.

Middleware

'after' => ['typo3-cms/frontend/site']

Code:
$configurationManagerInterface = $commonFactory->getConfigurationManagerInterface();
$typoScript = $configurationManagerInterface->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);

$typoScript is empty

Problem is that a lot of code is dependent on the ts settings.

I´ve changed the Middleware to run after 'typo3/cms-frontend/tsfe' now to see if that makes a difference.

Actions #5

Updated by Stefan Froemken 11 months ago

  • Status changed from New to Closed

Hello

Thanks for your info. All extbase classes are intended for use in plugin context only. Using extbases classes in middleware or in page context may lead to invalid cache entries. I had that problem, too, and it costs me 3 days of investigation to find out, that the cache was filled with a reduced set of TSFE which leads to curious problems within the next FE requests. After a clear cache everything works again. If such an eID or middleware (using extbase classes) was called first just after a clear cache, the cache was filled with invalid data.

Please try to use non-extbase classes to prevent invalid cache entries and you can use $GLOBALS['TSFE']->tmpl->setup directly until TYPO3 12.

I will close the ticket now. If you feel this is the wrong decision, let me know, and I will re-open it.

Stefan

Actions

Also available in: Atom PDF