Skip to content

Commit

Permalink
[BUGFIX] Avoid calling trim(null) in PageRenderer
Browse files Browse the repository at this point in the history
PageRender sanitizes array values in two methods, using
array walk with trim(). These values can be other
types then string, which trigger deprecation warning in
PHP 8.1.

This patch change the array walk to an closure to have
an explicit type cast to string for passing the value
to trim().

Additional a return type ': string' is added to the
protected method getTemplate(), as this method always
returns a string.

Resolves: #95788
Releases: master
Change-Id: Id0cdef928f977fdc1a9d476475bd3a44c5783922
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71984
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
sbuerk authored and lolli42 committed Oct 26, 2021
1 parent 8e48aff commit 177b087
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions typo3/sysext/core/Classes/Page/PageRenderer.php
Expand Up @@ -1924,7 +1924,7 @@ protected function getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cs
'JS_INLINE_FOOTER' => $jsFooterInline,
'BODY' => $this->bodyContent,
];
$markerArray = array_map('trim', $markerArray);
$markerArray = array_map(static fn ($item) => (trim((string)$item)), $markerArray);
return $markerArray;
}

Expand Down Expand Up @@ -1959,7 +1959,7 @@ protected function getPreparedMarkerArrayForPageWithUncachedObjects($substituteH
'JS_INCLUDE_FOOTER' => '<!-- ###JS_INCLUDE_FOOTER' . $substituteHash . '### -->',
'JS_INLINE_FOOTER' => '<!-- ###JS_INLINE_FOOTER' . $substituteHash . '### -->',
];
$markerArray = array_map('trim', $markerArray);
$markerArray = array_map(static fn ($item) => (trim((string)$item)), $markerArray);
return $markerArray;
}

Expand All @@ -1968,7 +1968,7 @@ protected function getPreparedMarkerArrayForPageWithUncachedObjects($substituteH
*
* @return string
*/
protected function getTemplate()
protected function getTemplate(): string
{
$templateFile = GeneralUtility::getFileAbsFileName($this->templateFile);
if (is_file($templateFile)) {
Expand Down

0 comments on commit 177b087

Please sign in to comment.