Bug #79121 [Com]: is_writable not working for path in phar archive, regardless of phar.readonly
| From: | Gail1985Marshall at gmail dot com | Date: | Tue, 03 Jan 2023 10:29:45 +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-243318@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: Gail1985Marshall at gmail 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:
Try defining the full path.
$path = '.';
if (!empty($pharPath = \Phar::running(false))) {
$path = dirname($pharPath);
}
$this->fileSystem->dumpFile(
$path.'/testfile.txt',
'my test content'
);
(https://www.myhealthatvanderbilt.net/)github.com
Previous Comments:
------------------------------------------------------------------------
[2020-01-23 19:05:31] alex at 1stleg dot com
The https://github.com/kwhat/dumpsterfire-phar/blob/master/index.md
file is run using the arguments specified using index.php as the entry point and public/ as the
document root/cwd. This is the baseline for how I would expect stuff to work, everything is normal
except for glob() a phar:// path. The glob maybe broken for other reasons and it is really the
smallest of these issues.
When we look at https://github.com/kwhat/dumpsterfire-phar/blob/master/phar.md
we can see what didn't match up to our index.md baseline. Glob experiences a number of new
failures for the relative paths, which are expected.
* "../config/": For some reason this is found while using the phar... I don't
believe it should have been.
* phar.readonly: This is empty string, it is specified in the cli ini as phar.readonly = Off.
According to the docs, this should come from the ini but can only be set with -d.
* is_writeable: This doesn't appear to work when using phar.
* include "./config/" vs "config/" This makes some sense, except for
is_dir/is_file "./config/" returning true when within the phar.
If we take a look at https://github.com/kwhat/dumpsterfire-phar/blob/master/create-phar.php:
* @unlink('/tmp/archive.phar'): Sometimes phar archive updating will cause a failure
depending on the change.
* $phar->compressFiles(Phar::GZ): Causes failure to create temp file error when compressing phar
of any meaningful size.
* $phar->buildFromIterator does not update the $phar objects contents. Start/Stop buffering has
no effect. The only workaround I found was
$phar = new Phar($phar->getPath())
------------------------------------------------------------------------
[2020-01-23 08:33:43] nikic@php.net
> 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.
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
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