php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58213 Paths after the first directory separator are ignored
Submitted: 2008-06-03 11:02 UTC Modified: 2009-02-15 01:12 UTC
Votes:4
Avg. Score:4.2 ± 0.4
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: malaney at gmail dot com Assigned:
Status: No Feedback Package: phar (PECL)
PHP Version: 5.2.5 OS: Mac OS X (Tiger)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-06-03 11:02 UTC] malaney at gmail dot com
Description:
------------
Paths after the first directory separator in a set_include_path() or ini_set('include_path') call are ignored when running the phar extension 2.0.0b1.  After installing phar-2.0.0b1 on my Macbook, all my require's failed.  Seems like DIRECTORY_SEPARATOR may be munged on Mac OS X.

Reproduce code:
---------------
<?php
    $PATH1 = "/path/to/libs";
    $PATH2 = $PATH1 . "/pear";
    print set_include_path($PATH1 . DIRECTORY_SEPARATOR . $PATH2);
    require $PATH2 . 'MDB2.php';
    print 'File included';
?>

Expected result:
----------------
File included

Actual result:
--------------
Warning: require_once('/path/to/libs/MDB2.php') [function.require-once]: failed to open stream: No such file or directory in test_script.php on line 4

Fatal error: require_once() [function.require]: Failed opening required 'MDB2.php' (include_path='/path/to/libs:/path/to/libs/pear') in test_script.php on line 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-03 11:38 UTC] steph dot fox at virgin dot net
Hi,

Can you please alter your script slightly and try this instead? Your original script doesn't work for me either, I'm just trying to establish whether there is a reproducible bug.

<?php
    $PATH1 = "libs";
    $PATH2 = $PATH1 . "/pear";
    set_include_path($PATH1 . ';' . $PATH2);
    print get_include_path()."\n";
    require $PATH2 . '/MDB2.php';
    print 'File included';
    /*
    expected output:
    libs;libs/pear
    File included
    */
?>

Thanks,
- Steph
 [2008-06-03 11:40 UTC] steph dot fox at virgin dot net
Not 'libs', sorry, that was my test environment not yours :)

path/to/libs.
 [2008-06-03 11:56 UTC] steph dot fox at virgin dot net
So shoot me, I never heard of PATH_SEPARATOR 'til now.

Can you confirm that you're still seeing a bug when you use the correct constant and when you remember to put '/' between 'pear' and the target filename?
 [2008-06-03 12:34 UTC] malaney at gmail dot com
Yes, I altered the script as suggested and I got the expected output.  I was able to run require $PATH2 . '/MDB2.php';

However, I'm hoping to not have to specify $PATH2 on my require line, hence the set_include_path call ...
 [2008-06-03 13:17 UTC] steph dot fox at virgin dot net
Can you please confirm that you're seeing this with:

<?php
    $PATH1 = "path/to/libs";
    $PATH2 = $PATH1 . "/pear/";
    set_include_path($PATH1 . PATH_SEPARATOR . $PATH2);
    print get_include_path()."\n";
    require 'MDB2.php';
    print 'File included';
?>

and also please post your output if that's failing for you?

NB I'm not able to reproduce any problem under Windows.
 [2008-06-03 14:07 UTC] malaney at gmail dot com
Here is my output:

/path/to/lib;/path/to/lib/pear
PHP Warning:  require_once(/path/to/www/MDB2.php): failed to open stream: No such file or directory in /path/to/lib/www/test.php on line 7

Warning: require_once(/path/to/www/MDB2.php): failed to open stream: No such file or directory in /path/to/www/test.php on line 7
PHP Fatal error:  require_once(): Failed opening required 'MDB2.php' (include_path='/path/to/lib;/path/to/lib/pear') in /path/to/www/test.php on line 7

Fatal error: require_once(): Failed opening required 'MDB2.php' (include_path='/path/to/lib;/path/to/lib/pear') in /path/to/www/test.php on line 7

NB:  I'm not having problems with Pha 2.0.0b1 on my CentOS machine either.  Only on OS X ...
 [2008-06-03 15:08 UTC] steph dot fox at virgin dot net
Sorry, but your problem does not imply a bug in PECL itself.  For a
list of more appropriate places to ask for help using PECL, please
visit http://pecl.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PECL.

Hi,

The include_path is being set correctly. See your own output:

/path/to/lib;/path/to/lib/pear

Notice that the path you're actually looking in is different. Not sure why, I should've asked you to post your code too.

You may email me directly if you still can't get it to work, and I'll do my best to help, but I'm 100% certain this isn't a Phar (or PHP) bug now.

- Steph
 [2008-06-03 20:30 UTC] philip at roshambo dot org
This might be related to the following:

 * http://bugs.php.net/bug.php?id=45044

Although, #45044 appears to be a 5.3 and non-phar bug :)
 [2008-06-04 10:40 UTC] malaney at gmail dot com
Just googling brought up this link http://marc.info/?l=php-cvs&m=120942242226464&w=2 which would explain why my script works perfectly without the phar extension loaded, but then breaks once it is loaded.
 [2008-06-04 11:05 UTC] greg at chiaraquartet dot net
that patch is against PHP 5.3, and has nothing to do with PHP 5.2, zend_resolve_path was introduced in PHP 5.3.

None of us have access to OS X, so it will be very difficult to debug without someone who does and is willing to step through with gdb to see what is going on.  The function to break on is phar_find_in_include_path
 [2008-12-16 13:36 UTC] till@php.net
I can reproduce this "bug". This is not a MacOSX only issue, and I actually haven't had time to reproduce it on there but if you guys request me to, I will do so next weekened.

I found this bug on Ubuntu 8.04 (LTS), PHP 5.2.4, I had the phar extension installed (please check with Brett on installing it) and since then it failed traversing through the different include paths.

For example:
<?php
// this fails
set_include_path(".:/usr/share/php");
require_once "PEAR.php";
?>

While this works:
<?php
// this works
set_include_path("/usr/share/php:.");
require_once "PEAR.php";
?>

If I remove the phar extension, it all goes back to normal.

I strace'd the script and without strace it doesn't even check in /usr/share/php if it comes second.

Also, according to my second example, it will also fail to include files from the same directory as the script itself. For example:

Layout
foo/script.php
foo/script2.php

foo/script.php contains:
<?php
// this fails
set_include_path('/usr/share/php:.');
require 'script2.php';
?>
 [2008-12-16 16:04 UTC] greg at chiaraquartet dot net
phar version?
 [2021-01-21 07:22 UTC] darrendemers12 at gmail dot com
None of us have access to OS X, so it will be very difficult to debug without someone who does and is willing to step through with gdb to see what is going on.  The function to break on is phar_find_in_include_path
http://www.thecollectionmarts.com/product-category/bedding/
http://www.thecollectionmarts.com/product-category/comforter-set/
 [2021-11-04 13:27 UTC] evenmhismay at gmail dot com
Awesome blog. I read through and I found this blog to be very useful and informative. Thanks for sharing. Check<a href="https://infoguidenigeria.com/mapoly-post-utme-form/"> when is mapoly post utme form closing</a>
 [2023-02-03 16:16 UTC] alexwriter2003 at gmail dot com
So Exeleent Paper Help
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC