php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60794 Cannot include files from different .phars when include path is too long
Submitted: 2012-01-18 18:27 UTC Modified: 2021-01-31 04:22 UTC
Votes:10
Avg. Score:5.0 ± 0.0
Reproduced:9 of 9 (100.0%)
Same Version:7 (77.8%)
Same OS:8 (88.9%)
From: pdobrigkeit at gmx dot de Assigned: cmb (profile)
Status: No Feedback Package: PHAR related
PHP Version: 5.3.9 OS: Windows 7
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pdobrigkeit at gmx dot de
New email:
PHP Version: OS:

 

 [2012-01-18 18:27 UTC] pdobrigkeit at gmx dot de
Description:
------------
When including multiple .phar archieves into the code and one of the archieves contains for example an autoloading script to include files, the script breaks when the reference to the phar wrapper is too far back in the include path. It works anytime when using the phar:// wrapper and not when referencing the file via the include path.

That is not helpful, when the provided autoloader of the framework does not care whether the file is within a different .phar. 

The two used .phars used can be downloaded here:
http://dl.dropbox.com/u/3319901/autoload.phar
http://dl.dropbox.com/u/3319901/libA.phar

Just put those into the root directory with the test script code. To build the .phars I used the export functionality of Zend Studio, as well as a Phing target, both yielded the same results.

Test script:
---------------
<?php

$phars = array( 'phar://libA.phar',
				'phar://autoload.phar');

$usedPath = implode(PATH_SEPARATOR, $phars);

//working with this include path length
//set_include_path(str_pad(PATH_SEPARATOR . $usedPath, 218, 'a', STR_PAD_LEFT));

//NOT working with this include path length
set_include_path(str_pad(PATH_SEPARATOR . $usedPath, 219, 'a', STR_PAD_LEFT));

include 'libA.phar';
include 'autoload.phar';

include 'autoload/autoload.php';

//works at any time
autoload('phar://libA.phar/libA/libA.php');

//NOT working when include path is too long
autoload('libA/libA.php');

Expected result:
----------------
included file phar://libA.phar/libA/libA.php
included file phar://libA.phar/libA/libA.php

Actual result:
--------------
included file phar://libA.phar/libA/libA.php
Warning: include() [function.include]: Failed opening 'libA/libA.php' for inclusion (include_path='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;phar://libA.phar;phar://autoload.phar') in phar://autoload.phar/autoload/autoload.php on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-19 07:59 UTC] s dot kleff at dershao dot de
Same on PHP 5.3.8 on Win 7 64Bit
 [2012-01-19 10:39 UTC] s dot kleff at dershao dot de
Works as expected on PHP Version 5.3.8-ZS5.5.0 / Debian 2.6.32-5-amd64
 [2012-04-12 21:11 UTC] alex dot bowyer at googlemail dot com
I have the same problem on PHP 5.3.10 / Windows Server 2008 / IIS 7.5.
We have a workaround for now but soon the 218 character limit is going to be an issue for us. Hope you can fix it!
 [2012-06-04 17:01 UTC] pajoye@php.net
For the record here. This is certainly due to MAXPATHLEN check in the stream 
implementation.

The question now is to verify where it fails, whether in stream core itself or in 
phar. If the sooner, we have some kind of a problem here and could be harder to 
solve.

Temporary work around would be to use aliases.
 [2012-06-07 19:26 UTC] mattficken@php.net
I can't reproduce this error with 5.3.8-TS or 5.3.14rc2-NTS on Windows 7. I've posted the output of the test script above for 5.3.8-TS.

The test script doesn't pass regardless of turning off the str_pad calls. Could there be something wrong with the 2 phar files themselves?

What INI directives are you using? 

The PHAR section of my INI file is:
[Phar]
;phar.readonly = On
; http://php.net/phar.require-hash
;phar.require_hash = On
;phar.cache_list =

I am using the official 5.3.8 build, which has PHAR builtin.

With both set_include_path() calls commented out (ie it should work):
PHP Warning:  include(autoload/autoload.php): failed to open stream: No such fil
e or directory in C:\php-sdk\php-5.3.8-Win32-VC9-x86\60794.php on line 17

Warning: include(autoload/autoload.php): failed to open stream: No such file or
directory in C:\php-sdk\php-5.3.8-Win32-VC9-x86\60794.php on line 17
PHP Warning:  include(): Failed opening 'autoload/autoload.php' for inclusion (i
nclude_path='.;C:\php\pear') in C:\php-sdk\php-5.3.8-Win32-VC9-x86\60794.php on
line 17

Warning: include(): Failed opening 'autoload/autoload.php' for inclusion (includ
e_path='.;C:\php\pear') in C:\php-sdk\php-5.3.8-Win32-VC9-x86\60794.php on line
17
PHP Fatal error:  Call to undefined function autoload() in C:\php-sdk\php-5.3.8-
Win32-VC9-x86\60794.php on line 20

Fatal error: Call to undefined function autoload() in C:\php-sdk\php-5.3.8-Win32
-VC9-x86\60794.php on line 20

With the second set_include_path() call uncommented (so it should fail), I get:
included file phar://C:/php-sdk/php-5.3.8-Win32-VC9-x86/libA.phar/libA/libA.phpP
HP Warning:  include(libA/libA.php): failed to open stream: No such file or dire
ctory in phar://C:/php-sdk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autolo
ad.php on line 5

Warning: include(libA/libA.php): failed to open stream: No such file or director
y in phar://C:/php-sdk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autoload.p
hp on line 5
PHP Warning:  include(): Failed opening 'libA/libA.php' for inclusion (include_p
ath='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa;phar://libA.phar;phar://autoload.phar') in phar://C:/
php-sdk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autoload.php on line 5

Warning: include(): Failed opening 'libA/libA.php' for inclusion (include_path='
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaa;phar://libA.phar;phar://autoload.phar') in phar://C:/php-s
dk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autoload.php on line 5

With the 2nd set_include_path() commented out and the 1st uncommented (so it should pass), instead I get:
included file phar://C:/php-sdk/php-5.3.8-Win32-VC9-x86/libA.phar/libA/libA.phpP
HP Warning:  include(libA/libA.php): failed to open stream: No such file or dire
ctory in phar://C:/php-sdk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autolo
ad.php on line 5

Warning: include(libA/libA.php): failed to open stream: No such file or director
y in phar://C:/php-sdk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autoload.p
hp on line 5
PHP Warning:  include(): Failed opening 'libA/libA.php' for inclusion (include_p
ath='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaa;phar://libA.phar;phar://autoload.phar') in phar://C:/p
hp-sdk/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autoload.php on line 5

Warning: include(): Failed opening 'libA/libA.php' for inclusion (include_path='
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa;phar://libA.phar;phar://autoload.phar') in phar://C:/php-sd
k/php-5.3.8-Win32-VC9-x86/autoload.phar/autoload/autoload.php on line 5
 [2015-04-24 15:22 UTC] massimo dot lombardo at chiarezza dot it
I've the same problem PHP Version 5.3.17 running on windows 7
 [2021-01-19 14:52 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-19 14:52 UTC] cmb@php.net
Yes, this is likely MAXPATHLEN related.  Since the phars are no
longer available, I can't easily test, but I assume this issue is
practically resolved as of PHP 7.1.0 which introduces support for
long paths and defines MAXPATHLEN to 2048 on Windows.  Or can
anybody still reproduce this with any of the actively supported
PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-01-31 04:22 UTC] php-bugs 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 "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 23:01:30 2024 UTC