Edit report at https://bugs.php.net/bug.php?id=63486&edit=1

 ID:                 63486
 Patch added by:     der...@php.net
 Reported by:        der...@php.net
 Summary:            mysqli_free_result leave the resource variable in a
                     messy state
 Status:             Open
 Type:               Bug
 Package:            MySQLi related
 PHP Version:        5.4.8
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: mysqli-clear-result-cleanup
Revision:   1352638381
URL:        
https://bugs.php.net/patch-display.php?bug=63486&patch=mysqli-clear-result-cleanup&revision=1352638381


Previous Comments:
------------------------------------------------------------------------
[2012-11-11 12:52:02] der...@php.net

Description:
------------
An Xdebug user filed the following report: 
http://bugs.xdebug.org/view.php?id=900

I've just investigated this, and found out that this is something I can't fix 
in Xdebug. mysqli_free_result() destroys the internal object, but leaves the 
resource (in your case, $rs) in a silly state. All Xdebug does internally is 
basically a var_dump( $rs ), and after it is freed with mysqli_free_result(), 
that throws exactly the same error (without Xdebug). This can however, easily 
be fixed in the MySQLi extension with the attached patch. The patch applies to 
PHP 5.4, but this also a problem in master and PHP 5.3. It is also possible, 
that other mysqli_free_* functions can benefit from a similar construct.

Test script:
---------------
<?php

$con = mysqli_init();
mysqli_real_connect($con, '127.0.0.1', 'root', 'xxxxx');
$rs = mysqli_query($con, 'show schemas');
$row = mysqli_fetch_object($rs);
mysqli_free_result($rs);

echo "hi mom";
var_dump( $rs );
?>


Expected result:
----------------
The expected result is perhaps something like "NULL" (which my patch makes it 
do).

Actual result:
--------------
hi mom
Warning: var_dump(): Couldn't fetch mysqli_result in 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php on line 10

Call Stack:
    0.0002     662616   1. {main}() 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:0
    0.0032     672792   2. var_dump(class mysqli_result { public $current_field 
= NULL; public $field_count = NULL; public $lengths = NULL; public $num_rows = 
NULL; public $type = NULL }) 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:10


Warning: var_dump(): Couldn't fetch mysqli_result in 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php on line 10

Call Stack:
    0.0002     662616   1. {main}() 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:0
    0.0032     672792   2. var_dump(class mysqli_result { public $current_field 
= NULL; public $field_count = NULL; public $lengths = NULL; public $num_rows = 
NULL; public $type = NULL }) 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:10


Warning: var_dump(): Property access is not allowed yet in 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php on line 10

Call Stack:
    0.0002     662616   1. {main}() 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:0
    0.0032     672792   2. var_dump(class mysqli_result { public $current_field 
= NULL; public $field_count = NULL; public $lengths = NULL; public $num_rows = 
NULL; public $type = NULL }) 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:10


Warning: var_dump(): Couldn't fetch mysqli_result in 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php on line 10

Call Stack:
    0.0002     662616   1. {main}() 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:0
    0.0032     672792   2. var_dump(class mysqli_result { public $current_field 
= NULL; public $field_count = NULL; public $lengths = NULL; public $num_rows = 
NULL; public $type = NULL }) 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:10


Warning: var_dump(): Property access is not allowed yet in 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php on line 10

Call Stack:
    0.0002     662616   1. {main}() 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:0
    0.0032     672792   2. var_dump(class mysqli_result { public $current_field 
= NULL; public $field_count = NULL; public $lengths = NULL; public $num_rows = 
NULL; public $type = NULL }) 
/home/derick/dev/php/derickr-xdebug/tests/bug00900.php:10

class mysqli_result#2 (5) {
  public $current_field =>
  NULL
  public $field_count =>
  NULL
  public $lengths =>
  NULL
  public $num_rows =>
  NULL
  public $type =>
  NULL
}



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63486&edit=1

Reply via email to