#49708 [NEW]: fgetcsv returns NULL instead of FALSE
| From: | orel at melix dot net | Date: | Tue, 29 Sep 2009 11:59:53 +0000 |
| Subject: | #49708 [NEW]: fgetcsv returns NULL instead of FALSE | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-143032@lists.php.net to get a copy of this message | ||
From: orel at melix dot net
Operating system: All
PHP version: 5.3SVN-2009-09-29 (SVN)
PHP Bug Type: Filesystem function related
Bug description: fgetcsv returns NULL instead of FALSE
Description:
------------
See example of documentation http://www.php.net/fgetcsv
If file doesn't exist there is an endless loop.
fgetcsv returns NULL if handler is invalid.
Reproduce code:
---------------
<?php
$row = 1;
$handle = fopen("test.csv", "r"); /* test.csv should not exist */
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
?>
Expected result:
----------------
fgetcsv should returns FALSE
Actual result:
--------------
Endless loop, fgetcsv returns NULL
--
Edit bug report at http://bugs.php.net/?id=49708&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49708&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49708&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49708&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49708&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49708&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49708&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49708&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49708&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49708&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49708&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49708&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49708&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49708&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49708&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49708&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49708&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49708&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49708&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49708&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49708&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49708&r=mysqlcfg