Project

General

Profile

Actions

Bug #79694

closed

PHP warning on using inline Fluid syntax with object

Added by Oliver Hader about 7 years ago. Updated almost 7 years ago.

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

0%

Estimated time:
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

Actions #1

Updated by Oliver Hader about 7 years ago

  • Description updated (diff)
Actions #2

Updated by Oliver Hader about 7 years ago

  • Sprint Focus set to Stabilization Sprint
Actions #3

Updated by Oliver Hader about 7 years ago

  • Description updated (diff)
Actions #4

Updated by Georg Ringer about 7 years ago

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

Actions #5

Updated by Claus Due about 7 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.

Actions #6

Updated by Georg Ringer about 7 years ago

  • Status changed from New to Needs Feedback

should we close it then?

Actions #7

Updated by Claus Due about 7 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.

Actions #8

Updated by Riccardo De Contardi almost 7 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

Actions

Also available in: Atom PDF