Project

General

Profile

Actions

Bug #96823

open

<f:image src="{file-path-to-image}"> with config.absRefPrefix not working in TYPO3 11

Added by Martin Weymayer almost 3 years ago. Updated 7 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2022-02-11
Due date:
% Done:

0%

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

Description

If you user <f:image src="{file-path-to-image}"> together with config.absRefPrefix = https://www.domain.at/ an error will occure:
Supplied https://www.domain.at/fileadmin/user_upload/anim.gif could not be resolved to a File or FileReference.

Actions #1

Updated by Bastian Bringenberg almost 3 years ago

  • Project changed from 9 to TYPO3 Core
  • Category deleted (Content)
  • TYPO3 Version set to 11

Moved to right project and changed TYPO3 Version.

Actions #2

Updated by Oliver Hader almost 3 years ago

  • Category set to Frontend

Do you have by chance a stack trace of mentioned exception at hand?

Actions #3

Updated by Martin Weymayer almost 3 years ago

in /html/typo3/typo3_src-11.5.5/typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php line 203

            // thrown if file does not exist
            throw new Exception($e->getMessage(), 1509741911, $e);
        } catch (\UnexpectedValueException $e) {
            // thrown if a file has been replaced with a folder
            throw new Exception($e->getMessage(), 1509741912, $e);
        } catch (\RuntimeException $e) {
            // RuntimeException thrown if a file is outside of a storage
            throw new Exception($e->getMessage(), 1509741913, $e);
        } catch (\InvalidArgumentException $e) {

at TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper->render()
at call_user_func(array(object(TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper), 'render'))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 264

     */
    protected function callRenderMethod()
    {
        if (method_exists($this, 'render')) {
            return call_user_func([$this, 'render']);
        }
        if ((new \ReflectionMethod($this, 'renderStatic'))->getDeclaringClass()->getName() !== AbstractViewHelper::class) {
            // Method is safe to call - will not recurse through ViewHelperInvoker via the default
            // implementation of renderStatic() on this class.

at TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper->callRenderMethod()
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 252

    {
        $this->validateArguments();
        $this->initialize();

        return $this->callRenderMethod();
    }

    /**
     * Call the render() method and handle errors.

at TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper->initializeArgumentsAndRender()
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/ViewHelperInvoker.php line 79

            }
            $viewHelper->setRenderingContext($renderingContext);
            $viewHelper->setArguments($evaluatedArguments);
            $viewHelper->handleAdditionalArguments($undeclaredArguments);
            return $viewHelper->initializeArgumentsAndRender();
        } catch (Exception $error) {
            return $renderingContext->getErrorHandler()->handleViewHelperError($error);
        }
    }

at TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker->invoke(object(TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper), array('src' => object(TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode)), object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/ViewHelperNode.php line 150

     * @return string evaluated node after the view helper has been called.
     */
    public function evaluate(RenderingContextInterface $renderingContext)
    {
        return $renderingContext->getViewHelperInvoker()->invoke($this->uninitializedViewHelper, $this->arguments, $renderingContext);
    }
}

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode->evaluate(object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/AbstractNode.php line 56

     * @return mixed
     */
    protected function evaluateChildNode(NodeInterface $node, RenderingContextInterface $renderingContext, $cast)
    {
        $output = $node->evaluate($renderingContext);
        if ($cast) {
            $output = $this->castToString($output);
        }
        return $output;

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\AbstractNode->evaluateChildNode(object(TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode), object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext), false)
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/AbstractNode.php line 36

    public function evaluateChildNodes(RenderingContextInterface $renderingContext)
    {
        $evaluatedNodes = [];
        foreach ($this->getChildNodes() as $childNode) {
            $evaluatedNodes[] = $this->evaluateChildNode($childNode, $renderingContext, false);
        }
        // Make decisions about what to actually return
        if (empty($evaluatedNodes)) {
            return null;

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\AbstractNode->evaluateChildNodes(object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 306

        if ($this->renderChildrenClosure !== null) {
            $closure = $this->renderChildrenClosure;
            return $closure();
        }
        return $this->viewHelperNode->evaluateChildNodes($this->renderingContext);
    }

    /**
     * Helper which is mostly needed when calling renderStatic() from within

at TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper->renderChildren()
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 321

    protected function buildRenderChildrenClosure()
    {
        $self = clone $this;
        return function() use ($self) {
            return $self->renderChildren();
        };
    }

    /**

at TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper->TYPO3Fluid\Fluid\Core\ViewHelper\{closure}()
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/ViewHelpers/ForViewHelper.php line 148

                $templateVariableContainer->add($arguments['iteration'], $iterationData);
                $iterationData['index']++;
                $iterationData['cycle']++;
            }
            $output .= $renderChildrenClosure();
            $templateVariableContainer->remove($arguments['as']);
            if (isset($arguments['key'])) {
                $templateVariableContainer->remove($arguments['key']);
            }

at TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper::renderStatic(array('each' => array(object(TYPO3\CMS\Core\Resource\FileReference)), 'as' => 'file', 'key' => null, 'reverse' => false, 'iteration' => null), object(Closure), object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/Traits/CompileWithRenderStatic.php line 30

    {
        return static::renderStatic(
            $this->arguments,
            $this->buildRenderChildrenClosure(),
            $this->renderingContext
        );
    }

    /**

at TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper->render()
at call_user_func(array(object(TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper), 'render'))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 264

     */
    protected function callRenderMethod()
    {
        if (method_exists($this, 'render')) {
            return call_user_func([$this, 'render']);
        }
        if ((new \ReflectionMethod($this, 'renderStatic'))->getDeclaringClass()->getName() !== AbstractViewHelper::class) {
            // Method is safe to call - will not recurse through ViewHelperInvoker via the default
            // implementation of renderStatic() on this class.

at TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper->callRenderMethod()
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php line 252

    {
        $this->validateArguments();
        $this->initialize();

        return $this->callRenderMethod();
    }

    /**
     * Call the render() method and handle errors.

at TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper->initializeArgumentsAndRender()
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/ViewHelper/ViewHelperInvoker.php line 79

            }
            $viewHelper->setRenderingContext($renderingContext);
            $viewHelper->setArguments($evaluatedArguments);
            $viewHelper->handleAdditionalArguments($undeclaredArguments);
            return $viewHelper->initializeArgumentsAndRender();
        } catch (Exception $error) {
            return $renderingContext->getErrorHandler()->handleViewHelperError($error);
        }
    }

at TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker->invoke(object(TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper), array('each' => object(TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode), 'as' => object(TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\TextNode)), object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/ViewHelperNode.php line 150

     * @return string evaluated node after the view helper has been called.
     */
    public function evaluate(RenderingContextInterface $renderingContext)
    {
        return $renderingContext->getViewHelperInvoker()->invoke($this->uninitializedViewHelper, $this->arguments, $renderingContext);
    }
}

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode->evaluate(object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/AbstractNode.php line 56

     * @return mixed
     */
    protected function evaluateChildNode(NodeInterface $node, RenderingContextInterface $renderingContext, $cast)
    {
        $output = $node->evaluate($renderingContext);
        if ($cast) {
            $output = $this->castToString($output);
        }
        return $output;

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\AbstractNode->evaluateChildNode(object(TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode), object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext), false)
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/AbstractNode.php line 36

    public function evaluateChildNodes(RenderingContextInterface $renderingContext)
    {
        $evaluatedNodes = [];
        foreach ($this->getChildNodes() as $childNode) {
            $evaluatedNodes[] = $this->evaluateChildNode($childNode, $renderingContext, false);
        }
        // Make decisions about what to actually return
        if (empty($evaluatedNodes)) {
            return null;

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\AbstractNode->evaluateChildNodes(object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/RootNode.php line 25

     * @return mixed Evaluated subtree
     */
    public function evaluate(RenderingContextInterface $renderingContext)
    {
        return $this->evaluateChildNodes($renderingContext);
    }
}

at TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode->evaluate(object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/Core/Parser/ParsingState.php line 119

     * @return string Rendered string
     */
    public function render(RenderingContextInterface $renderingContext)
    {
        return $this->getRootNode()->evaluate($renderingContext);
    }

    /**
     * Push a node to the node stack. The node stack holds all currently open

at TYPO3Fluid\Fluid\Core\Parser\ParsingState->render(object(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext))
in /html/typo3/typo3_src-11.5.5/vendor/typo3fluid/fluid/src/View/AbstractTemplateView.php line 186

        }

        if (!$parsedTemplate->hasLayout()) {
            $this->startRendering(self::RENDERING_TEMPLATE, $parsedTemplate, $this->baseRenderingContext);
            $output = $parsedTemplate->render($this->baseRenderingContext);
            $this->stopRendering();
        } else {
            $layoutName = $parsedTemplate->getLayoutName($this->baseRenderingContext);
            try {

at TYPO3Fluid\Fluid\View\AbstractTemplateView->render()
in /html/typo3/typo3_src-11.5.5/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php line 341

     * @return string
     */
    protected function renderFluidView()
    {
        return $this->view->render();
    }

    /**
     * Apply standard wrap to content

at TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject->renderFluidView()
in /html/typo3/typo3_src-11.5.5/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php line 106

        $this->view->assignMultiple($variables);

        $this->renderFluidTemplateAssetsIntoPageRenderer();
        $content = $this->renderFluidView();
        $content = $this->applyStandardWrapToRenderedContent($content, $conf);

        $this->view = $parentView;
        return $content;

at TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject->render(array('templateRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Templates/'), 'partialRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Partials/'), 'layoutRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Layouts/'), 'dataProcessing.' => array('MASK\\Mask\\DataProcessing\\MaskProcessor'), 'templateName' => 'TextUndAnimiertesGifJe50'))
in /html/typo3/typo3_src-11.5.5/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 800

        }

        // 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(MASK\Mask\Fluid\FluidTemplateContentObject), array('templateRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Templates/'), 'partialRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Partials/'), 'layoutRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Layouts/'), 'dataProcessing.' => array('MASK\\Mask\\DataProcessing\\MaskProcessor'), 'templateName' => 'TextUndAnimiertesGifJe50'))
in /html/typo3/typo3_src-11.5.5/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 736

            $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('FLUIDTEMPLATE', array('templateRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Templates/'), 'partialRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Partials/'), 'layoutRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Layouts/'), 'dataProcessing.' => array('MASK\\Mask\\DataProcessing\\MaskProcessor'), 'templateName' => 'TextUndAnimiertesGifJe50'), 'lib.maskContentElement')
in /html/typo3/typo3_src-11.5.5/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php line 731

            [$name, $conf] = $cF->getVal($key, $this->getTypoScriptFrontendController()->tmpl->setup);
            $conf = array_replace_recursive($conf, $confOverride);
            // Getting the cObject
            $timeTracker->incStackPointer();
            $content .= $this->cObjGetSingle($name, $conf, $key);
            $timeTracker->decStackPointer();
        } else {
            $contentObject = $this->getContentObject($name);
            if ($contentObject) {

at TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->cObjGetSingle('FLUIDTEMPLATE', array('templateRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Templates/'), 'partialRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Partials/'), 'layoutRootPaths.' => array('typo3conf/ext/mw_theme/Resources/Private/Mask/Frontend/Layouts/'), 'dataProcessing.' => array('MASK\\Mask\\DataProcessing\\MaskProcessor'), 'templateName' => 'TextUndAnimiertesGifJe50'), 'tt_content.mask_text_und_animiertes_gif_je_50')
in /html/typo3/typo3_src-11.5.5/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php line 197

        if ($timeTracker->LR) {
            $timeTracker->push('/f:cObject/', '<' . $typoscriptObjectPath);
        }
        $timeTracker->incStackPointer();
        $content = $contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'] ?? [], $typoscriptObjectPath);
        $timeTracker->decStackPointer();
        if ($timeTracker->LR) {
            $timeTracker->pull($content);
        }

at TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper::renderContentObject(object(TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer), array('key.' => 
Actions #4

Updated by Oliver Hader almost 3 years ago

https://github.com/TYPO3/typo3/blob/1c1975d0d6e7a1894c7f8749417394ffaa18771f/typo3/sysext/extbase/Classes/Service/ImageService.php#L134

.. is the candidate (a few lines below, there's the exception message that has been reported initially).

Thus, the question is, where fileadmin/user_upload/anim.gif gets extended to https://www.domain.at/fileadmin/user_upload/anim.gif and handed in to that method.

Actions #5

Updated by Martin Weymayer almost 3 years ago

Sorry, I do not understand your question. I can not answer it. This is a fluid template with MASK extension

Actions #6

Updated by Markus Slaby about 2 years ago

Martin Weymayer wrote:

If you user <f:image src="{file-path-to-image}"> together with config.absRefPrefix = https://www.domain.at/ an error will occure:
Supplied https://www.domain.at/fileadmin/user_upload/anim.gif could not be resolved to a File or FileReference.

I have the same problem here in a fluid page layout, while using an image from page resources. I use TYPO3 11.5.16 with php 8.1.5

Actions #7

Updated by Jan Kornblum 7 months ago

Same here with TYPO3 11.5.36 and PHP 8.3 when using config.absRefPrefix = https://www.domain.tld/

Actions

Also available in: Atom PDF