Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112401 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77097 invoked from network); 3 Dec 2020 21:45:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Dec 2020 21:45:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 25B10180511 for ; Thu, 3 Dec 2020 13:13:27 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 3 Dec 2020 13:13:26 -0800 (PST) Received: by mail-lj1-f180.google.com with SMTP id f18so4126200ljg.9 for ; Thu, 03 Dec 2020 13:13:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yTICRxLDWf+zRbG6aagl437PlUcJeqhl2GRXfENLPxw=; b=btW+ep6+IrZcOzICSADiIeISMWr3jpbHlRvxZ39NFdMw0DYyNcFSQWDTL0+jHnWMy9 1rsWoaMrFiXblTsvHNTiv0fsgwCO2R2t1jGtYfSA1vhjvNWOy/gP3j00RVNsi88nGMkT cRiVsKr11TWTR/Ni2LIuyb2IR38qkbbzf6I6Mf/Rfh+JaGyYc2UoDs+l5tBxxKMq/r59 TSNLFCRKvIYefm0AL2yeI6Bq0tAPtF0JzMw39cl2Ka/99WfiM5V799F/moAqZNwiLoBC Zn0pfwMTQLM1CzOcVKNSIUx8433vlY8KistUG35RTua0g2pHKBL+Z9riTGRi2E4bz7Hm rtng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yTICRxLDWf+zRbG6aagl437PlUcJeqhl2GRXfENLPxw=; b=lpLYK1+zq8IFB7DUaeThnnVBUt4mmFPhYdaBIu7K6LIPMH7UZfME1XL/juldNSn5QO vPT2DfgaGRBiTMWW8wAA0TmZ8O2ATgEQXv214uI/zMFwsWcR4TVs7+H9TBW4eFveBNB7 ojA2g+sMO+2e0LUEEum2b5Lijxo/RRIn0FfbyPqhsRPcKBpnK+9vAusKKYUoHYfgALTW XhJkU/8JMiBSZYsYT3d4yC+u+I++BLhnYrrdv0LiWhK2i9TkrrdrfQgErauupeZtJNCz 60QQ2D1c53hxdnX+KNjArsQzpSAs6mYrD228yHHpWS+N1z66E4ZBjmj0/v2iGyP/IfJc MbnA== X-Gm-Message-State: AOAM530lCsd+r72XKmDiEnPV5acJ6RkFe6sUDr/3Cu4GyJcKBO1Jjis2 b2BxgKPoJ0bkWN9GwbpH2/GemwWp4JMGlerRxzc= X-Google-Smtp-Source: ABdhPJxwt+3HATkWHyNh55cL8djfWkiDg7AQmiHR5AaTk04qkhlVMA8SkUXuCK37f0dtgIZUIS0d2c/YNfvYwnFn+Sg= X-Received: by 2002:a2e:8796:: with SMTP id n22mr2009555lji.345.1607030004675; Thu, 03 Dec 2020 13:13:24 -0800 (PST) MIME-Version: 1.0 References: <34FA3E20-9D06-4D08-937E-4216FEF35504@gmail.com> <7E98C687-7A24-49E7-A14C-3D68B4B3419E@gmail.com> In-Reply-To: Date: Thu, 3 Dec 2020 22:13:08 +0100 Message-ID: To: Levi Morrison Cc: Claude Pache , PHP Internals Content-Type: multipart/alternative; boundary="000000000000927b1505b595d4c8" Subject: Re: [PHP-DEV] Missing warning for stat(), etc. when invoked with empty string From: nikita.ppv@gmail.com (Nikita Popov) --000000000000927b1505b595d4c8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 3, 2020 at 10:06 PM Levi Morrison via internals < internals@lists.php.net> wrote: > On Thu, Dec 3, 2020 at 6:30 AM Claude Pache > wrote: > > > > [Of course, I meant `stat()`, not `stats()`. Resending the message with > correct spelling, including in subject line. Sorry.] > > > > > > Hi, > > > > `stat()` and friends invoked with empty string or null as argument, > return `false` (indicating failure), but do not emit the Warning that is > expected on failure. See: https://3v4l.org/jXC2N > > > > That discrepancy between the two ways of indicating failure is > problematic. Indeed, whenever I use one of those functions without > prefixing it by @, I expect that it will either return a value of expecte= d > type (`array` in case of `stat()`), or run the panic procedure of my erro= r > handler. > > > > I propose to ensure that those functions always emit a Warning in each > and every situation they return false/null (provided, of course, that tho= se > functions are not supposed to return `false/null` in absence of failure, > and that their purpose is not to check for failure condition as in > `file_exists()`). > > > > =E2=80=94Claude > > > > This is a long-standing behavior. Further, I don't know many people > who want _more_ warnings in their codebase. > > In other words, I disagree with this proposal. This seems like a pretty odd position to take. I think there's two ways it can reasonably behave: 1. Always generate a warning if stat() fails. 2. Never generate a warning if stat() fails. While the current option is: 3. Always generate a warning if stat() fails ... unless an empty string was passed. I'm okay with either 1. or 2., but I don't think that 3. constitutes sensible behavior. Regards, Nikita --000000000000927b1505b595d4c8--