3

I use the TYPO3\CMS\Frontend\DataProcessing\FilesProcessor to access FAL Images

dataProcessing {
    20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
    20 {
        references.fieldName = image
        as = images
    }
}

the use of<f:uri.image image="{images.0}" /> works fine but {f:uri.image(image:'{images.0}')} or {f:uri.image(image:images.0)}

gives me a FE Error:

#1: PHP Warning: htmlspecialchars() expects parameter 1 to be string, object given in typo3_cms8/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/EscapingNode.php line 41

Info: in 7.LTS the code works

andreas
  • 16,357
  • 12
  • 72
  • 76
bschauer
  • 958
  • 9
  • 33
  • If the code works and just throws a warning, I would ignore it and turn off the warnings. Actually there are a lot of warnings in Typo3 / Extbase like Array/String expected but got null, etc. – Dimitri L. Sep 02 '16 at 11:30
  • Please do not disable warnings. TYPO3 in general works without warnings if done correctly. Everything else is a real and valid bug and should therefor be fixed in the core system. Please report your issue with steps to reproduce at forge.typo3.org. Thank you. – Susi Sep 02 '16 at 14:56

1 Answers1

4

This is caused by two things in combination:

  • The {images.0} variable is an object and has no __toString method
  • The parameter is passed wrapped in a TextNode in the provided inline example

To correct this problem avoid wrapping the object accessor in a text node:

{f:uri(image: images.0)}

For a much more detailed explanation about this you can view my video about the subject: Mastering Fluid - Accessing Variables.

I should also add that we are indeed aware of this edge case of variables which are incompatible with strings being wrapped in a TextNode. So far the decision is that we would rather allow this edge case to slip through and avoid adding a condition that would need to check every variable in every template which cumulative would be billions upon billions of conditions with the single goal of avoiding this warning.

Claus Due
  • 4,166
  • 11
  • 23