Project

General

Profile

Actions

Bug #97197

closed

Method getServerParams missing in RequestWrapper

Added by Marc Bastian Heinrichs about 2 years ago. Updated 3 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2022-03-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Conditions
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #100595: Unable to call method "getPageType" of object "TYPO3\CMS\Backend\Routing\RouteResult".Closed2023-04-14

Actions
Actions #1

Updated by Marc Bastian Heinrichs about 2 years ago

  • Tags changed from Conditons to Conditions
Actions #2

Updated by Oliver Bartsch about 2 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?

Actions #3

Updated by Marc Bastian Heinrichs about 2 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

Actions #4

Updated by Marc Bastian Heinrichs about 2 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'] ?? '';

Actions #5

Updated by Oliver Bartsch about 2 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).

Actions #6

Updated by Stefan Froemken about 1 year ago

  • Related to Bug #100595: Unable to call method "getPageType" of object "TYPO3\CMS\Backend\Routing\RouteResult". added
Actions #7

Updated by Oliver Bartsch 3 months 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

Actions

Also available in: Atom PDF