fgetcsv returns null on invalid resource

From: Date: Tue, 28 Jul 2009 19:59:02 +0000
Subject: fgetcsv returns null on invalid resource
Groups: php.internals 
Request: Send a blank email to internals+get-45127@lists.php.net to get a copy of this message
Hello, I came across a condition in some legacy code that did not properly check if a file was a valid resource (Causes while(FALSE !== ($data = fgetcsv($fp))) { to be a infinite loop). I made a small change to standard/file.c to return false instead of null as the documentation seems to state as well as make it more consistent with the file reading family. My question is, does it return null for a specific reason? If not I assume filing a bug is the route to take. The simple change I am speaking of is listed below. -Chris -- Index: ext/standard/file.c =================================================================== --- ext/standard/file.c (revision 286463) +++ ext/standard/file.c (working copy) @@ -2032,7 +2032,7 @@                        &enclosure_str, &enclosure_str_len,                        &escape_str, &escape_str_len) == FAILURE                ) { -                       return; +                       RETURN_FALSE;                }                if (delimiter_str != NULL) {

« previous php.internals (#45127) next »