Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113982 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25466 invoked from network); 6 Apr 2021 22:05:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Apr 2021 22:05:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6A65D1804CC for ; Tue, 6 Apr 2021 15:04:11 -0700 (PDT) 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-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.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, 6 Apr 2021 15:04:10 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id r22so5854607edq.9 for ; Tue, 06 Apr 2021 15:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=10v94dLXQYV5eMQNIP8F29J4BbYgpGFvMovcvp9gywA=; b=YfFjE4eT8bN5xBmyefh+ZlEo05rD1HvVGdGrKVXDuZHCALrEdk84GOvfVTigUNDFUz YydB7HkFztc32dTm4faIozA8MqK3H7snROPSj4tTaF/mdRcEnKdPr93MM9uRjigmIlrD cBjLN1jInKn4jbPUBVecbCDg2Pg0oQj4cD38XRi6k00czVSDOBuAkrS/ItOU7JKOg3qx fOYBXDpLlUhzr1Irm5KTuB9QHxk9KOjup+OJiGwOnGS4cd0bgPmotN67leDn9C83mnd3 aJciG2Xa4VuQrrBYRAcobaUi/OiIH2K8uVY928OjGsrW7oOwRP5H0OHKUTKUc9rRicAc aOxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=10v94dLXQYV5eMQNIP8F29J4BbYgpGFvMovcvp9gywA=; b=gg8qObTaIEsm07w4G56RvRVGz14Nz/q8yJilKMQRWcPSBtYR5RykyQGMjVvfZJxrEp DV9wd9qfjl7F23q5IDyaDemQqja9/okNndcdvfSiL1VFbnTOG/wG3moyG1xnhiykVZf0 PEsUwVD4CHJJnBE0B/mGX2H6O9MXRJ/SVrCJiZxV7EZrHCvH4rUFq644HIfmkKkZcKp0 3a90K3SFqUBrcOyhXoYuMHMwjjC7T98YtTB8bjrYYu2h/UdEQK5voHOaz0OBlSyMhpJz jvNxx/FGkPr0pJi7QosyiQMr0PC0PTZZgdk/mCjGcIBY9+nIU1BScxvDkctiL7+K3IHU tVxA== X-Gm-Message-State: AOAM531fx4DiPIesGV6FVoArdjE8pl47tvDOm8XKfhrtb42+roug/fqh 0qbgLKutsALImyFiiQGCjZvd06IMRfM= X-Google-Smtp-Source: ABdhPJyns4Va+UQ4RHuKZfXSFNugWjgX2XZ84Aaziej9TXnFkk6A+4BiyboU486xG8E0V3utK+LFOQ== X-Received: by 2002:aa7:dd4d:: with SMTP id o13mr581433edw.53.1617746647807; Tue, 06 Apr 2021 15:04:07 -0700 (PDT) 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 i16sm4880935ejg.63.2021.04.06.15.04.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Apr 2021 15:04:07 -0700 (PDT) To: PHP Internals Message-ID: <754310d2-f12e-84fc-cbc8-55f6e46e2ff8@gmail.com> Date: Tue, 6 Apr 2021 23:04:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Function getdir() accidentally exists From: rowan.collins@gmail.com (Rowan Tommins) Hi all, Following up this Stack Overflow question https://stackoverflow.com/q/66854655/157957 and accompanying bug report https://bugs.php.net/bug.php?id=80914 I have discovered the odd fact that a function was accidentally added to PHP 8.0: getdir() is now an alias for dir() Well, actually, it's slightly weirder than that: dir() is the alias, and getdir() is the real function. It's just that from PHP 4.0 until PHP 7.4, only the alias existed: https://3v4l.org/ZHJ9U In PHP 8.0.x, getdir() is a callable function, and users can't define a function with that name. Here's what seems to have happened: dir() is a function from PHP 3, which is why it creates a weird object with no constructor. Its function entry originally looked like this: {"dir",            php3_getdir,    NULL}, Because the PHP function didn't match the C function name, this got translated to a function *alias* in PHP 4 [1]: PHP_FALIAS(dir, getdir, NULL) But it wasn't really an alias: there was no separate PHP_FE line for "getdir", so "dir" remained the only name you could actually use in PHP code. This situation survived until the move to add arginfo in PHP 8. Maté, quite reasonably, saw that getdir() was missing a stub, and added one. [2] The stubs were then used to re-generate the function entries, and after more than 20 years, getdir() finally got its own function entry:     ZEND_FE(getdir, arginfo_getdir)     ZEND_FALIAS(dir, getdir, arginfo_dir) I've compared the list of PHP_FE / ZEND_FE macros in 7.4 and 8.0, and can't see any others that are obviously wrong, although I noticed that get_mangled_object_vars isn't documented. The obvious question is: should this be considered a bug, and undone, and if so, how? The answer is probably to do what should have been done 20 years ago, and rename the internal definition to match the function name exposed to the user. [1] https://github.com/php/php-src/commit/7a167cd0c1f6ee7c0dce0196b5ca9209a54f534c#diff-a6738c9e7e606e49fc4e7225c281deca86191ada31a5dc077169418541541d1cL59 [2] https://github.com/php/php-src/commit/736b22dc0b2fc36e9bd87f2ee5af8c4b2be9fd3d#diff-96c05a0551ccbeca3ff610c111f88b54a0d727888cf353f477ea8dc951a18637R723 -- Rowan Tommins [IMSoP]