Project

General

Profile

Actions

Bug #99004

closed

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

Added by Ralph Brugger about 2 years ago. Updated over 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

Also available in: Atom PDF