Feature #53059

Throw exception for unresolved namespaces

Added by Bastian Waidelich over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Category:
Core
Target version:
-
Start date:
2013-10-23
Due date:
% Done:

0%

Estimated time:
Has patch:
No

Description

One major source of errors when working with Fluid is the missing error handling when referring to a ViewHelper namespace that hasn't been declared.
Especially when one extracts parts of the template to a partial the namespace declaration is easily forgotten.

The issue with this is that namespace prefixes are allowed in xml so Fluid can't determine whether <unknown-namespace:foo /> is a mistyped ViewHelper or a (possibly valid) XML/XHTML tag that has been registered otherwise.
Given the importance of this we should solve this even though it would be a breaking change. We came up with following solution:

{namespace x=Some\Package\ViewHelpers}
{namespace xs}

<f:foo />  <!-- as before: this would be a valid fluid tag as "f" is always registered (even though it would throw an exception because there is no VH "FooViewHelper" in the Fluid package -->

<x:some.viewHelper />    <!-- as before: would resolve to \Some\Package\ViewHelpers\Some\ViewHelperViewHelper -->

<xs:element />     <!-- as before but explicit: would be ignored, because the namespace is registered but does not point to a PHP namespace -->

<unknown:foo />     <!-- new: would throw an exception in Dev context, ignore the tag in Production context because the namespace "unknown" is not defined -->


When working with complex XML based files with a lot of namespaces (like XML Schema or LaTeX) it would be tedious to register all the namespaces so we should also support some kind of placeholder syntax like:

{namespace *} <!-- ignores all unknown namespaces (old behavior) -->
{namespace xs*} <!-- ignores all unknown namespaces that start with "xs" -->

Note: a different approach to this would be to configure namespaces not in the Fluid template but in the configuration. See #35766 and the related issues for reasons why we shouldn't do this


Related issues

Related to TYPO3.Fluid - Bug #30138: Bad error message "TYPO3\FLOW3\Persistence\Doctrine\QueryResult could not be converted to string" if necessary namespace hasn't been loaded ClosedBastian Waidelich2011-09-20

Actions
Related to TYPO3.Fluid - Feature #58557: Define Namespaces in Configuration FileRejectedBastian Waidelich2014-05-06

Actions
Related to TYPO3.Fluid - Feature #58829: Register package namespaces automaticallyClosedMarc Neuhaus2014-05-15

Actions
#1

Updated by Gerrit Code Review over 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/24971

#2

Updated by Bastian Waidelich over 7 years ago

  • Assignee set to Bastian Waidelich
#3

Updated by Gerrit Code Review almost 7 years ago

Patch set 1 for branch master of project Packages/TYPO3.Fluid has been pushed to the review server.
It is available at https://review.typo3.org/30673

#4

Updated by Gerrit Code Review almost 7 years ago

Patch set 4 for branch master of project Packages/TYPO3.Fluid has been pushed to the review server.
It is available at https://review.typo3.org/30673

#5

Updated by Gerrit Code Review almost 7 years ago

Patch set 9 for branch master of project Packages/TYPO3.Fluid has been pushed to the review server.
It is available at https://review.typo3.org/30673

#6

Updated by Bastian Waidelich over 6 years ago

  • Status changed from Under Review to Closed

This ticket has been moved to https://jira.typo3.org/browse/FLOW-150

Also available in: Atom PDF