Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100816 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61332 invoked from network); 3 Oct 2017 15:21:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2017 15:21:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.216.172 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.216.172 mail-qt0-f172.google.com Received: from [209.85.216.172] ([209.85.216.172:51053] helo=mail-qt0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/C1-34435-6FAA3D95 for ; Tue, 03 Oct 2017 11:21:26 -0400 Received: by mail-qt0-f172.google.com with SMTP id f15so13596309qtf.7 for ; Tue, 03 Oct 2017 08:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=8PWvm0HkAl27sxdCO3f6EZ2dAliSg17T7R1QxGFqG+I=; b=c8NE2wSfKrIBKLbcK45wL0GASMdpaTeyRxN7I923z5RIqDIXa+IjpIm6uNqIZ+4d6B 8k19mdhAMmiUsWtjw796lMtUPk2UwHM8B2LCFHU2rbIlV8EWnsFE06GrU2Y4GzysCeiA jnH8c0XrA33H7xqiIq5AFjSeEp5rgThNIaglE17Dmub6HXhL3fusXBJNXnxdD6f9tdDh ksFfg72RMIADHG25r70ktBokAbo9LunVBO7eEuZXlniiuaLep1s110OiHecm9UECG98S Rui6LSGH+sw6ZXHAVsVltQcOu7jPxmeISJyglvcxXoJpbq+nkGEhRru2YwhE2b3A+OkC RWEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=8PWvm0HkAl27sxdCO3f6EZ2dAliSg17T7R1QxGFqG+I=; b=kPKlJfO/D9UMe2acGzbHODHLTRkfqzNmvzpCz5XAYRI70U3xDgQHkvC9DvrWuvHrGB QQzCXYkUwqaxRYWemHcHOuUp8VhPqE4RzK6Ps5sL2/Sb8POwRPlbmPvASFji87iHtQTg PcYVSqseq9tzjxxAY0quXLY6KjPCoE0C6XL8magvhnhOeq+vM0hIXT1s4zWeR9FRwzs5 SMew3WxQZsjjFDLvZZRhUYpi2mYGMgAHXr5JmACAtMmkkUN5G3vdZVjT+vGi/d2aPKru IE7N0Z3DNNy6Ont4aW1D8s48deO+vgNDbvz3HgZGtkPTi+HMAbcTuhaLrky8GWa+gdBP pcVw== X-Gm-Message-State: AMCzsaU6phX5QGutMGX+AcbDu79QAzdcsrhiD/TPts2Xcs04NnacAa5z aLcga3LZdeJcEmAv1wNtkuvr79IA2BqKZGRCNJoUU4uh X-Google-Smtp-Source: AOwi7QADwF+gXmHuTxybUhOoCix6csPLFsRwf667qKNMf0nUYtCRvJwGUuVtbho4BAN0PSKv7bb0kfIRmRrd3YmqZTs= X-Received: by 10.237.44.34 with SMTP id f31mr22682640qtd.252.1507044083273; Tue, 03 Oct 2017 08:21:23 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.156.130 with HTTP; Tue, 3 Oct 2017 08:21:22 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: References: Date: Tue, 3 Oct 2017 11:21:22 -0400 X-Google-Sender-Auth: hFzXivJaR2xw1_3nJnuO3Hnxtx8 Message-ID: To: Dan Ackroyd Cc: nyamsprod the funky webmaster , "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Making stream functions accepting SplFileObject as valid parameter From: pollita@php.net (Sara Golemon) On Tue, Oct 3, 2017 at 9:44 AM, Dan Ackroyd wrote: > On 29 September 2017 at 07:46, nyamsprod the funky webmaster > wrote: >> >> I've been following the resolution of this bug: >> >> https://bugs.php.net/bug.php?id=44392 >> >> and it seems that there is no safe way to expose the internal >> `SplFileObject` filepointer. > > > It seems that people are scared to comment on a streams related question... > Nah, just distr... OOH SHINY! > I'm not sure that making stream_* functions accept SplFileObject's > would be an appropriate way to solve this problem; it's just too much > of a hack. > Implementation wise, about as difficult as you'd imagine. We have php_stream_from_zval() which is a central place which could be made smarter, though most (all?) stream related functions have IS_RESOURCE checks that'd have to be dealt with, so it still means touching the world. > However, although it's not safe to expose the underlying file handle > used by SplFileObject, I think it _might_ be safe to allow the > SplFileObject to return a stream that represents the file, but with > the necessary php_stream_ops that aren't safe to use replaced with NOP > operations, similar to how it is done in the pgsql extension: > https://github.com/php/php-src/blob/879126a2cedef5b6e1c1f701ade17ca3da9a39ec/ext/pgsql/pgsql.c#L5406-L5409 > I like this approach in the abstract (though I haven't paged in the entire problem space yet). A proxy wrapper provides (possibily implemeted on the SplFileObject itself) keeps the scope of the change localized to SPL and has little residual hack smell. -Sara