|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-05-27 22:31 UTC] derick@php.net
Description: ------------ When a script reads $dbc->stat, subsequent reads of $dbc->affected_rows return a different result. This was first reported to me as Xdebug bug #1053: http://bugs.xdebug.org/view.php?id=1053. I traced this back to the reading of ->stat as follows: - Xdebug's debugging command "context_get" reads all the variables in the local scope - For each object variable, the debug handlers are called (through Z_OBJDEBUG_PP): https://github.com/derickr/xdebug/blob/master/xdebug_var.c#L1725 - MySQLi debug handler loops over a list of properties: https://github.com/php/php-src/blob/master/ext/mysqli/mysqli_prop.c#L449 - The debug handler for affected_rows is at https://github.com/php/php-src/blob/master/ext/mysqli/mysqli_prop.c#L158 - The debug handler for stat is at https://github.com/php/php-src/blob/master/ext/mysqli/mysqli_prop.c#L256 - The debug handler for stat is defined at https://github.com/php/php-src/blob/master/ext/mysqlnd/mysqlnd.h#L212 - When I do *not* call "$foo = $dbc->stat", everything works. - I can not created a work around, because the debug handler loops over all properties, and I have no chance to prevent ->stat from being read from the Xdebug side. Test script: --------------- <?php $dbc = mysqli_connect('localhost', 'root', 'passwd', 'test'); $q = "INSERT INTO test1053 VALUES(7)"; $r = mysqli_query($dbc, $q); var_dump($dbc->affected_rows); $foo = $dbc->stat; var_dump($dbc->affected_rows); ?> Expected result: ---------------- int(1) int(1) Actual result: -------------- int(1) int(-1) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
I have this problem regardless of whether I step through the code in my Eclipse/Xdebug/MAMP environment. It seems if I try to open/close mysqli connections when used, the problem occurs. If I don't close the connections, I get no errors about accessing properties, but I do then get the expected "too many connections." Any chance this will get fixed soon? It's really hard to debug when your error logs fill with hundreds of lines of useless info. if(!$this->db->isConnected()){ $this->db->selectDB(); $this->dbc = $this->db->dbc; } $this->resource = $this->dbc->query($this->text); if($this->resource===false){ $this->error=$this->dbc->connect_error; if(isset($this->log)){ $err=$this->log->writeLog($this->text."\n".$this->error."\n".$this->implode_r("\n",debug_backtrace()),'log',$tag); }else{ echo $this->text."\n".$this->error."\n".$this->implode_r("\n",debug_backtrace()),'log -- '.$tag; die; } }elseif(strpos($this->text,'insert into')!==false){ $this->result=$this->dbc->insert_id; }elseif(strpos($this->text,'delete')!==false or strpos($this->text,'update')!==false){ $this->result=$this->resource; }else{ $this->fetch_all(); } $this->dbc->close();