Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100812 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52686 invoked from network); 3 Oct 2017 13:44:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2017 13:44:24 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 74.125.83.46 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 74.125.83.46 mail-pg0-f46.google.com Received: from [74.125.83.46] ([74.125.83.46:57112] helo=mail-pg0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/70-34435-53493D95 for ; Tue, 03 Oct 2017 09:44:22 -0400 Received: by mail-pg0-f46.google.com with SMTP id n1so4038879pgt.13 for ; Tue, 03 Oct 2017 06:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fRCObnK3OwFF/eWLePSaHm/EauieZQYW6pD8Vxk8s6k=; b=kb2AvqNl5cisizYJKxB9pDJg+z8I9Bq/fNJtxn5QCVuo1W/G52rTVwUxYTfRfUSY+2 n1JPDZgSO2/mAnRYlRhk0RVVXcRsREb5IBseWdHfe1dmiAdh9WatmWy9CJBEcgizJlbo tjsMU+RB4ZEp8cvZeiDgxhn7cMezf2OBnDyLFOeLb4zN4QFt0W7Q1zoVN4SUCvJJv42+ LQ4FT6ir/f6Cetd3/a+aDMWNkyNOAcCNYvVkQBYlznIGt8YuY9t63uQewhYqLWH9IYXN eJpqh3jtYaFaU4ijajVQ0R9aKdmuFSc4AvUeWMrAfFoADM3F64DGW9AjI3AyddtrCBrQ 7jaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fRCObnK3OwFF/eWLePSaHm/EauieZQYW6pD8Vxk8s6k=; b=llpf6MLRNyCRm3nDlXFSu7G5iK8JT+2VJohHzhzDZAeWW87Sm7uRHCS+YiRpgCJYqy EoTkyd0ymAll5SjH+Iu7X0dst7kXrAALxNhRPdMIdWMl7OdywSCGgmDFk8A1MXsp5tKi UvjwvlgamnyKasFZZnlKohTMIsONzZprBa2r8mpY7kBng9WShoPDA7TFVZGCCq0mOY7d GNrni2h0WCWeIj9QCLtOwF1XXBxGkqTRNrYCrANmb4Uz+nXRpeq09CeBapOXHOMOdjQC 7CN26SIT7XLzHCYUWqFpIIpZTLEn7g3lZEvpeXVLwSoTEX7pcoXFZgF32soJ/1s7wTVB RwhA== X-Gm-Message-State: AHPjjUgM5KW6D5ldxXjYJuAD9RMXaPhGhguZq/f3OLYPemiIZbsVHAAa fbCsiWo/lKCpLeCYkFDxck+StFw0qbB8+2ZNkLkYyw== X-Google-Smtp-Source: AOwi7QDuvCs2HMJ7A5FsebVDiJcXjp376xpb2FJxrj0He69T6BOC+NozDpWX+Vgz0ojWz7aPvGpO5lSPqYQO8lYsNgE= X-Received: by 10.99.129.199 with SMTP id t190mr11978225pgd.227.1507038258546; Tue, 03 Oct 2017 06:44:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.151.165 with HTTP; Tue, 3 Oct 2017 06:44:18 -0700 (PDT) X-Originating-IP: [81.143.203.71] In-Reply-To: References: Date: Tue, 3 Oct 2017 14:44:18 +0100 Message-ID: To: nyamsprod the funky webmaster Cc: "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Making stream functions accepting SplFileObject as valid parameter From: danack@basereality.com (Dan Ackroyd) On 29 September 2017 at 07:46, nyamsprod the funky webmaster wrote: > Hi internals, > > 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. Hi nyamsprod the funky webmaster, It seems that people are scared to comment on a streams related question... 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. 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 static int php_pgsql_fd_close(php_stream *stream, int close_handle) /* {{{ */ { return EOF; } To expose the internal stream to userland. I'd really like to hear from anyone who knows about streams internals to know if that's a viable approach. cheers Dan Ack