php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59736 include/require_once path changed to source
Submitted: 2011-04-28 09:30 UTC Modified: 2013-02-18 00:35 UTC
From: tomaz dot lovrec at x-shells dot org Assigned:
Status: No Feedback Package: bcompiler (PECL)
PHP Version: 5.2.17 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tomaz dot lovrec at x-shells dot org
New email:
PHP Version: OS:

 

 [2011-04-28 09:30 UTC] tomaz dot lovrec at x-shells dot org
Description:
------------
When compiling a simple include_once or require_once with a part of path in it, and not just the file name, i.e. when an included files resides in a lower directory, this path gets replaced by the original source file location at compile time.
I.e. if you put your source PHP file in /var/www/htdocs/tocompile
and compile that file with "bcompile_write_header/file/footer()" and save it to /var/www/htdocs/compiled, any include/require_once(and possibly others) will try and refference files in /var/www/htdocs/tocompile.

Bellow is a simple file I've created and tested.

Reproduce code:
---------------
<? require_once('inc/test.php'); echo $test_value; ?>

Compiled with:
$fhandle = fopen(compiled/testing.php, 'w');
bcompiler_write_header($fhandle);
bcompiler_write_file($fhandle, tocompile/testing.php);
bcompiler_write_footer($fhandle);
fclose($fhandle);

Expected result:
----------------
After above compile, the compiled script should produce an error, because there was no "compiled/inc/test.php" file available.

Actual result:
--------------
After removing inc/test.php file from "tocompile" directory, it produced an error, file or directory not found with path to "tocompile/inc/test.php"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-03 04:38 UTC] tomaz dot lovrec at x-shells dot org
A workaround proposal:
Store the path to a variable and use the variable to include/require the file.
i.e:
$somevar = 'path/to/my/include/file.php';
require_once($somevar);
 [2011-09-05 07:06 UTC] val@php.net
It's a known problem that can't be just solved at bcompiler level, since it relates to PHP internals. I can suggest trying require_once(dirname(__FILE__).'/inc/test.php')
instead of require_once('inc/test.php').
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Nov 16 23:01:41 2019 UTC