Breaking: #98377 - Fluid StandaloneView does not create an Extbase Request anymore
See forge#98377
Description
In our efforts to further speed up, streamline and separate Fluid from Extbase,
the \TYPO3\
has been changed to no longer
create an Extbase Request anymore.
StandaloneView is typically not used in Extbase context, creating an Extbase Request at this point was a very unfortunate architectural flaw leading to a not wanted context switch.
Not having an Extbase Request within StandaloneView anymore can have impact on behavior of some Fluid ViewHelpers.
Impact
Common usages of StandaloneView are a frontend related FLUIDTEMPLATE
content object, plus various usages in non-Extbase extensions like rendering eMails
or similar. Within FLUIDTEMPLATE
, the current non-Extbase PSR-7
ServerRequest is actively set to StandaloneView, custom extension usages may need
to $view->set
explicitly.
Some ViewHelpers that rely on Extbase functionality throw exceptions when
a Request is not set, or if the Request is not an Extbase Request. Those will
refuse to work for instance when used in a template triggered by a FLUIDTEMPLATE
content object.
Most notably, all f:
ViewHelpers are affected of this, plus
eventually custom ViewHelpers that access Extbase specific Request
methods.
Affected installations
Instances with extensions using StandaloneView in their code may need attention,
and frontend rendering using FLUIDTEMPLATE
content objects may need
adaptions if Extbase-only ViewHelpers like f:
are used.
Migration
Avoiding f:form
in non-Extbase context
The f:
ViewHelpers are Extbase specific: They especially take care of
handling Extbase internal fields like __
and similar. The casual solution
is to switch these usages away from those ViewHelpers, and use the HTML counterparts
directly, for instance using <input ...>
instead of <f:
.
Custom StandaloneView code
Extensions that instantiate Standalone
may want to $view->set
to hand over the current request to the view, since the request is no longer initialized
automatically. This is needed for ViewHelpers that rely on $rendering
.
Custom ViewHelpers
Custom ViewHelpers used in Standalone
that call methods from Extbase
\TYPO3\
which are not part of
\Psr\
will throw fatal PHP errors.
Possible solutions:
- Create an Extbase Request within a controller and
set
it to the view instance as quick solution.Request () - Properly boot Extbase using the Extbase Bootstrap to have a fully initialized Extbase Request in the View.
- Avoid using Extbase specific methods within the ViewHelper by checking if the
incoming request implements Extbase
\TYPO3\
. This allows creating "hybrid" ViewHelpers that work in both contexts.CMS\ Extbase\ Mvc\ Request Interface - Avoid using Extbase specific methods within the ViewHelper by fetching data from
the given
\Psr\
Request, or it's attached core attributes.Http\ Message\ Server Request Interface