Bug #99004
closedPHP 8.1 warning in /typo3/sysext/frontend/Classes/ContentObject/ImageResourceContentObject.php
100%
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;
}
Updated by Thomas Hohn over 1 year ago
Du you remember what the warning was? Was it just accessing key 3?
Updated by Thomas Hohn over 1 year ago
- Assignee set to Thomas Hohn
- Target version set to Candidate for patchlevel
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77999
Updated by Ralph Brugger over 1 year ago
Thomas Hohn wrote in #note-1:
Du you remember what the warning was? Was it just accessing key 3?
Yes, I can't find the log entry but I'm pretty sure that it was:
warning... array... key [3]
Updated by Thomas Hohn over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset a7ab07dc44d0f2d49c0a308260b152cc3e6d3ca6.
Updated by Gerrit Code Review over 1 year ago
- Status changed from Resolved to Under Review
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78003
Updated by Gerrit Code Review over 1 year ago
Patch set 2 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78003
Updated by Thomas Hohn over 1 year ago
- Status changed from Under Review to Resolved
Applied in changeset dd1ba442a59c42ec7e7f1ac11a0920661d7b5d4e.