ZF-4622: Zend_View_Abstract::_addPath() strips double-slash from protocol
Description
This code is run on the path in Zend_View_Abstract::_addPath(): {{$dir = rtrim($dir, DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;}}
This should be removed/improved because it prevents you from using custom stream wrappers. For example, I have implemented a few custom wrappers to work with a different template engine. Instead of hacking everything to work from non-filesystem sources, I just created some stream wrappers to do it behind the scenes. I register the protocol 'tpl', and then set the script path to 'tpl://' (i.e., to load a 'tpl://emaple.html' template). But the code above strips off the extra slash so ZF tries to load 'tpl:/example.html' which is incorrect.
Furthermore, the _addPath method is private so I can't override it in a subclass.
For now what I've been doing to work around the problem is to set the script path to 'tpl://null/' to stop the rtrim from stripping the double slash from the protocol part.
Comments
Posted by Ralph Schindler (ralph) on 2011-02-18T14:59:25.000+0000
Is this still an issue?
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-28T23:09:36.000+0000
No. The unit test for ZF-9000 shows that this issue no longer exists:
It successfully adds a view path using the file:// scheme. This unit test should be generalized for all platforms.
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-28T23:35:23.000+0000
Added adapted unit test to trunk r24076 * Renamed test to: testAddingStreamSchemeAsScriptPathShouldNotMangleThePath * Removed Windows-only constraint
Posted by Adam Lundrigan (adamlundrigan) on 2011-06-07T23:07:07.000+0000
Merged updated unit test to release-1.11 in r24127