php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62492 dba_firstkey & dba_nextkey retuns NULL (instead false) on invalid dba resource
Submitted: 2012-07-06 09:08 UTC Modified: 2013-12-03 14:44 UTC
From: marc-bennewitz at arcor dot de Assigned:
Status: Not a bug Package: DBM/DBA related
PHP Version: 5.4.4 OS: openSUSE 11.3 (x86_64)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marc-bennewitz at arcor dot de
New email:
PHP Version: OS:

 

 [2012-07-06 09:08 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-03 14:44 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-12-03 14:44 UTC] mike@php.net
It's convention that functions return NULL on invalid arguments.

See the note here: http://php.net/manual/en/functions.internal.php
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Aug 15 05:01:25 2020 UTC