rupertgermann / tt_news

TYPO3 Extension - News (tt_news)
21 stars 37 forks source link

TypeError TYPO3\CMS\Core\Page\AssetCollector::addMedia() must be of the type string, null given #199

Closed Patta closed 1 year ago

Patta commented 1 year ago

ddev, composer PHP 7.4 TYPO3 11.5.24 tt_news feature/typo3-v11 useFluidRendering = 1

I just upgraded to TYPO3 v11 and test the feature/typo3-v11 branch. On any page with a tt_news plugin the following error occurs. With tt_news v10.1.0 it worked.

(1/1) TypeError

Argument 1 passed to TYPO3\CMS\Core\Page\AssetCollector::addMedia() must be of the type string, null given, 
called in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php on line 74

in /var/www/html/private/typo3/sysext/core/Classes/Page/AssetCollector.php line 159

     * @param string $fileName
     * @param array $additionalInformation One dimensional hash map (array with non numerical keys) with scalar values
     * @return AssetCollector
     */
    public function addMedia(string $fileName, array $additionalInformation): self
    {
        $existingAdditionalInformation = $this->media[$fileName] ?? [];
        ArrayUtility::mergeRecursiveWithOverrule($existingAdditionalInformation, $this->ensureAllValuesAreSerializable($additionalInformation));
        $this->media[$fileName] = $existingAdditionalInformation;

at TYPO3\CMS\Core\Page\AssetCollector->addMedia(null, array('origFile' => 'REMOVED.jpg', 'origFile_mtime' => false))
in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php line 74

        // Remove file objects for AssetCollector, as it only allows to store scalar values
        $infoOriginalFile = $info['originalFile'] ?? null;
        unset($info['originalFile'], $info['processedFile']);
        GeneralUtility::makeInstance(AssetCollector::class)->addMedia(
            $source,
            $info
        );

        $layoutKey = (string)$this->cObj->stdWrapValue('layoutKey', $conf ?? []);

at TYPO3\CMS\Frontend\ContentObject\ImageContentObject->cImage('REMOVED.jpg', array('file.' => array('maxH' => '', 'width' => '1920m'), 'imageLinkWrap' => '1', 'stdWrap.' => array('spaceAfter' => '0'), 'altText' => '', 'titleText' => '', 'file' => 'https://REMOVED.jpg'))
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('maxH' => '', 'width' => '1920m'), 'imageLinkWrap' => '1', 'stdWrap.' => array('spaceAfter' => '0'), 'altText' => '', 'titleText' => '', 'file' => 'https://REMOVED.jpg'))
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('maxH' => '', 'width' => '1920m'), 'imageLinkWrap' => '1', 'stdWrap.' => array('spaceAfter' => '0'), 'altText' => '', 'titleText' => '', 'file' => 'https://REMOVED.jpg'))
in /var/www/html/private/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 737

            $timeTracker->decStackPointer();
        } else {
            $contentObject = $this->getContentObject($name);
            if ($contentObject) {
                $content .= $this->render($contentObject, $conf);
            }
        }
        if ($timeTracker->LR) {
            $timeTracker->pull($content);

at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->cObjGetSingle('IMAGE', array('file.' => array('maxH' => '', 'width' => '1920m'), 'imageLinkWrap' => '1', 'stdWrap.' => array('spaceAfter' => '0'), 'altText' => '', 'titleText' => '', 'file' => 'https://REMOVED.jpg'))
in /var/www/html/private/typo3conf/ext/tt_news/Classes/Plugin/TtNews.php line 2700

                        $lConf['image.']['titleText'] = $imgsTitleTexts[$cc];
                        $lConf['image.']['file'] = $imgPath . $val;

                        $theImgCode .= $this->local_cObj->cObjGetSingle('IMAGE',
                                $lConf['image.']) . $this->local_cObj->stdWrap($imgsCaptions[$cc],
                                $lConf['caption_stdWrap.']);
                    }

                    $cc++;
Patta commented 1 year ago

Can be avoided by set imageCount and catImageMode in setup to 0. This is wired, because the image markers are not used, only fluid image rendering.

Patta commented 1 year ago

If image markers are used (legacy templates), the images are missing now.

Patta commented 1 year ago

Its an core issue: https://forge.typo3.org/issues/100132