Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112361 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24751 invoked from network); 1 Dec 2020 21:07:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Dec 2020 21:07:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F0E3A1804C9 for ; Tue, 1 Dec 2020 12:35:18 -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, 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-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 ; Tue, 1 Dec 2020 12:35:18 -0800 (PST) Received: by mail-wr1-f42.google.com with SMTP id u12so4861126wrt.0 for ; Tue, 01 Dec 2020 12:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=cIgnh+NtlHZBrewKVCPP6BtQsayaqjb3ykO1P3BeMf0=; b=oYXy5pNC5SvgDX37GmBhIyWi6JAUroK5KYOHHyaf88cT6J5hEu4t4qzYoqNpr7FZdu r8NCoqRn29PMnaIrjIzGHzQG0e13NX3AnGok6CrNToEfIXjkDTB8yl3QPFW917lUITwe W6txBj+FDpESDBevYnDEUPe1G4B5P+TvFdX38eaWBD5IgcF2g5SkFvbgLcio7skyg40s 7/tdYAjqBergsLcoyihXsJCRVONNNdwa1iUD38JJ9Py3Jy7wKYrxrSmNa/gAXufhhCsj rAVOMG9cqP76Hq+Ij/ebT4sIZiCMSYA0qN4L9iFFZWRBbVYO+HakEPgSe78Lib4/eloX Ku/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=cIgnh+NtlHZBrewKVCPP6BtQsayaqjb3ykO1P3BeMf0=; b=e2T1ILAGmsFMs1DbGqR5MWZ1v3rFLex/EzlXBeTranNNhr5jYUktZiER9sBpsI2ZtD B4dD4yf5PEZ+JrTPnef0u8SCM4QPu/Awt+I4XYgBr4fq6MCfgL75EYgdJp5Zc+9AmOZ+ R/Td3mEWIgyu7oKv05FIV3f8gAIIu0RmK3Zx0Hyi4Q5DSTPQpDEgZp0Ji7VJDCNQztN0 4cPcCa7KrjgRmdBhNSeiNo8MMVB8in7BmjNf/OwSO+kSR9xfBOV42XVoQhnT4wpK97Io jC3SF9kyVH/yIEBeyt3aZRYXU5yHt6WwlC3QZaQ+h+EiSqz58h/kOgnIEGjxCceccIgJ +ZTg== X-Gm-Message-State: AOAM532FcDoqi70m2aUUpvsORkTsmToKtcJ/1Fa0mrtFauFAJ2ip43qC SSD/N1rk04LLHxjb+bjT7ehH/keSqEk= X-Google-Smtp-Source: ABdhPJzjA8Cu6QoaSTppGrJnIDGsc7308Lb5plTx/AvNDbo3Rog8F+QTj35pcI9BG71/t4g5GXV6Aw== X-Received: by 2002:a05:6000:1288:: with SMTP id f8mr6306033wrx.261.1606854914457; Tue, 01 Dec 2020 12:35:14 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id p11sm1229815wrj.14.2020.12.01.12.35.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2020 12:35:13 -0800 (PST) To: internals@lists.php.net References: <0774c293-afd7-d8b9-175f-217ed600d1ea@aimeos.com> <29529061-dc71-c759-590a-b4786936f8c5@aimeos.com> <96e40442-a649-f9af-a0cc-dd43cfd1bd0c@gmx.de> Message-ID: Date: Tue, 1 Dec 2020 20:35:14 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Re: PHP 8 is_file/is_dir input handling From: rowan.collins@gmail.com (Rowan Tommins) On 01/12/2020 20:06, Stanislav Malyshev wrote: >> is broken is a great illustration of that. PHP 8 makes it obvious >> that the >> cited code is incorrect. > > But it's not incorrect. if is_file("abc\0") returns false, it's > correct - "abc\0" is not a correct filename, so I expect it to return > false. It does exactly what I need, so it's correct. The posted code is correct under a theoretical version of is_file() that returns false for that input, but it is incorrect for all versions of PHP after PHP 5.4, since they return null (as shown by the sample posted by George: https://3v4l.org/7E2mv) so the ===false condition will not be met. I think we can all agree that the previous behaviour was less than ideal - the NULL return value was undocumented and unexpected, and the wording of the Warning was pretty vague. If I'd never seen this discussion, I think my assumption would be that invalid input would simply return false in this particular case - if the path is logically impossible, then it's not a file. However, I wonder if there other functions also use this undocumented "file path" input type, where there isn't such an obvious safe return value, and throwing an exception is more justifiable. Regards, -- Rowan Tommins (né Collins) [IMSoP]