is_readable() not working on files inside phar
Open
Nobody has claimed this yet.
Bug
Extension: phar
Status: Verified
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
Using the following code to create a basic phar file:
$stub = <<<STUB
<?php
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
include "index.php";
__HALT_COMPILER();
STUB;
$index = <<<INDEX
<?php
var_dump(file_exists('phar:///path/to/archive.phar/index.php')) . PHP_EOL;
var_dump(is_readable('phar:///path/to/archive.phar/index.php')) . PHP_EOL;
var_dump(file_exists('index.php')) . PHP_EOL;
var_dump(is_readable('index.php')) . PHP_EOL;
INDEX;
$phar = new Phar('archive.phar');
$phar->addFromString('index.php', $index);
$phar->setStub($stub);
Then executing the following code:
php archive.phar
Resulted in this output:
bool(true)
bool(false)
bool(true)
bool(false)
But I expected this output instead:
bool(true)
bool(true)
bool(true)
bool(true)
Or executing the following code:
<?php
var_dump(is_readable('phar:///path/to/archive.phar/index.php'));
Resulted in this output:
bool(false)
But I expected this output instead:
bool(true)
PHP Version
PHP 8.0.12
Operating System
Ubuntu 20.04
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using the supplied archive.phar, index.php, and Phar stub on PHP 8.0.12. Start by tracing Phar::interceptFileFuncs() and the is_readable() path, then add or update a regression test showing that files inside the Phar report the expected readable status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100