Re: [PHP-DEV] destructors and output_buffering

[email protected] (Tjerk Meesters)
Newsgroups php.internals
Message-ID <[email protected]>
On 31 Aug, 2014, at 12:40 pm, Stas Malyshev <[email protected]> wrote:

> Hi!
> 
>> This is just a thought; could we delay the call to
>> `zend_call_destructors` ONLY IF there’s output buffering taking place
>> (i.e. ob_get_level() > 0)?
> 
> That wouldn't help - imagine this:
> 1. ob_start is set
> 2. shutdown is starting
> 3. ob functions shut down, call function foo
> 4. function foo creates an object of class FooBar
> 5. ob shutdown ends, all output is flushed, etc.
> 6. FooBar::__destruct is run and tries to output something

So let it output something ...

Trying to output something in a destructor after flushing the output seems rather fishy; at the same time I’m quite aware that it’s impossible to predict what some developers would expect to happen in such cases.

> 
> That scenario still may have a problem. I'll check more into if it's
> really a big deal outputting after OB shutdown (after all, some other
> things may lead to it too) but conditioning dtor move does not solve
> this problem. If it works this way we may as well move them there
> permanently.

Yeah, I can see now how my suggestion doesn’t really need the condition then :)

> -- 
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.