#45788 [Opn->Bgs]: fgetcsv retuns NULL on warning instead of false

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               45788
 Updated by:       [email protected]
 Reported By:      steven at realestatewebmasters dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Filesystem function related
 Operating System: Linux
 PHP Version:      5.2.6
 New Comment:

Invalid parameter does not cause fatal error in any PHP function. And
when an invalid parameter is passed, all functions using the new (more
consistent) parameter parsing also return NULL. No bug here.


Previous Comments:
------------------------------------------------------------------------

[2008-08-11 18:36:49] steven at realestatewebmasters dot com

Description:
------------
fgetcsv returns null if passed false as the handle. This should cause
and error instead of a warning and cause the function to return false.

Reproduce code:
---------------
<?php

$handle = fopen("foo","r");

var_dump($data = fgetcsv($handle,0,",",'"'));

while (($data = fgetcsv($handle,0,",",'"')) !== false) {
	echo 'test';
}

?>

Expected result:
----------------
Warning: fopen(foo): failed to open stream: No such file or directory
in /home/sbarre85/test.php on line 3

Warning: fgetcsv() expects parameter 1 to be resource, boolean given in
/home/sbarre85/test.php on line 5
bool(false)

Error: fgetcsv() expects parameter 1 to be resource, boolean given in
/home/sbarre85/test.php on line 7

Actual result:
--------------
Warning: fopen(foo): failed to open stream: No such file or directory
in /home/sbarre85/test.php on line 3

Warning: fgetcsv() expects parameter 1 to be resource, boolean given in
/home/sbarre85/test.php on line 5
NULL

Warning: fgetcsv() expects parameter 1 to be resource, boolean given in
/home/sbarre85/test.php on line 7
test

.. looping infinitly


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45788&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.