Bug #91560
open
ActionController::forward() not work with different target controller - Needs better error description
Added by Markus Pircher about 4 years ago.
Updated over 3 years ago.
Description
I use a forward in one action to an action in another controller. With version <= 9.5 it worked without any problems. But with 10.4 the controller class cannot be found.
TYPO3\CMS\Extbase\Mvc::controllerAliasToClassNameMapping has only the mapping of the controller for the first action.
The error was that the action in the flexform was not allowed. There would be a better error message here if the controller could not be found or a fallback with a warning.
Can confirm
In a regular plugin configured with ExtensionUtility::configurePlugin
, if the controller that is being forwarded to is not listed in the $controllerActions
argument, then the forward will fail with an obscure "class not found" error message, without any indications of where the error originates from, or what class it's talking about (because it's working with an empty string).
My suggestion would be to either allow the full controller class name to ActionController::forward, instead of just the Alias, or throw an error if the class could not be found in the forward method.
The first method seems more reasonable, since it matches what ExtensionUtility::configurePlugin
expects.
Lars Peter Søndergaard wrote in #note-1:
My suggestion would be to either allow the full controller class name to ActionController::forward, instead of just the Alias, or throw an error if the class could not be found in the forward method.
The first method seems more reasonable, since it matches what ExtensionUtility::configurePlugin
expects.
There is a "work around" so far. Before forwarding you have to set:
$this->getControllerContext()->getRequest()->setControllerAliasToClassNameMapping(
['ControllerAlias' => FullControllerClassName::class]
);
$this->forward('actionName', 'ControllerAlias', 'ExtensionName');
Also available in: Atom
PDF