|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46614 Extended MySQLi class gives incorrect empty() result (works in PHP_5_2 !)
Submitted: 2008-11-19 13:25 UTC Modified: 2009-08-27 12:42 UTC
Avg. Score:4.0 ± 1.0
Reproduced:0 of 0 (0.0%)
From: sander dot vink at procurios dot nl Assigned: mysql (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.3CVS-2008-11-19 (snap) OS: *
Private report: No CVE-ID: None
 [2008-11-19 13:25 UTC] sander dot vink at procurios dot nl
When an empty() call is done within a class that extends the MySQLi class, an incorrect result is provided.

Reproduce code:
class Foo extends MySQLi
	protected $fooData = array();
	public function isEmpty()
		$this->fooData[] = 'Bar';
		return empty($this->fooData);

$Foo = new Foo('localhost', 'root', '', 'test');
$isEmpty = $Foo->isEmpty();


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-19 23:12 UTC]
You set $this->fooData[]to contain 'Bar' -> it's not empty -> returns 
true..what's the bug..?
 [2008-11-20 08:14 UTC] sander dot vink at procurios dot nl
Yes, exactly, it is not empty. However, I return the result of empty() ( not !empty() ) which should be false, since the array actually contains data.
 [2008-11-21 13:05 UTC]
Ah, I tested with PHP 5.2CVS and it works as expected. So this is PHP_5_3 (and propably HEAD) issue only.
 [2009-08-27 12:41 UTC]
Automatic comment from SVN on behalf of andrey
Log: Fix for bug#46614 Extended MySQLi class gives incorrect empty() result
 [2009-08-27 12:42 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

The fix will be in 5.3.1
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jun 01 02:01:30 2020 UTC