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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lasse at cederstrom dot dk
New email:
PHP Version: OS:

 

 [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: Thu Apr 25 23:01:29 2024 UTC