Bug #79694

PHP warning on using inline Fluid syntax with object

Added by Oliver Hader over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2017-02-08
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
Stabilization Sprint

Description

Using the tag-based view-helper <f:format.date date="{user.dateOfBirth}" /> works like a charm.
However, using {f:format.date(date:'{user.dateOfBirth}')} leads to the following PHP warning:

The property dateOfBirth is a \DateTime object in this example.

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

Working on dev-master with commit 12fd6b6ae7a14ca22d9f0cfa6cf9bcaa62046f4a

History

#1 Updated by Oliver Hader over 2 years ago

  • Description updated (diff)

#2 Updated by Oliver Hader over 2 years ago

  • Sprint Focus set to Stabilization Sprint

#3 Updated by Oliver Hader over 2 years ago

  • Description updated (diff)

#4 Updated by Georg Ringer over 2 years ago

however using something like {f:format.date(date:newsItem.datetime)} (without single quotes) works fine

#5 Updated by Claus Due over 2 years ago

This 5-minute video explains why and how to avoid it: https://vimeo.com/167666466

TL;DR: `'{variable}'` is the same as `(string) $variable` in PHP.

#6 Updated by Georg Ringer over 2 years ago

  • Status changed from New to Needs Feedback

should we close it then?

#7 Updated by Claus Due over 2 years ago

I would close this as "by design". Hopefully people will catch on that this intentional wrapping in TextNode implies you absolutely want a string value.

#8 Updated by Riccardo De Contardi over 2 years ago

  • Status changed from Needs Feedback to Closed

Closing it as suggested by Claus Due and in agreement with the issue reporter.

@todo: mention this (IMHO useful) information in the documentation

Also available in: Atom PDF