php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39546 Objects destoryed before output buffering
Submitted: 2006-11-17 14:05 UTC Modified: 2006-11-17 15:05 UTC
From: lasse at cederstrom dot dk Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.2.0 OS: FreeBSD
Private report: No CVE-ID: None
 [2006-11-17 14:05 UTC] lasse at cederstrom dot dk
Description:
------------
When the code reaches the callback function for ob_start, the objects in $GLOBALS have been destructed.

In earlier versions of php they were not destructed at this point, making it possible to use $GLOBALS['object']->func() in output()

This is new behaviour for 5.2

Reproduce code:
---------------
<?php

class dims
{
        function x()
        {
                return "Muhahahaha";
        }
        function __destruct()
        {
                echo "IM GOING DOWN!!!";
        }
}

$GLOBALS['d'] = new dims();
function output($buffer)
{
        var_dump($GLOBALS);
        return false;
}
ob_start('output');
?>

This is a test
<hr>
<?php
        var_dump($GLOBALS);
?>


Expected result:
----------------
To have $GLOBALS['d'] still be there when reaching output()

Actual result:
--------------
$GLOBALS['d'] should still be available in output()

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-17 15:05 UTC] tony2001@php.net
The current shutdown order has been discussed numerous times and it was decided to leave it as it is at the moment, i.e. 
1. shutdown functions
2. destructors
3. output buffers
4. HTTP headers
5. modules request shutdown
6. globals
.. others.

For more information about this chicked-and-egg problem you can look in the internals@ list and in existing bug reports.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC