Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77042 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12785 invoked from network); 2 Sep 2014 19:29:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2014 19:29:15 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.75 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.75 smtp75.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.75] ([108.166.43.75:48033] helo=smtp75.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/10-11031-48A16045 for ; Tue, 02 Sep 2014 15:29:15 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp10.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 423DC3803F9; Tue, 2 Sep 2014 15:29:06 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp10.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id B5442380245; Tue, 2 Sep 2014 15:29:05 -0400 (EDT) X-Sender-Id: smalyshev@sugarcrm.com Received: from Stass-MacBook-Pro.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net [108.66.6.48]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.2.10); Tue, 02 Sep 2014 19:29:06 GMT Message-ID: <54061A81.2090509@sugarcrm.com> Date: Tue, 02 Sep 2014 12:29:05 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: jocelyn fournier , Nikita Popov CC: PHP Internals , Dmitry Stogov References: <54027B6D.7060708@sugarcrm.com> <54036DEA.8060902@sugarcrm.com> <5405783D.5010204@sugarcrm.com> <5405C2FB.9030301@gmail.Com> In-Reply-To: <5405C2FB.9030301@gmail.Com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] destructors and output_buffering From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > One line fix, nice :) > > A quick question about how resources are freed : > if some variables are computed inside a singleton and read through a > myclass::instance()->get_my_variable(), should we expect to have those > variables available when calling ob_start() callbacks ? > > From experiment, they are still available, but since > zend_call_destructors is called before ob_start(), I wonder if this is a > safe behaviour. Generally, it would depend on when they were created. If they were created before shutdown stage and you try to access them in OB shutdown stage, it may be too late and the dtor may have been called for them already. Doing too much stuff on shutdown is not really a good idea, as you can not rely on resources being there. If you really need to do something on shutdown, I'd advise register_shutdown_function() as it is called first, before anything is really shut down. Relying on OB handlers shutdown is not a good idea as by then at least part of the shutdown happened. If you do something with OB handlers, I'd propose to add a shutdown function that flushes the OB, so that you are sure everything is wrapped up while the engine is still in predictable state and not half-shutdown. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/