Bug #79121 [Opn]: is_writable not working for path in phar archive, regardless of phar.readonly

From: Date: Thu, 23 Jan 2020 08:33:43 +0000
Subject: Bug #79121 [Opn]: is_writable not working for path in phar archive, regardless of phar.readonly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225059@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79121&edit=1 ID: 79121 Updated by: nikic@php.net Reported by: alex at 1stleg dot com Summary: is_writable not working for path in phar archive, regardless of phar.readonly Status: Open Type: Bug Package: PHAR related Operating System: Ubuntu 18.04.3 LTS PHP Version: 7.2.26 Block user comment: N Private report: N New Comment: > Also broken, include path "."; > > For example: > > lets say the php path is "." and in my pwd, folder exists file with file.php.> > > include "folder/file.php"; // works as expected. > > include "./folder/file.php"; // shits it's pants. > > Not sure we could screw up path handling any more than it is. It's really hard to tell from these ramblings, but if I understand correctly, you are talking about plain files here, not phars, right? In that case, you do realize that those two paths refer to different things? "./folder/file.php" is relative to the current working directory, while "folder/file.php" is relative to the include_path and the including script as a fallback. My immediate suspicion would be that are are confusing the "current working directory" and the "directory of the including script". Both paths will work against the cwd (if "." is in the include path), but only the first path against the directory of the current script. I recommend using __DIR__ relative paths to avoid this kind of confusion. Previous Comments: ------------------------------------------------------------------------ [2020-01-23 06:15:37] alex at 1stleg dot com I will update as I discover more issues, example code is available in the same repo. https://github.com/kwhat/dumpsterfire-phar/blob/master/index.md https://github.com/kwhat/dumpsterfire-phar/blob/master/phar.md ------------------------------------------------------------------------ [2020-01-23 01:33:17] alex at 1stleg dot com Now I am randomly getting "unable to create temporary file" WHAT THE EF! I am done with this. go back and rewrite it with a brain. PS this captcha is bullshit. ------------------------------------------------------------------------ [2020-01-23 01:15:52] alex at 1stleg dot com Also broken, include path "."; For example: lets say the php path is "." and in my pwd, folder exists file with file.php. include "folder/file.php"; // works as expected. include "./folder/file.php"; // shits it's pants. Not sure we could screw up path handling any more than it is. ------------------------------------------------------------------------ [2020-01-23 00:02:50] alex at 1stleg dot com The really effed up part is that include "phar:///path/to/archive.phar/folder/file.php" will not work, but is_file( "phar:///path/to/archive.phar/folder/file.php") works just fine. Can we pick a method for resolving files in a phar archive across all file functions? There is really no way to get phar to do anything useful beyond using "./" as a path. After 20 years of PHP it is really time to move on to something mature. ------------------------------------------------------------------------ [2020-01-22 17:47:44] alex at 1stleg dot com Just to further add to this: var_dump($configDir, is_dir($configDir), is_readable($configDir), realpath($configDir), scandir($configDir)); string(8) "./config" bool(true) bool(true) bool(false) bool(false) Needless to say, I am not very excited about these issues. ------------------------------------------------------------------------ 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=79121 -- Edit this bug report at https://bugs.php.net/bug.php?id=79121&edit=1

« previous php.bugs (#225059) next »