Bug #67348 [NEW]: Reading $dbc->stat modifies $dbc->affected_rows
From: derick
Operating system: Linux
PHP version: 5.6Git-2014-05-27 (Git)
Package: MySQLi related
Bug Type: Bug
Bug description:Reading $dbc->stat modifies $dbc->affected_rows
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)
--
Edit bug report at https://bugs.php.net/bug.php?id=67348&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67348&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67348&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67348&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67348&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67348&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67348&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67348&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67348&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67348&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67348&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67348&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67348&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67348&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67348&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67348&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67348&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67348&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67348&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67348&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67348&r=mysqlcfg
Thread (17 messages)
- derick@php.net
- stephan dot eicher at check24 dot deBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- chealer at gmail dot comBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- chealer at gmail dot comBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- myk at illinois dot eduBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- aik dot bold at gmail dot comBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- johnnyecon at gmail dot comBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- fjanisze@php.netBug #67348 [Opn->Ana]: Reading $dbc->stat modifies $dbc->affected_rows
- steffenbalje at gmail dot comBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- gcognault at free dot frBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- konrad dot br at brynda dot orgBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- kamilcodes at gmail dot comBug #67348 [Com]: Reading $dbc->stat modifies $dbc->affected_rows
- derick@php.netBug #67348 [Ana->Csd]: Reading $dbc->stat modifies $dbc->affected_rows
- derick@php.netBug #67348 [Csd]: Reading $dbc->stat modifies $dbc->affected_rows
- andrey@php.netBug #67348 [Csd]: Reading $dbc->stat modifies $dbc->affected_rows
- derick@php.netBug #67348 [Csd]: Reading $dbc->stat modifies $dbc->affected_rows
- nikic@php.netBug #67348 [Csd]: Reading $dbc->stat modifies $dbc->affected_rows