From: james dot turner dot phpninja at gmail dot com
Operating system: Ubuntu 12
PHP version: 5.3.16
Package: PHAR related
Bug Type: Bug
Bug description:Include inside Phar with "./" prefix fails to include correctly
Description:
------------
When including a file from another file within a phar build, that has a ./
prefix, e.g. include_once './my/other/file.php' a "failed to open stream:
No such file or directory in phar" warning is thrown followed by a Fatal
error "PHP Fatal error: require_once(): Failed opening required
'./my/other/file.php"
The test script below contains 3 files required to produce the same
output.
structure:
.
/src
/src/index.php
/src/includes/bootstrap.php
package.php
Test script:
---------------
// package.php
<?php
if(!file_exists('test.phar')){
try {
$phar = new Phar('test.phar');
$phar->buildFromDirectory('src');
$phar->setStub($phar->createDefaultStub());
} catch(PharException $e){
echo $e->getMessage();
}
} else {
require_once ('phar://test.phar');
}
// src/index.php
<?php
require_once './includes/bootstrap.php'
// src/includes/bootstrap.php
<?
echo "hello world";
Expected result:
----------------
hello world
Actual result:
--------------
/usr/bin/php /workspace/PharTest/package.php
PHP Warning: require_once(./includes/bootstrap.php): failed to open
stream: No such file or directory in
phar:///workspace/PharTest/test.phar/index.php on line 3
PHP Stack trace:
PHP 1. {main}() /workspace/PharTest/package.php:0
PHP 2. require_once() /workspace/PharTest/package.php:12
PHP 3. include() /workspace/PharTest/test.phar:9
PHP Fatal error: require_once(): Failed opening required
'./includes/bootstrap.php'
(include_path='phar:///workspace/PharTest/test.phar:.:/usr/share/php:/usr/share/pear')
in phar:///workspace/PharTest/test.phar/index.php on line 3
PHP Stack trace:
PHP 1. {main}() /workspace/PharTest/package.php:0
PHP 2. require_once() /workspace/PharTest/package.php:12
PHP 3. include() /workspace/PharTest/test.phar:9
--
Edit bug report at https://bugs.php.net/bug.php?id=63028&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63028&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63028&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=63028&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=63028&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=63028&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=63028&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=63028&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=63028&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=63028&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=63028&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=63028&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63028&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63028&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=63028&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=63028&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63028&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=63028&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=63028&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=63028&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=63028&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=63028&r=mysqlcfg