Bug #80914 [PATCH]: function_exists is now case-sensitive for aliases

From: Date: Sun, 11 Apr 2021 19:30:25 +0000
Subject: Bug #80914 [PATCH]: function_exists is now case-sensitive for aliases
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233353@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80914&edit=1 ID: 80914 Patch added by: rowan.collins@gmail.com Reported by: chris at vendiadvertising dot com Summary: function_exists is now case-sensitive for aliases Status: Open Type: Bug Package: *General Issues Operating System: All PHP Version: 8.0.3 Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Remove the "getdir" function which was introduced accidentally On GitHub: https://github.com/php/php-src/pull/6855 Patch: https://github.com/php/php-src/pull/6855.patch Previous Comments: ------------------------------------------------------------------------ [2021-04-11 19:29:35] rowan dot collins at gmail dot com The problem here is actually not related to case-sensitivity. The function/alias getdir() didn't exist until PHP 8.0, and it turns out it was actually added by mistake. For the full story, see https://externals.io/message/113982 and https://stackoverflow.com/a/66981991/157957 The current plan is to remove it in the next 8.0.x release. ------------------------------------------------------------------------ [2021-04-06 20:10:35] rowan dot collins at gmail dot com There's actually something a lot weirder going on here. Firstly, looking closely at the source, it seems that internally, getdir() is the *real* name of the function, and dir() is the alias. Secondly, there is no case-sensitivity change, and function_exists() was telling the truth, getdir() really *didn't* exist on older versions of PHP: https://3v4l.org/dCpeh It seems that this function had been there for years as some kind of ghost, and a change in PHP 8 brought it to life. ------------------------------------------------------------------------ [2021-03-29 17:54:25] chris at vendiadvertising dot com I went through all 25 aliases listed in https://github.com/php/php-src/blob/master/ext/standard/basic_functions.stub.php and it seems that getdir is the only only that is not listed in the PHP docs, so I'm fine reclassifying this as a documentation update for that specific function. I do still think, however, with how many aliases exist in PHP that this could still be a problem for future upgraders. ------------------------------------------------------------------------ [2021-03-29 15:20:33] chris at vendiadvertising dot com I absolutely agree that writing a function with the same name as a built-in but with different case is asking for trouble. But is there a list of aliases somewhere to help someone troubleshoot this? Looking at getdir specifically, searching the manual doesn't provide anything, and it is not listed as an alias for dir. Maybe this is just a documentation bug then? ------------------------------------------------------------------------ [2021-03-29 15:13:16] egegeg dot egeez at fff dot ff functions in php are generally case-insensitive and every place where they are not is and was a bug by definition - so this is a bugfix and not a bug writing plain functions without a prefix is bad coding style anyways because you never know if a future version brings a native function with the same name but different semantics calling a function identical as a builtin but with different case is asking for troubles no matter what ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=80914 -- Edit this bug report at https://bugs.php.net/bug.php?id=80914&edit=1

« previous php.bugs (#233353) next »