Bug #38459

Accessing a not present property/method should error verbosely

Added by Adrian Föder about 3 years ago. Updated almost 3 years ago.

Status:New Start date:2012-06-28
Priority:Must have Due date:
Assigned To:Sebastian Kurfuerst % Done:

0%

Category:-
Target version:-

Description

in my case, I erroneously wrote

page.body.title = ${context.attr('title')}

which resulted in

1<!-- Exception while rendering page&lt;TYPO3.TYPO3:Page&gt;/body :
2Catchable Fatal Error: Object of class TYPO3\Eel\FlowQuery\FlowQuery
3could not be converted to string in /var/www/Data/Temporary/Development⸗
4/Cache/Code/Fluid_TemplateCache/Standalone_template_file_Site_5d5f8dc75⸗
5b9c07fb770fba32529975b68fe55c41.php line 1193 -->

Christian perfectly summarized it to

yep, so the parser correctly detects the FlowQuery and creates the FlowQuery object but it seems it isn't evaluated

He also provided the reason: there is no `attr`, it must be `property`.
So please provide a better exception catch for such cases. I filed this as Bug because I think it's pretty important for users.

Associated revisions

Revision a12eb1b0
Added by Christopher Hlubek almost 3 years ago

[BUGFIX] Throw an exception when calling undefined method on object

Add tests to the evaluator test case for undefined methods and
function calls on NULL values. Introduce an EvaluationException for
better exception handling (needs further work).

Change-Id: Ie0579ae84b32a64c7103ed458cc0349fac8e94a3
Related: #38459

History

#1 Updated by Christopher Hlubek almost 3 years ago

  • Assigned To set to Sebastian Kurfuerst

I think this is due to the behaviour in FLowQuery::__call where a unknown operation should rather throw an exception instead of returning the FlowQuery object itself.

#2 Updated by Christopher Hlubek almost 3 years ago

But when adding some more Unit Tests to Context I found some cases where also Eel itself did not throw an exception but returned NULL. Nesting expressions like foo.bar.baz should be safe in Eel by design, even if NULL values are in the path. But I think if the callee is a method or array there should be an exception. If the callee is NULL I would return NULL to make chaining safer.

Also available in: Atom PDF