Skip to content

Commit

Permalink
[BUGFIX] Prevent null pointer exception in ContentObjectRenderer
Browse files Browse the repository at this point in the history
The $request might not be initialized, that's
why the getRequest() method has to be used in
ContentObjectRenderer.

This is now done for newly introduced occurrences,
accessing the class property directly.

Resolves: #103407
Releases: main
Change-Id: I466f31316b2885132288cbc8745f3dc4760bdcf2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83497
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
o-ba authored and bnf committed Mar 18, 2024
1 parent d3e492e commit 9ebc397
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -4149,7 +4149,7 @@ protected function rootLineValue($key, $field, $slideBack = false, $altRootLine
if (is_array($altRootLine)) {
$rootLine = $altRootLine;
} else {
$rootLine = $this->request->getAttribute('frontend.page.information')->getLocalRootLine();
$rootLine = $this->getRequest()->getAttribute('frontend.page.information')->getLocalRootLine();
}
if (!$slideBack) {
return $rootLine[$key][$field] ?? '';
Expand Down Expand Up @@ -4806,7 +4806,7 @@ public function getQuery(Connection $connection, string $table, array $conf): st
$pidList = GeneralUtility::trimExplode(',', $conf['pidInList'], true);
array_walk($pidList, function (&$storagePid) {
if ($storagePid === 'this') {
$storagePid = $this->request->getAttribute('frontend.page.information')->getId();
$storagePid = $this->getRequest()->getAttribute('frontend.page.information')->getId();
}
});
$pageRepository = $this->getPageRepository();
Expand Down Expand Up @@ -5170,7 +5170,7 @@ public function checkPidArray($pageIds)
return [];
}

if ($pageIds === [$this->request->getAttribute('frontend.page.information')->getId()]) {
if ($pageIds === [$this->getRequest()->getAttribute('frontend.page.information')->getId()]) {
// Middlewares already checked access to the current page and made sure the current doktype
// is a doktype whose content should be rendered, so there is no need to check that again.
return $pageIds;
Expand Down

0 comments on commit 9ebc397

Please sign in to comment.