Bug #97197
closed
Method getServerParams missing in RequestWrapper
Added by Marc Bastian Heinrichs about 2 years ago.
Updated 3 months ago.
Description
Using [request.getServerParams() && request.getServerParams()['HTTP_USER_AGENT'] == "Foo"]
results in some requests (still to be debugged when) in logged exception: "RuntimeException: Unable to call method "getServerParams" of object "TYPO3\CMS\\Core\ExpressionLanguage\RequestWrapper\.
IMO in any case getServerParams should be added to the RequestWrapper, too.
- Tags changed from Conditons to Conditions
- Status changed from New to Needs Feedback
Hi, thanks for creating an issue.
The the ServerParams
are available as "normalized params" using the getNormalizedParams()
method.
In your case this would therefore be:
[request.getNormalizedParams() && request.getNormalizedParams().getHttpUserAgent() == "Foo"]
Could you please check, whether this works for you?
Also see in class NormalizedParams
// @deprecated Below variables can be fully deprecated as soon as core does not use them anymore
$this->pathInfo = $serverParams['PATH_INFO'] ?? '';
$this->httpReferer = $serverParams['HTTP_REFERER'] ?? '';
$this->httpUserAgent = $serverParams['HTTP_USER_AGENT'] ?? '';
$this->httpAcceptEncoding = $serverParams['HTTP_ACCEPT_ENCODING'] ?? '';
$this->httpAcceptLanguage = $serverParams['HTTP_ACCEPT_LANGUAGE'] ?? '';
$this->remoteHost = $serverParams['REMOTE_HOST'] ?? '';
$this->queryString = $serverParams['QUERY_STRING'] ?? '';
Hi thanks for your feedback. As far as I can see does the linked documentation only referrer to the direct usage of the PSR-7 Request object in e.g a PSR-15 middleware, where the full data is available.
For the use in TypoScript conditions, the RequestWrapper only exposes a couple of the request data. While you are right about the code comments in NormalizedParams
, the functionality is not yet (12.0-dev) officially deprecated. If this happens anytime in the future, an alternative for those data in the RequestWrapper will be added and documented accordingly.
For now I think using request.getNormalizedParams().getHttpUserAgent()
is the way to go (for at least v10 and v11, and most likely even v12).
- Related to Bug #100595: Unable to call method "getPageType" of object "TYPO3\CMS\Backend\Routing\RouteResult". added
- Status changed from Needs Feedback to Closed
Hi, I'm closing this for now as the status is still the same and the issue is on needs feedback for more than two years. In case you think this is the wrong decision, please contact me or create a new issue with reference to this one.
Best, Oli
Also available in: Atom
PDF