php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42132 suggest a fix for global object got destructed in output buffer handler
Submitted: 2007-07-28 14:30 UTC Modified: 2013-09-26 14:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: xuefer at gmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5CVS-2007-07-28 (CVS) OS: gentoo linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xuefer at gmail dot com
New email:
PHP Version: OS:

 

 [2007-07-28 14:30 UTC] xuefer at gmail dot com
Description:
------------
it seems that the implicit ob_end_flush() is called after object destructions.
uncomment any ONE of the comments gives "okay". but this is not the official trick that supported by php.

the php bug system suggest me this bug is by design in #39546 #39629 etc.

there's many register_xxx arround my php files, which install data into a global object, and the output buffer handler will inject the data into the output in the correct place. if this bug is not fixed, the only way i can do is to rewrite the object into array/functions

anyway, i have a suggested fix to change the work flow a bit:
 1. flush and pop all OBs but leave 1 top OB on shutdown
 2. destruct objects
 3. flush the last OB if there's any

no matter if this bug is gonna be fixed, there shall be a page that give explanation and work arround to this issue.

Reproduce code:
---------------
<?php
class Obj
{
}

function callback($content)
{
    return isset($GLOBALS['a']) ? $content : 'oops';
}

ob_start('callback');
$a = new Obj();
//$b = $a;
echo 'okay';
//ob_end_flush();

?>

Expected result:
----------------
okay

Actual result:
--------------
oops

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-29 23:41 UTC] jani@php.net
See also bug #39546 and bug #39629 
 [2013-09-26 14:53 UTC] mike@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2013-09-26 14:53 UTC] mike@php.net
http://3v4l.org/2ZsYF
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC