Bug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows

From: Date: Wed, 04 Jan 2017 20:29:29 +0000
Subject: Bug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206306@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67348&edit=1 ID: 67348 Comment by: johnnyecon at gmail dot com Reported by: derick@php.net Summary: Reading $dbc->stat modifies $dbc->affected_rows Status: Open Type: Bug Package: MySQLi related Operating System: Linux PHP Version: 5.6Git-2014-05-27 (Git) Block user comment: N Private report: N New Comment: Same here. In my phpunit tests I connect to mysql using mysqli_connect on setUp(). All is ok when the first test runs mysqli_real_escape_string. But when it is not the first test running then I get the below: mysqli_real_escape_string(): Couldn't fetch mysqli I am running PHP7.0 on PHPUnit 5.6.1 Previous Comments: ------------------------------------------------------------------------ [2016-11-21 12:11:28] aik dot bold at gmail dot com Happens for me as well on PHP 5.4, PHP 5.5, PHP 5.6. Maybe even on PHP 7.0. ------------------------------------------------------------------------ [2015-08-25 19:40:55] myk at illinois dot edu 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(); ------------------------------------------------------------------------ [2015-06-30 17:20:56] chealer at gmail dot com I should have specified this affected me while using XDebug on Windows (8.1). This happened when I migrated an application from mysql to mysqli, which is its closest equivalent. And the reason why I migrated from mysql is that I upgraded to 5.5... which deprecates the mysql extension! Unfortunately, there will probably many others affected. And unfortunately, the procedural style mysqli_affected_rows() is also affected, so the best workarounds I see is to go back to mysql, go to PDO instead, or wrap the critical part of our high-level query() function in big "DO NOT STEP THROUGH THIS CODE" comments. We wouldn't have the last choice if we didn't use such a wrapper, so we're in fact among the luckiest... ------------------------------------------------------------------------ [2015-06-30 16:17:41] chealer at gmail dot com This is a recipe to make a developer crazy. You hit a bug in your code, add breakpoints to try debugging it, and get crazy results. I can't believe this persists. I am experiencing this under PHP 5.5.12. This was reported by figiemmi to NetBeans Forums on 2012-11-24, but he did not specify which PHP version he was using. This is visibly an old bug, but it's hard to believe it's always been that way. This was also reported against NetBeans: https://netbeans.org/bugzilla/show_bug.cgi?id=244714 Thank you very much for reporting, your test case and your analysis, Derick. ------------------------------------------------------------------------ [2015-06-21 21:31:29] stephan dot eicher at check24 dot de We are affected by this bug and it's very important for us because our framework relies on valid return values for "affected_rows". We can reproduce this issue on Debian Jessie with package php5 (5.6.x) and xdebug installed. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=67348 -- Edit this bug report at https://bugs.php.net/bug.php?id=67348&edit=1

« previous php.bugs (#206306) next »