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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC