Issue Details (XML | Word | Printable)

Key: ZF-3249
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Major Major
Assignee: Satoru Yoshida
Reporter: wego
Votes: 0
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Use of fopen with '@' triggers error-handler

Created: 13/May/08 03:40 AM   Updated: 17/Dec/08 12:38 PM   Resolved: 14/May/08 04:43 AM
Component/s: Zend_Loader
Affects Version/s: 1.5.0
Fix Version/s: 1.5.2

Time Tracking:
Not Specified

Issue Links:
Dependency
 


 Description  « Hide

The method Zend_Loader::isReadable() uses fopen to check if a file exists and the @-operator to abort its error-messages:

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

return true;
}

This only aborts the messages from beeing displayed, the error-handler will be triggert anyway. So if you use your own error-handler, everytime a file is beeing checked with this function and not found (and this may happen very often) a php-notice is thrown and beeing logged into your logfile for example or your database.

Why not use the 'file_exists()' function of php?

// example with include path:

static $paths = null;
if ($paths == null) {
$paths = explode(PATH_SEPARATOR, get_include_path());
}

foreach ($paths as $path) {
$fullpath = $path.DIRECTORY_SEPARATOR.$filename;
if (file_exists($fullpath)) { return true; }
}

return file_exists($filename);



James Dempster added a comment - 13/May/08 05:34 AM

I think it's cause file_exits() doesn't follow the include path where as the third parameter of fopen() is weather is should use the include path or not.


julien PAULI added a comment - 13/May/08 08:20 AM

Hum, just use in you error handler function :

if(error_reporting() == 0) { return; }

When the error handler catches the error, the @ puts silently error_reporting level to 0, so you can detect errors comming from 'arobased' instructions.


Satoru Yoshida added a comment - 14/May/08 04:43 AM

I think it duplicates with ZF-2985


Wil Sinclair added a comment - 17/Dec/08 12:38 PM

Bookkeeping. We're trying to assign all resolved issues to the people who resolved them.