#99004PHP 8.1 warning in /typo3/sysext/frontend/Classes/ContentObject/ImageResourceContentObject.php
Description
In this function:
public function render($conf = [])
{
$imageResource = NULL;
$lastImgResourceInfo = $this->cObj->getImgResource($conf['file'] ?? '', $conf['file.'] ?? []);
if ($this->hasTypoScriptFrontendController()) {
$this->getTypoScriptFrontendController()->lastImgResourceInfo = $lastImgResourceInfo;
}
if (!is_array($lastImgResourceInfo)) {
return '';
}
$imageResource = $lastImgResourceInfo[3];
return isset($conf['stdWrap.']) ? $this->cObj->stdWrap($imageResource, $conf['stdWrap.']) : $imageResource;
}
public function render($conf = [])
{
$imageResource = NULL;
$lastImgResourceInfo = $this->cObj->getImgResource($conf['file'] ?? '', $conf['file.'] ?? []);
if ($this->hasTypoScriptFrontendController()) {
$this->getTypoScriptFrontendController()->lastImgResourceInfo = $lastImgResourceInfo;
}
if (!is_array($lastImgResourceInfo)) {
return '';
}
if (isset($lastImgResourceInfo[3])){
$imageResource = $lastImgResourceInfo[3];
}
return isset($conf['stdWrap.']) ? $this->cObj->stdWrap($imageResource, $conf['stdWrap.']) : $imageResource;
}
under some circumstances $lastImgResourceInfo3 won’t be set.
This results in a php warning.
Maybe change likt this?
public function render($conf = [])
{
$imageResource = NULL;
$lastImgResourceInfo = $this->cObj->getImgResource($conf['file'] ?? '', $conf['file.'] ?? []);
if ($this->hasTypoScriptFrontendController()) {
$this->getTypoScriptFrontendController()->lastImgResourceInfo = $lastImgResourceInfo;
}
if (!is_array($lastImgResourceInfo)) {
return '';
}
if (isset($lastImgResourceInfo[3])){
$imageResource = $lastImgResourceInfo[3];
}
return isset($conf['stdWrap.']) ? $this->cObj->stdWrap($imageResource, $conf['stdWrap.']) : $imageResource;
}