[php-src] Issue #14481: realpath() and SplFileInfo::getRealPath inside Phar
| From: | murrant | Date: | Wed, 05 Jun 2024 14:00:24 +0000 |
| Subject: | [php-src] Issue #14481: realpath() and SplFileInfo::getRealPath inside Phar | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247038@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14481
Author: murrant
### Description
I'm trying to include packages in my phar but many of them use realpath to files inside the
Phar which spits out false instead of a path; breaking things. If the behavior was to return the
same path when the path starts with phar:// it would just work.
The following code:
make_phar.php
```php
<?php
$phar = new Phar('test.phar');
$phar->addFile('test.php');
$phar->setDefaultStub('test.php');
$phar->stopBuffering();
```
test.php
```php
<?php
var_dump(
__FILE__,
realpath(__FILE__),
(new SplFileInfo(__FILE__))->getRealPath(),
);
```
php test.php && php make_phar.php && php test.phar
Resulted in this output:
```
string(45) "/home/murrant/projects/realpath_test/test.php"
string(45) "/home/murrant/projects/realpath_test/test.php"
string(45) "/home/murrant/projects/realpath_test/test.php"
string(62) "phar:///home/murrant/projects/realpath_test/test.phar/test.php"
bool(false)
bool(false)
```
But I expected this output instead:
```
string(45) "/home/murrant/projects/realpath_test/test.php"
string(45) "/home/murrant/projects/realpath_test/test.php"
string(45) "/home/murrant/projects/realpath_test/test.php"
string(62) "phar:///home/murrant/projects/realpath_test/test.phar/test.php"
string(62) "phar:///home/murrant/projects/realpath_test/test.phar/test.php"
string(62) "phar:///home/murrant/projects/realpath_test/test.phar/test.php"
```
### PHP Version
PHP 8.3.7
### Operating System
_No response_