Feature #53059

Throw exception for unresolved namespaces

Added by Bastian Waidelich almost 2 years ago. Updated 8 months ago.

Status:Closed Start date:2013-10-23
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:Core
Target version:-
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:

 1{namespace x=Some\Package\ViewHelpers}
 2{namespace xs}
 3
 4<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 -->
 5
 6<x:some.viewHelper />    <!-- as before: would resolve to \Some\Package\ViewHelpers\Some\ViewHelperViewHelper -->
 7
 8<xs:element />     <!-- as before but explicit: would be ignored, because the namespace is registered but does not point to a PHP namespace -->
 9
10<unknown:foo />     <!-- new: would throw an exception in Dev context, ignore the tag in Production context because the namespace "unknown" is not defined -->
11

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:

1{namespace *} <!-- ignores all unknown namespaces (old behavior) -->
2{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\Query... Closed 2011-09-20
related to TYPO3.Fluid - Feature #58557: Define Namespaces in Configuration File Rejected 2014-05-06
related to TYPO3.Fluid - Feature #58829: Register package namespaces automatically Closed 2014-05-15

History

#1 Updated by Gerrit Code Review almost 2 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 1 year ago

  • Assigned To set to Bastian Waidelich

#3 Updated by Gerrit Code Review about 1 year 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 about 1 year 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 about 1 year 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 8 months 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