Project

General

Profile

Actions

Bug #99004

closed

PHP 8.1 warning in /typo3/sysext/frontend/Classes/ContentObject/ImageResourceContentObject.php

Added by Ralph Brugger over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Frontend
Start date:
2022-11-05
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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;
    }

Actions #1

Updated by Thomas Hohn about 1 year ago

Hi @Ralph Brugger

Du you remember what the warning was? Was it just accessing key 3?

Actions #2

Updated by Thomas Hohn about 1 year ago

  • Assignee set to Thomas Hohn
  • Target version set to Candidate for patchlevel
Actions #3

Updated by Gerrit Code Review about 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

Actions #4

Updated by Ralph Brugger about 1 year ago

Thomas Hohn wrote in #note-1:

Hi @Ralph Brugger

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]

Actions #5

Updated by Thomas Hohn about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #6

Updated by Gerrit Code Review about 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

Actions #7

Updated by Gerrit Code Review about 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

Actions #8

Updated by Thomas Hohn about 1 year ago

  • Status changed from Under Review to Resolved
Actions #9

Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF