Problem with isReadable() in Zend_Loader

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with isReadable() in Zend_Loader

Dirk Schwarz-2
Hi list,

I have a problem with the isReadble() function in Zend_Loader class. It
creates a warning each time if using a view helper like:

fopen(S:\WebserverRoot\web_3.0\application\modules\default\views\helpers\Doctype.php)
[function.fopen]: failed to open stream: No such file or directory

Is this because I set a path wrong or because of this implementation:

     public static function isReadable($filename)
     {
         if (!$fh = @fopen($filename, 'r', true)) {
             return false;
         }

         return true;
     }

Thanks for any help!

Regards
Dirk
Reply | Threaded
Open this post in threaded view
|

Re: Problem with isReadable() in Zend_Loader

weierophinney
Administrator
-- Dirk Schwarz <[hidden email]> wrote
(on Wednesday, 02 April 2008, 12:14 PM +0200):
> I have a problem with the isReadble() function in Zend_Loader class. It  
> creates a warning each time if using a view helper like:
>
 

> fopen(S:\WebserverRoot\web_3.0\application\modules\default\views\helpers\Doctype.php)
> [function.fopen]: failed to open stream: No such file or directory
>
> Is this because I set a path wrong or because of this implementation:
>
>     public static function isReadable($filename)
>     {
>         if (!$fh = @fopen($filename, 'r', true)) {
>             return false;
>         }
>
>         return true;
>     }

the above should not raise any errors -- errors are suppressed with the
@ operator.

I have not experienced this issue with view helpers, though I know some
people have experienced it with autoloading. I'll look into it with
Darby and see if we can figure out what's going on.

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: Problem with isReadable() in Zend_Loader

Wolfgang Forstmeier
Hey List,

I have mentioned that some time ago,
does this only occure with Zend Studio in use ?
Or will that occure ever ?

An option would like to add an file_exists befor opening the file to
check if it is readable.
Should also speed up the whole thing if some files are not there ?!

--

On Wed, Apr 2, 2008 at 1:07 PM, Matthew Weier O'Phinney
<[hidden email]> wrote:

> -- Dirk Schwarz <[hidden email]> wrote
>  (on Wednesday, 02 April 2008, 12:14 PM +0200):
>
>
> > I have a problem with the isReadble() function in Zend_Loader class. It
>  > creates a warning each time if using a view helper like:
>  >
>
>  > fopen(S:\WebserverRoot\web_3.0\application\modules\default\views\helpers\Doctype.php)
>  > [function.fopen]: failed to open stream: No such file or directory
>  >
>  > Is this because I set a path wrong or because of this implementation:
>  >
>  >     public static function isReadable($filename)
>  >     {
>  >         if (!$fh = @fopen($filename, 'r', true)) {
>  >             return false;
>  >         }
>  >
>  >         return true;
>  >     }
>
>  the above should not raise any errors -- errors are suppressed with the
>  @ operator.
>
>  I have not experienced this issue with view helpers, though I know some
>  people have experienced it with autoloading. I'll look into it with
>  Darby and see if we can figure out what's going on.
>
>  --
>  Matthew Weier O'Phinney
>  PHP Developer            | [hidden email]
>  Zend - The PHP Company   | http://www.zend.com/
>



--
Mit freundlichen Grüßen
With best regards

