Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101987 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5301 invoked from network); 20 Mar 2018 22:13:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2018 22:13:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=dennis@birkholz.biz; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@dennis.birkholz.biz; sender-id=pass Received-SPF: pass (pb1.pair.com: domain birkholz.biz designates 144.76.185.252 as permitted sender) X-PHP-List-Original-Sender: dennis@birkholz.biz X-Host-Fingerprint: 144.76.185.252 mail01.nexxes.net Received: from [144.76.185.252] ([144.76.185.252:46258] helo=mail01.nexxes.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/10-03694-69781BA5 for ; Tue, 20 Mar 2018 17:13:43 -0500 Received: from [192.168.178.24] (xdsl-87-78-250-126.netcologne.de [87.78.250.126]) (Authenticated sender: db220660-p0g-1-m5x-1) by mail01.nexxes.net (Postfix) with ESMTPSA id 5147B86036D for ; Tue, 20 Mar 2018 23:13:39 +0100 (CET) To: internals@lists.php.net Message-ID: Date: Tue, 20 Mar 2018 23:13:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------596E19E47F729CAD6C247FEA" Content-Language: en-US Subject: Weird destructor call order on stream wrappers From: php@dennis.birkholz.biz (Dennis Birkholz) --------------596E19E47F729CAD6C247FEA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hello together, today I noticed that the order in which stream_flush/stream_close and the destructor of a (userspace implemented) stream wrapper are called is weird: When a stream is closed with fclose(), the call order is as expected: stream_flush, stream_close, finally the destructor. But if the stream is closed automatically on program exit, the order seems wrong: stream_flush and stream_close are called AFTER the destructor was called (and so the object should be destroyed!) The documentation (http://php.net/manual/en/streamwrapper.destruct.php) for the destructor contains the ominous sentence "Called when closing the stream wrapper, right before streamWrapper::stream_flush()." which is clearly only half of the truth. Example: https://3v4l.org/CMItP Is this some kind of "desired" behavior? Should I open a bug? Greets, Dennis P.s.: In addition to the call order, in auto-close case autoloading with registered autoloaders does not work inside stream_flush and stream_close, it seems registered autoloaders (maybe all objects) have been dispatched when the calls happen, see: https://3v4l.org/GB7Mm (I also appended both example files as I don't know how long snippets at 3v4l.org persist) --------------596E19E47F729CAD6C247FEA--