(on Tuesday, 04 November 2008, 08:57 AM -0800):
>
> I'm getting annoyed by the errors the isReadable function gives because it's
> trying to open non-existing files (which get suppressed).
> Why not use file_exists in conjuction with file_open? It won't give (as
> many) errors with the same implementation.
>
> There was an alternative fix, but it got revert because it broke the BC
> (which is what?).
There are two things going on here.
First off, BC == Backwards Compatibility. If a new implementation does
not work the same as the original -- i.e., given the same input, does
not return the same results -- we cannot make the change while in the
same major revision.
Second, using file_exists + fopen() means multiple stat calls to the
filesystem, which degrades performance. We can't use file_exists() by
itself, as it is not include_path aware; fopen() *is*, however.
Considering the number of reports about performance, adding additional
stat calls is a no-go.
There are ways to remove the warnings from your logs. First, you can add
an error handler routine that greps for them and removes them. Second,
in 1.7.0 (and current svn trunk), you can try using the PluginLoader
include file cache. This should reduce the number of isReadable() calls
tremendously, as the PluginLoader is the biggest consumer of it.
> SO:
>
> public static function isReadable($filename)
> {
> if (!file_exists($filename) || !$fh = @fopen($filename, 'r', true))
> {
> return false;
> }
> @fclose($fh);
> return true;
> }
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论