Wolfgang Forstmeier
-------------------------------------------
+49° 34' 26.76", +11° 0' 48.60"
-------------------------------------------
mailto:[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Problem with isReadable() in Zend_Loader

Dirk Schwarz-2
In reply to this post by weierophinney
Hi Matthew,

Matthew Weier O'Phinney wrote:
 > the above should not raise any errors -- errors are suppressed with the
 > @ operator.

Yes, that's true, but an error handler by using set_error_handler
catches also such kind of errors. I want to create an error handler,
which logs all errors (also warnings etc.) to a logfile. And this would
cause a lot of errors for each call.

 > I have not experienced this issue with view helpers, though I know some
 > people have experienced it with autoloading. I'll look into it with
 > Darby and see if we can figure out what's going on.

Tanks anyway for your answer!

Regards
Dirk


Reply | Threaded
Open this post in threaded view
|

Re: Problem with isReadable() in Zend_Loader

Dirk Schwarz-2
In reply to this post by Wolfgang Forstmeier
Hi Wolfgang,

Wolfgang Forstmeier wrote:
 > Hey List,
 >
 > I have mentioned that some time ago,
 > does this only occure with Zend Studio in use ?
 > Or will that occure ever ?

I think this has nothing to do with Zend Studio.

 >
 > An option would like to add an file_exists befor opening the file to
 > check if it is readable.
 > Should also speed up the whole thing if some files are not there ?!

The problem with file_exist() is, that it has no "use_include_path"
parameter, which Zend_Load needs.

BTW: anny suggestion or "best practice" for default error handling with
Zend Framework and the MVC?

Regards
Dirk

Reply | Threaded
Open this post in threaded view
|

Re: Problem with isReadable() in Zend_Loader

weierophinney
Administrator
In reply to this post by Wolfgang Forstmeier
-- Wolfgang Forstmeier <[hidden email]> wrote
(on Wednesday, 02 April 2008, 01:24 PM +0200):
> I have mentioned that some time ago,
> does this only occure with Zend Studio in use ?
> Or will that occure ever ?
>
> An option would like to add an file_exists befor opening the file to
> check if it is readable.
> Should also speed up the whole thing if some files are not there ?!

This is what Zend_Loader::isReadable() is doing. fopen() in PHP 5 allows
passing a flag to search along the include_path -- a flag that
file_exists does not have. So, if the fopen() fails, we know two
possible things: the file either does not exist or is not readable, both
of which mean we can't open it.


> On Wed, Apr 2, 2008 at 1:07 PM, Matthew Weier O'Phinney
> <[hidden email]> wrote:
> > -- Dirk Schwarz <[hidden email]> wrote
> >  (on Wednesday, 02 April 2008, 12:14 PM +0200):
> >
> >
> > > I have a problem with the isReadble() function in Zend_Loader class. It
> >  > creates a warning each time if using a view helper like:
> >  >
> >
> >  > fopen(S:\WebserverRoot\web_3.0\application\modules\default\views\helpers\Doctype.php)
> >  > [function.fopen]: failed to open stream: No such file or directory
> >  >
> >  > Is this because I set a path wrong or because of this implementation:
> >  >
> >  >     public static function isReadable($filename)
> >  >     {
> >  >         if (!$fh = @fopen($filename, 'r', true)) {
> >  >             return false;
> >  >         }
> >  >
> >  >         return true;
> >  >     }
> >
> >  the above should not raise any errors -- errors are suppressed with the
> >  @ operator.
> >
> >  I have not experienced this issue with view helpers, though I know some
> >  people have experienced it with autoloading. I'll look into it with
> >  Darby and see if we can figure out what's going on.
> >
> >  --
> >  Matthew Weier O'Phinney
> >  PHP Developer            | [hidden email]
> >  Zend - The PHP Company   | http://www.zend.com/
> >
>
>
>
> --
> Mit freundlichen Grüßen
> With best regards
>
> Wolfgang Forstmeier
> -------------------------------------------
> +49° 34' 26.76", +11° 0' 48.60"
> -------------------------------------------
> mailto:[hidden email]

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: Problem with isReadable() in Zend_Loader

Darby Felton
In reply to this post by Dirk Schwarz-2
Hi Dirk,

What version of Zend_Loader are you using? The information from the
@version tag at the top of the file would be sufficient.

Also, in what context are you using Zend_Loader? As an autoloader?

If possible, please provide the minimum amount of code necessary to for
us to be able to reproduce the problem.

Thanks!

Best regards,
Darby

Dirk Schwarz wrote:

> Hi list,
>
> I have a problem with the isReadble() function in Zend_Loader class. It
> creates a warning each time if using a view helper like:
>
> fopen(S:\WebserverRoot\web_3.0\application\modules\default\views\helpers\Doctype.php)
> [function.fopen]: failed to open stream: No such file or directory
>
> Is this because I set a path wrong or because of this implementation:
>
>     public static function isReadable($filename)
>     {
>         if (!$fh = @fopen($filename, 'r', true)) {
>             return false;
>         }
>
>         return true;
>     }
>
> Thanks for any help!
>
> Regards
> Dirk
>