Project

General

Profile

Actions

Bug #100834

closed

Undefined array key 0 in ImageContentObject

Added by Patrick Lenk over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2023-05-08
Due date:
% Done:

0%

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

Description

E.g. image added with typoscript from a field, but field is empty.

PHP Warning: Undefined array key 0 in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php line 89
in /var/www/html/private/typo3/sysext/core/Classes/Error/ErrorHandler.php line 137

        }

        $message = self::ERROR_LEVEL_LABELS[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine;
        if ($errorLevel & $this->exceptionalErrors) {
            throw new Exception($message, 1476107295);
        }

        $message = $this->getFormattedLogMessage($message);

at TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'Undefined array key 0', '/var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php', 89)
in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php line 89

            $params = ' ' . $params;
        }

        $imageTagValues = [
            'width' =>  (int)$info[0],
            'height' => (int)$info[1],
            'src' => htmlspecialchars($source),
            'params' => $params,
            'altParams' => $altParam,

at TYPO3\CMS\Frontend\ContentObject\ImageContentObject->cImage('', array('file.' => array('treatIdAsReference' => '1', 'import.' => array('data' => 'file:current:publicUrl'), 'crop.' => array('data' => 'file:current:crop'), 'maxW' => '80'), 'params' => 'style="width:80px;max-width:none;margin-top:0;margin-bottom:0;display:block;border-style:none;outline-style:none;text-decoration:none;text-align:center;"'))
in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php line 41

        if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
            return '';
        }

        $theValue = $this->cImage($conf['file'] ?? '', $conf);
        if (isset($conf['stdWrap.'])) {
            $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
        }
        return $theValue;

at TYPO3\CMS\Frontend\ContentObject\ImageContentObject->render(array('file.' => array('treatIdAsReference' => '1', 'import.' => array('data' => 'file:current:publicUrl'), 'crop.' => array('data' => 'file:current:crop'), 'maxW' => '80'), 'params' => 'style="width:80px;max-width:none;margin-top:0;margin-bottom:0;display:block;border-style:none;outline-style:none;text-decoration:none;text-align:center;"'))
in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 801

        }

        // Render content
        try {
            $content .= $contentObject->render($configuration);
        } catch (ContentRenderingException $exception) {
            // Content rendering Exceptions indicate a critical problem which should not be
            // caught e.g. when something went wrong with Exception handling itself
            throw $exception;

at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->render(object(TYPO3\CMS\Frontend\ContentObject\ImageContentObject), array('file.' => array('treatIdAsReference' => '1', 'import.' => array('data' => 'file:current:publicUrl'), 'crop.' => array('data' => 'file:current:crop'), 'maxW' => '80'), 'params' => 'style="width:80px;max-width:none;margin-top:0;margin-bottom:0;display:block;border-style:none;outline-style:none;text-decoration:none;text-align:center;"'))
Actions #1

Updated by Thomas Hohn over 1 year ago

Could you add the typoscript snippet?

Actions #2

Updated by Patrick Lenk over 1 year ago

can be closed. file:current:publicUrl seems not working anymore. changed to file:current:uid and the issue is gone.

Actions #3

Updated by Thomas Hohn over 1 year ago

  • Status changed from New to Closed

Not a bug

Actions #4

Updated by David Bruchmann over 1 year ago

As the keys are explicitly used and related to the internal logic, I'd indeed value it as a bug.

Btw: file:current:publicUrl is still working, I just have it used.
It might be though that it's not working anymore for IMAGE or IMG_RESOURCE, I used it in TEXT, where it shows the result like expected.

Actions

Also available in: Atom PDF