Skip to content

Commit

Permalink
[BUGFIX] Fix return type in RequestWrapper
Browse files Browse the repository at this point in the history
In case TypoScript conditions are evaluated in
the backend, e.g. in extbase modules, usage
of `getPageArguments()` might led to exceptions,
because in backend context, no PageArguments
object is available.

This is now fixed and a corresponding example
is adjusted.

Resolves: #100567
Related: #100405
Releases: main
Change-Id: Ibee0fa8b509b1552bdcf003ff154e70229215d08
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78602
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
o-ba authored and sbuerk committed Apr 12, 2023
1 parent 7357c91 commit c4d7c4d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Routing\RouteResultInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;

Expand Down Expand Up @@ -127,7 +127,7 @@ public function getNormalizedParams(): ?NormalizedParams
return $this->request->getAttribute('normalizedParams');
}

public function getPageArguments(): ?RouteResultInterface
public function getPageArguments(): ?PageArguments
{
trigger_error(
'Using conditions based on request data within page TSconfig or user TSconfig has been deprecated' .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Routing\RouteResultInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;

Expand Down Expand Up @@ -81,8 +81,8 @@ public function getNormalizedParams(): ?NormalizedParams
return $this->request->getAttribute('normalizedParams');
}

public function getPageArguments(): ?RouteResultInterface
public function getPageArguments(): ?PageArguments
{
return $this->request->getAttribute('routing');
return ($routing = $this->request->getAttribute('routing')) instanceof PageArguments ? $routing : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ the request object is not available.
Within TypoScript, conditions and getData properties need to be adapted:

Before: :typoscript:`[getTSFE() && getTSFE().type == 13]`
After: :typoscript:`[request.getPageArguments().getPageType() == 13]`
After: :typoscript:`[request.getPageArguments()?.getPageType() == 13]`

In Typoscript getData attributes:

Expand Down

0 comments on commit c4d7c4d

Please sign in to comment.