From:             guessousmehdi at hotmail dot com
Operating system: windows
PHP version:      5.2.0
PHP Bug Type:     Output Control
Bug description:  objects destroyed, but not always on callbacks functions

Description:
------------
When I  terminate a script by an exit,
before end  of execution, ob_start allows to 
to invoke a callback function.
>From this callback function, I cannot access to an 
object (in source example:$t1) previously initiated in the script. 
However, if I save a dummy copy of that object in a new variable (for
instance $t2), then it work as expected.
In the source example, just uncomment the line "$t2=$t1;"
to see what I mean.
I works normally in previous version of php (php 4 and first releases of
5)
I cannot remplace the exit at the end by an ob_flush(), because I'm
including a big script in my real work, which is much more complex than
the example I provide.

Reproduce code:
---------------
<?php
class test{
        function nice_string(){
                 return "hello world, how are you ?";
        }       
}
$t1 =  new test();

// the following commented line makes a difference 
//$t2=$t1;

function callbackfunc($output){
         global $t1;                    
   $output ="chocolate<br>". $output . "<br>". $t1->nice_string();     
        return "$output";
}
ob_start('callbackfunc');
echo "what a nice day";
exit();  ?>

Expected result:
----------------
should output:
chocolate
what a nice day
hello world, how are you ?

Actual result:
--------------
output nothing,
blank page,
probably a fatal error without any indication about it.

Uncommenting line $t2=$t1 and it works fine again.

-- 
Edit bug report at http://bugs.php.net/?id=39693&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39693&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39693&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39693&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39693&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39693&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39693&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39693&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39693&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39693&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39693&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39693&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39693&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39693&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39693&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39693&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39693&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39693&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39693&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39693&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39693&r=mysqlcfg

Reply via email to