|  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
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:

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

$GLOBALS['d'] = new dims();
function output($buffer)
        return false;

This is a test

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-17 15:05 UTC]
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-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 29 08:01:24 2023 UTC