Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77043 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15421 invoked from network); 2 Sep 2014 19:38:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2014 19:38:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=jocelyn.fournier@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jocelyn.fournier@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.181 as permitted sender) X-PHP-List-Original-Sender: jocelyn.fournier@gmail.com X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:60615] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/A0-11031-8CC16045 for ; Tue, 02 Sep 2014 15:38:49 -0400 Received: by mail-wi0-f181.google.com with SMTP id e4so8538009wiv.14 for ; Tue, 02 Sep 2014 12:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:message-id:date:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=qnoWlcodvac6zODQnBRdyC1jvRQsRnkxcZC/L57DWr4=; b=02klgUqE1nAG+Yua0jw8ActHGrIYjdGDm3WUXZjsQxdhkfeupLUgeQ9e99sgSRD7YT 8knY39syvfqE1ljrmsdM12055s4bAPtDds7Z2wbjk7MWvotKf+S8g/y91DBxUp7WXKRh 6s6aePTjHBPdn14anrflJoA3JQB0ItOpCckXkZvBgzhD2DpvEgT+uEs75vpm7IWUlEhX J8kXNA7l5vkoyIuI6bg04npufst4f/TE8dElHxJmGBNBXgz6UCv6S/75QSMCdNEhlxE7 Xez1RS3l+73wu3o7JJfbD4nKkkki56dQEqfhhEW7E2nGfSf+A9SMN9UjVQ2Lr6MWJgYX OIAA== X-Received: by 10.180.20.148 with SMTP id n20mr12578408wie.22.1409686725777; Tue, 02 Sep 2014 12:38:45 -0700 (PDT) Received: from MacBook-Pro-de-jocelyn-fournier.local (ven06-1-82-234-156-61.fbx.proxad.net. [82.234.156.61]) by mx.google.com with ESMTPSA id ju1sm11548407wjc.1.2014.09.02.12.38.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Sep 2014 12:38:45 -0700 (PDT) X-Google-Original-From: jocelyn fournier Message-ID: <54061CC2.4000201@gmail.Com> Date: Tue, 02 Sep 2014 21:38:42 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Stas Malyshev , Nikita Popov CC: PHP Internals , Dmitry Stogov References: <54027B6D.7060708@sugarcrm.com> <54036DEA.8060902@sugarcrm.com> <5405783D.5010204@sugarcrm.com> <5405C2FB.9030301@gmail.Com> <54061A81.2090509@sugarcrm.com> In-Reply-To: <54061A81.2090509@sugarcrm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] destructors and output_buffering From: jocelyn.fournier@gmail.com (jocelyn fournier) Hi Stas, Actually I would love flushing ob_start() in my own shutdown function, but since my application is a library called in auto_prepend_file, I have to protect ob_start() from being flushed too early by some wrong code in the client application. Hence I'm removing the PHP_OUTPUT_HANDLER_CLEANABLE, PHP_OUTPUT_HANDLER_FLUSHABLE & PHP_OUTPUT_HANDLER_REMOVABLE, but then I'm not able myself to flush the buffer :( A great "new" feature would be to optionally give a name to a buffer, and then allow to flush this buffer only if its name is passed through ob_end_clean / ob_end_flush / ... Thanks, Jocelyn Le 02/09/2014 21:29, Stas Malyshev a écrit : > 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. >