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

From: Date: Thu, 23 Jan 2020 06:15:37 +0000
Subject: Bug #79121 [Com]: 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-225055@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 Comment by: alex at 1stleg dot com 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: 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 Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2020-01-15 17:11:16] alex at 1stleg dot com Description: ------------ is_writable seems to be incapable of detecting if a path within a phar archive can be written to. Test script: --------------- pharstub.php <?php Phar::interceptFileFuncs(); set_include_path("phar://archive.phar" . PATH_SEPARATOR . get_include_path()); include "public/index.php"; __HALT_COMPILER(); public/index.php <?php if (is_writable("phar://archive.phar/folder")) { die("yes"); } else { die("no"); } create-phar.php #!/bin/env php <?php $phar = new Phar('archive.phar'); $phar->addEmptyDir('folder/'); $phar->buildFromIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator("public/", FilesystemIterator::SKIP_DOTS)), "."); $phar->setStub(file_get_contents("pharstub.php")); $phar->compressFiles(Phar::GZ); Expected result: ---------------- I would expect that is_writable will return true under some circumstance for folders within a phar. Currently it will return false regardless of phar.readonly = off or chmod 0777 of the internal folder or chmod 0777 of the phar archive. Actual result: -------------- Phar does not appear to be ready for production, or really anything outside of a novelty application. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79121&edit=1

« previous php.bugs (#225055) next »