Issues

ZF-101: Zend_View_Abstract::_loadClass() doesn't work with classes on the include path (TRAC#99)

Issue Type: Bug Created: 2006-06-21T21:47:01.000+0000 Last Updated: 2007-07-05T14:44:28.000+0000 Status: Closed Fix version(s): - 0.6.0 (16/Dec/06)

Reporter: Zend Framework (zend_framework) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_View

Related issues: Attachments: - Zend_View_Abstract.patch

Description

http://framework.zend.com/developer/ticket/99

Zend_View_Abstract::_loadClass() calls is_readable() to find out if the particular file exists on the path.

This causes problems when you want to have a set of common view helpers for multiple projects. In my case, I use a directory called Akrabat/View/Helper as part of a tree that mirrors the ZF tree for consistency.)

My preference would be to change

<pre class="highlight">
    if (is_readable($dir . $file)) {

to

<pre class="highlight">
    if (Zend::isReadable($dir . $file)) {

to solve this problem.

Suggested patch attached.

Comments

Posted by Zend Framework (zend_framework) on 2006-06-21T21:47:17.000+0000

05/28/06 16:18:19: Modified by rob.nospam@akrabat.com

* attachment Zend_View_Abstract.patch added.

Suggested patch v1

Posted by Nick Lo (nicklo) on 2006-06-26T00:55:09.000+0000

Rather than make the class dependant on Zend.php how about changing...

<pre class="literal"> 
if (is_readable($dir . $file)) {
    include $dir . $file;

...to...

<pre class="literal"> 
if (include $dir . $file) {

...which would achieve much the same result

Posted by Nick Lo (nicklo) on 2006-06-26T23:19:43.000+0000

Forget my suggestion...

<pre class="literal"> 
if (include $dir . $file) {

...as this produces warnings as each _path stack is looped over

Posted by Jayson Minard (jayson) on 2006-07-09T00:42:45.000+0000

Mind looking at this for 0.2.0?

Posted by Elisamuel Resto (user00265) on 2006-07-30T22:20:31.000+0000

One way is explode the path and then loop through it doing a Zend::isReadable() for each path with the requested file, that is somewhat slow in my eyes, but it's the only solution I see for making this work.

Posted by Matthew Weier O'Phinney (matthew) on 2006-11-02T00:11:51.000+0000

Fixed in 1428

Posted by Matthew Weier O'Phinney (matthew) on 2006-11-02T00:34:27.000+0000

Further analysis shows that the original behaviour was intentional. addScriptPath() can be used at any point to add additional view script paths to the view object. The reporter need only have done the following:

<pre class="highlight">
$view->addScriptPath('/path/to/common/view/scripts');

Posted by Matthew Weier O'Phinney (matthew) on 2006-11-02T00:35:16.000+0000

Behaviour was intentional, and a way to do as the reporter desired already existed in the code.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts