From: skrol29 at freesurf dot fr Operating system: any PHP version: 5.2.5 PHP Bug Type: Output Control Bug description: ob_start() changes variables and makes inconsistent serialize
Description: ------------ I call two functions, the one after the other. The first one is doing an output redirection using ob_start(). The second one is just modifying a variable. It is like the second function is executed just after the ob_start() without waiting for the end of the first function. The second function is called on an arbitrary local variable, for which the serialization becomes inconsistent. This bug has been found on PHP 5.2.5, but also 5.2.4, on Linux, Windows XP and Vista. Reproduce code: --------------- $Txt = ''; f_Action1($Txt); f_Action2($Txt); echo $Txt; function f_Action1(&$Txt) { $z = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; echo "value before={".$z."} <br>\r\n"; ob_start(); echo "value after={".$z."} <br>\r\n"; // Bug here : it is like Action2() has been applied to $z echo "serialize={".serialize($z)."} <br>\r\n"; // Bug here : the serialization is inconsistent between size and value. $Txt = ob_get_contents(); ob_end_clean(); } function f_Action2(&$Txt) { $Txt = str_replace('ABCDEFGHIJKLMNOPQRSTUVWXYZ','abc',$Txt); } Expected result: ---------------- value before={ABCDEFGHIJKLMNOPQRSTUVWXYZ} value after={ABCDEFGHIJKLMNOPQRSTUVWXYZ} serialize={s:26:"ABCDEFGHIJKLMNOPQRSTUVWXYZ";} Actual result: -------------- value before={ABCDEFGHIJKLMNOPQRSTUVWXYZ} value after={abc} serialize={s:26:"abc";} -- Edit bug report at http://bugs.php.net/?id=43700&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43700&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43700&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43700&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43700&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43700&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43700&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43700&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43700&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43700&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43700&r=support Expected behavior: http://bugs.php.net/fix.php?id=43700&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43700&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43700&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43700&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43700&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43700&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43700&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43700&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43700&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43700&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43700&r=mysqlcfg