From:             der...@php.net
Operating system: 
PHP version:      5.4.8
Package:          MySQLi related
Bug Type:         Bug
Bug description:mysqli_free_result leave the resource variable in a messy state

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 bug report at https://bugs.php.net/bug.php?id=63486&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63486&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63486&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63486&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63486&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63486&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63486&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63486&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63486&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63486&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63486&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63486&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63486&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63486&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63486&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63486&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63486&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63486&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63486&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63486&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63486&r=mysqlcfg

Reply via email to