php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36949 invalid internal mysqli objects dtor
Submitted: 2006-04-02 15:14 UTC Modified: 2006-05-29 16:57 UTC
Votes:3
Avg. Score:3.7 ± 1.9
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: jax at student dot unibe dot ch Assigned: georg (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.1.3RC3 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2006-04-02 15:14 UTC] jax at student dot unibe dot ch
Description:
------------
Test Case for mysqli->fetch_object bug 
class A and class B contain the exact same code
Using mysqli->fetch_object causes warning when the destructor of B is called (mysqli->close()):
  Warning: mysqli::close() [function.close]: Couldn't fetch mysqli in /home/path/to/php/test.php on line 56 (destructor of B)

If mysqli->fetch_assoc is used instead of fetch_object, it works fine.

Replace
  $row = $result->fetch_object();
  echo $row->my_time;

With
  $row = $result->fetch_assoc();
  echo $row['my_time'];

to test

something must be wrong with fetch_object

Reproduce code:
---------------
class A {

	private $mysqli;

	public function __construct() {
		$this->mysqli = new mysqli("localhost", "u", "p", "test");
		$result = $this->mysqli->query("SELECT NOW() AS my_time");
		// -------- Line Causing Problem ------
		$row = $result->fetch_object();
		echo $row->my_time."<br>";
		$result->close();
	}

	public function __destruct() {
		$this->mysqli->close();
	}
}

class B {

	private $mysqli;

	public function __construct() {
		$this->mysqli = new mysqli("localhost", "u", "p", "test");
		$result = $this->mysqli->query("SELECT NOW() AS my_time");
		// -------- Line Causing Problem --------
		$row = $result->fetch_object();
		echo $row->my_time."<br>";
		$result->close();
	}

	public function __destruct() {
		$this->mysqli->close();
	}
}

$A = new A();
$B = new B();

Expected result:
----------------
$this->mysqli->close() should work without throwing an error

Actual result:
--------------
2006-04-02 15:01:36
2006-04-02 15:01:36

Warning: mysqli::close() [function.close]: Couldn't fetch mysqli in /home/path/to/test.php on line 56

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-10 22:40 UTC] jax at student dot unibe dot ch
Ok i installed PHP 5.1.3 RC3 from CVS and problem persists:

root@dosim: cli # ./php --version
PHP 5.1.3RC3 (cli) (built: Apr 11 2006 00:27:07)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
root@dosim: cli # ./php test.php
2006-04-11 00:38:02<br>2006-04-11 00:38:02<br>
Warning: mysqli::close(): Couldn't fetch mysqli in /root/php5.1-200604102030/sapi/cli/test.php on line 35

test.php contained exact code mentioned in first post.
 [2006-04-12 14:58 UTC] sniper@php.net
Georg, this sounds very bad. Can you take a look?
 [2006-05-10 13:46 UTC] georg@php.net
Assigned to Helly (as discussed with him)
 [2006-05-27 01:13 UTC] helly@php.net
Georg, maybe you need Dmitry or Tony having a look into it. From our debug/discuss session i only rememebr that i cannot do anything about it - sorry.
 [2006-05-29 16:57 UTC] mike@php.net
This bug has been fixed in CVS.

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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC