From: fabiovh at gmail dot com
Operating system: RHEL5
PHP version: 5.2.5
PHP Bug Type: Output Control
Bug description: objects destroyed on callback functions
Description:
------------
It is already filed as Bug #39693, but I did not find a way to reopen it
or comment on it. I believe it has been marked as bogus in mistake, or at
least with not enough pondering about the problem.
I'm sure this wasn't the behavior in earlier versions of PHP 5, since my
code just broke with the upgrade, exactly because objects are now
destroyed, but it worked fine before.
At least mentioning this new behavior in the docs (on ob_start) would be
sensitive. But to me it's waaay weird that everything else works in those
callback functions, except objects.
I think it's pretty severe, since this change of behavior breaks
compatibility and makes output buffer processing useless for OO
applications. I had to change a lot of code - for the worse - to make it
compatible.
Reproduce code:
---------------
<?
ob_start('callback');
class Test {
function method() {
return 'cow';
}
}
$test = new Test();
function callback ($content) {
global $test;
return 'm:'.$test->method();
}
?>
Expected result:
----------------
cow
Actual result:
--------------
[none]
httpd: PHP Fatal error: Call to a member function method() on a
non-object in (...).php on line 16
--
Edit bug report at http://bugs.php.net/?id=44840&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44840&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44840&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44840&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44840&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44840&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44840&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44840&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44840&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44840&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44840&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44840&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44840&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44840&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44840&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44840&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44840&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44840&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44840&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44840&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44840&r=mysqlcfg