Bug #97197
closedMethod getServerParams missing in RequestWrapper
0%
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.
Updated by Marc Bastian Heinrichs almost 3 years ago
- Tags changed from Conditons to Conditions
Updated by Oliver Bartsch almost 3 years ago
- 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?
Updated by Marc Bastian Heinrichs almost 3 years ago
Hi, yes, I use getNormalizedParams now. But the documentation, if I get it right, explicit recommend to use
$request->getServerParams()['HTTP_USER_AGENT']
instead of
->getNormalizedParams()
See: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestHandling/Typo3Request.html
Updated by Marc Bastian Heinrichs almost 3 years ago
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'] ?? '';
Updated by Oliver Bartsch almost 3 years ago
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).
Updated by Stefan Froemken almost 2 years ago
- Related to Bug #100595: Unable to call method "getPageType" of object "TYPO3\CMS\Backend\Routing\RouteResult". added
Updated by Oliver Bartsch about 1 year ago
- 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