PHP 8 is_file/is_dir input handling

From: Date: Tue, 01 Dec 2020 17:18:17 +0000
Subject: PHP 8 is_file/is_dir input handling
Groups: php.internals 
Request: Send a blank email to internals+get-112333@lists.php.net to get a copy of this message
Hi internals PHP 8 is stricter in checking input data then PHP 7. This is good but has some side effects for is_file(), is_dir() and similar functions when invalid paths are passed for checking. In PHP 7, this returns FALSE: php -r 'var_dump(is_file("ab\0c"));' In PHP 8, the same code throws a ValueException. Problem is now that it's not possible to check upfront if the passed argument is a valid path to avoid the exception being thrown. My suggestion for simpler client side code would be to return FALSE in this situation for PHP 8 too instead of throwing the ValueException. Otherwise, it's not possible to use is_file() and related functions without adding a try/catch block around in any web application. Best, Norbert

« previous php.internals (#112333) next »