From: tero dot tasanen at gmail dot com Operating system: Linux 64bit PHP version: 5.3.14 Package: Output Control Bug Type: Bug Bug description:Strange behavior with global variables (objects) in ob_start() output callback
Description: ------------ Global variables in output buffering seem to work in very strange way. don't know actually if this has anything to do with output buffering callback but see the test case attached to reproduce this. And the strangest thing is that if you uncomment the last line the script works as expected! After some searching I found two similar bug reports (#40604, #44840) and the comments indicate that this is expected behavior?! Not just that it seem really strange that all objects get destroyed before the output callback is called, but why does the use of the $test variable in the end of the script change this behavior? This really does not make any sense! Test script: --------------- <? function output($buffer) { global $object; return $buffer . $object->bar; } ob_start('output'); $object = new stdClass(); $object->bar = "bar"; echo "foo "; // $test = $object; Expected result: ---------------- foo bar Actual result: -------------- PHP Notice: Trying to get property of non-object in /home/ttasanen/test.php on line 5 PHP Stack trace: PHP 1. output() /home/ttasanen/test.php:0 foo -- Edit bug report at https://bugs.php.net/bug.php?id=62437&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62437&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62437&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62437&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62437&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62437&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62437&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62437&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62437&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62437&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62437&r=support Expected behavior: https://bugs.php.net/fix.php?id=62437&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62437&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62437&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62437&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62437&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62437&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62437&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62437&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62437&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62437&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62437&r=mysqlcfg