Skip to content

is_readable() not working on files inside phar #7976

Open
@petitj

Description

@petitj

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions