Bug #62492 [Opn->Nab]: dba_firstkey & dba_nextkey retuns NULL (instead false) on invalid dba resource
| From: | mike@php.net | Date: | Tue, 03 Dec 2013 14:44:20 +0000 |
| Subject: | Bug #62492 [Opn->Nab]: dba_firstkey & dba_nextkey retuns NULL (instead false) on invalid dba resource | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183106@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62492&edit=1
ID: 62492
Updated by: mike@php.net
Reported by: marc-bennewitz at arcor dot de
Summary: dba_firstkey & dba_nextkey retuns NULL (instead
false) on invalid dba resource
-Status: Open
+Status: Not a bug
Type: Bug
Package: DBM/DBA related
Operating System: openSUSE 11.3 (x86_64)
PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
It's convention that functions return NULL on invalid arguments.
See the note here: http://php.net/manual/en/functions.internal.php
Previous Comments:
------------------------------------------------------------------------
[2012-07-06 09:08:16] marc-bennewitz at arcor dot de
Description:
------------
The functions "dba_firstkey" & "dba_nextkey" retuns NULL (instead of false)
on invalid dba resource.
It's documented as "Returns the key on success or FALSE on failure."
That can result in an infinite loop on iterate over items.
Test script:
---------------
$dba = false;
var_dump(dba_firstkey($dba));
var_dump(dba_nextkey($dba));
Expected result:
----------------
PHP Warning: dba_firstkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 5
Warning: dba_firstkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 5
boolean(false)
PHP Warning: dba_nextkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 6
Warning: dba_nextkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 6
boolean(false)
Actual result:
--------------
PHP Warning: dba_firstkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 5
Warning: dba_firstkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 5
NULL
PHP Warning: dba_nextkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 6
Warning: dba_nextkey() expects parameter 1 to be resource, boolean given in
/tmp/dba_firstkey_nextkey.php on line 6
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62492&edit=1