#50221 [NEW]: fgetcsv error handling

From: Date: Wed, 18 Nov 2009 21:16:34 +0000
Subject: #50221 [NEW]: fgetcsv error handling
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3218@lists.php.net to get a copy of this message
From: none at example dot com Operating system: linux PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: fgetcsv error handling Description: ------------ Concerns official Example on: http://de.php.net/manual/en/function.fgetcsv.php and all other examples in the user feedback. fgetcsv error handling shouldn't check ===FALSE, since reading from an unopened file will return NULL and cause a tight loop. So don't do: while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { but just: while ($data = fgetcsv($handle, 1000, ",")) { This will properly read in empty lines, and not stay looping forever when $handle is undefined (possibly because of fopen() failing, since that error isn't handled.......) Thanks! Reproduce code: --------------- --- From manual page: function.fgetcsv#Examples --- -- Edit bug report at http://bugs.php.net/?id=50221&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50221&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50221&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50221&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50221&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50221&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50221&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50221&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50221&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50221&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50221&r=support Expected behavior: http://bugs.php.net/fix.php?id=50221&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50221&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50221&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50221&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50221&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50221&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50221&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50221&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50221&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50221&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50221&r=mysqlcfg

« previous php.doc.bugs (#3218) next »