rest
rest copied to clipboard
Wrong ConfigurationManager initialized in TYPO3 v11
The global TYPO3_REQUEST is not yet present in the middleware when the ConfigurationManager gets initialized. Threfore Extbase can not determine correctly the application mode and the BackendConfigurationManager is loaded. This leads to issues when using extbase plugins. Extbase doesn't load the plugin configurations...
Quick solution is a middleware which sets the global variable before the rest middleware.
Thank you for opening this issue.
Can you tell me a bit more about the impact of this? Does it affect to default CRUD handler and custom handlers?
It looks like you already put some research into this. Could you give me a hint on where this should be set? Maybe as a workaround we could set $GLOBALS['TYPO3_REQUEST']
in RestMiddleware
.
I think he meant the following behavior: When the middleware "RestMiddleware" is called and it calls the ConfigurationManager via the Rest MiddlewareBootstrap before "$GLOBALS['TYPO3_REQUEST']" is set, which is set by "TypoScriptFrontendInitialization" or "PrepareTypoScriptFrontendRendering". In the typo3/sysext/extbase/Classes/Configuration/ConfigurationManager.php:47 there are the following If during initialization:
{
if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()
) {
$this->concreteConfigurationManager = $this->container->get(FrontendConfigurationManager::class);
} else {
$this->concreteConfigurationManager = $this->container->get(BackendConfigurationManager::class);
}
}
Because the middleware is listed before the set, the ConfigurationManager loads the BackendConfigurationManager and therefore the settings set by the user cannot be loaded.
Because of this I had an access "Deny" for all my urls.
As a solution I set the variable "$GLOBALS['TYPO3_REQUEST']" in the middleware "RestMiddleware". I'm unsure if this has any side effects, but so far I couldn't find any.
{
if ($this->isRestRequest($request)) {
+ $GLOBALS['TYPO3_REQUEST'] = $request;
$middlewareBootstrap = new MiddlewareBootstrap();
$frontendController = $middlewareBootstrap->bootstrapCore($request);
$languageEnhancedRequest = $middlewareBootstrap->bootstrapLanguage($frontendController, $request);
Thank you for the clarification.
I added the code in the v6 branch.