#39542 [NEW]: Search order for include/require wrong in get_include_path

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #39542 [NEW]: Search order for include/require wrong in get_include_path

    From: snowy at corporatezoo dot com
    Operating system: Windows XP
    PHP version: 5.2.0
    PHP Bug Type: Scripting Engine problem
    Bug description: Search order for include/require wrong in get_include_path

    Description:
    ------------
    Behaviour of require/include different to < 5.2.0.

    I'm not sure if this is by design, couldn't find any reference to it in
    release notes. Basically, the search order of an include seems to always
    start with ./ instead of in the order of get_include_path(). This is
    problematic, esp in the case of using autoload, where a filename eg in
    ../index.php might be the same as ../classes/Index.php, ./index.php gets
    autoloaded instead of ../classes/Index.php

    Reproduce code:
    ---------------
    //index.php
    set_include_path('../classes;.');
    function __autoload($class)
    {
    if (!require_once($class.'.php')) {
    error_log('Error: Autoload class: '.$class.' not found!');
    }
    }

    $index = new Index();

    //../classes/Index.php
    class Index
    {
    //blah
    }

    Expected result:
    ----------------
    In 5.1.6, it works ok, loads Index.php




    Actual result:
    --------------
    in 5.2.0,

    Fatal error: Class 'Index' not found in c:\docroot\index.php

    I suspect it's looking for a class in index.php (Which is the currently
    executed script).

    Is this an architectural change? Or is this a bug?

    --
    Edit bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39542&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39542&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39542&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39542&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39542&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39542&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39542&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39542&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39542&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39542&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39542&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39542&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39542&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39542&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39542&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39542&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39542&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39542&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39542&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39542&r=mysqlcfg[/url]
    snowy at corporatezoo dot com Guest

  2. Similar Questions and Discussions

    1. PHP require or include and Contribute 3
      I'm disappointed that the <?php require('.. ); ?> or <?php include('.. ); ?> do not render in EDIT mode in Contribute 3. I tried a SSI shtml, and...
    2. Absolute URLs with Require & Include
      Is there anyway to get an absolute URL to work with Require & Include? Why doesn't it work already? I did see the tip about using $_SERVER, but...
    3. [PHP] Performance and require / include
      Infoman: Thorsten Koch <koch@infoman.de> wrote: It depends on the type of application your making. Now if you have a lot of code that you include...
    4. #24593 [Opn->Bgs]: class not instantiated problem with include/require
      ID: 24593 Updated by: sniper@php.net Reported By: ssem at complexusgroup dot com -Status: Open +Status: ...
    5. [PHP] include/require inside of function
      > -----Original Message----- And is the assignment in the included file inside a function? If so, the usual rules about variables within...
  3. #2

    Default #39542 [Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    Updated by: [email]tony2001@php.net[/email]
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    Not reproducible on Linux.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 06:24:25] snowy at corporatezoo dot com

    Description:
    ------------
    Behaviour of require/include different to < 5.2.0.

    I'm not sure if this is by design, couldn't find any reference to it in
    release notes. Basically, the search order of an include seems to always
    start with ./ instead of in the order of get_include_path(). This is
    problematic, esp in the case of using autoload, where a filename eg in
    ../index.php might be the same as ../classes/Index.php, ./index.php gets
    autoloaded instead of ../classes/Index.php

    Reproduce code:
    ---------------
    //index.php
    set_include_path('../classes;.');
    function __autoload($class)
    {
    if (!require_once($class.'.php')) {
    error_log('Error: Autoload class: '.$class.' not found!');
    }
    }

    $index = new Index();

    //../classes/Index.php
    class Index
    {
    //blah
    }

    Expected result:
    ----------------
    In 5.1.6, it works ok, loads Index.php




    Actual result:
    --------------
    in 5.2.0,

    Fatal error: Class 'Index' not found in c:\docroot\index.php

    I suspect it's looking for a class in index.php (Which is the currently
    executed script).

    Is this an architectural change? Or is this a bug?


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]

    tony2001@php.net Guest

  4. #3

    Default #39542 [Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    User updated by: snowy at corporatezoo dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    tony, sorry I just realised that example might be different in linux
    because of being case sensitive.

    could you try renaming the files and class name to "index"... ie,
    "../classes/index.php" and "class index".

    See which one it tries to load up first. thx


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 11:35:53] [email]tony2001@php.net[/email]

    Not reproducible on Linux.

    ------------------------------------------------------------------------

    [2006-11-17 06:24:25] snowy at corporatezoo dot com

    Description:
    ------------
    Behaviour of require/include different to < 5.2.0.

    I'm not sure if this is by design, couldn't find any reference to it in
    release notes. Basically, the search order of an include seems to always
    start with ./ instead of in the order of get_include_path(). This is
    problematic, esp in the case of using autoload, where a filename eg in
    ../index.php might be the same as ../classes/Index.php, ./index.php gets
    autoloaded instead of ../classes/Index.php

    Reproduce code:
    ---------------
    //index.php
    set_include_path('../classes;.');
    function __autoload($class)
    {
    if (!require_once($class.'.php')) {
    error_log('Error: Autoload class: '.$class.' not found!');
    }
    }

    $index = new Index();

    //../classes/Index.php
    class Index
    {
    //blah
    }

    Expected result:
    ----------------
    In 5.1.6, it works ok, loads Index.php




    Actual result:
    --------------
    in 5.2.0,

    Fatal error: Class 'Index' not found in c:\docroot\index.php

    I suspect it's looking for a class in index.php (Which is the currently
    executed script).

    Is this an architectural change? Or is this a bug?


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at corporatezoo dot com Guest

  5. #4

    Default #39542 [Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    Updated by: [email]tony2001@php.net[/email]
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    I didn't use your example, I tested it in another way.


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 14:05:26] snowy at corporatezoo dot com

    tony, sorry I just realised that example might be different in linux
    because of being case sensitive.

    could you try renaming the files and class name to "index"... ie,
    "../classes/index.php" and "class index".

    See which one it tries to load up first. thx

    ------------------------------------------------------------------------

    [2006-11-17 11:35:53] [email]tony2001@php.net[/email]

    Not reproducible on Linux.

    ------------------------------------------------------------------------

    [2006-11-17 06:24:25] snowy at corporatezoo dot com

    Description:
    ------------
    Behaviour of require/include different to < 5.2.0.

    I'm not sure if this is by design, couldn't find any reference to it in
    release notes. Basically, the search order of an include seems to always
    start with ./ instead of in the order of get_include_path(). This is
    problematic, esp in the case of using autoload, where a filename eg in
    ../index.php might be the same as ../classes/Index.php, ./index.php gets
    autoloaded instead of ../classes/Index.php

    Reproduce code:
    ---------------
    //index.php
    set_include_path('../classes;.');
    function __autoload($class)
    {
    if (!require_once($class.'.php')) {
    error_log('Error: Autoload class: '.$class.' not found!');
    }
    }

    $index = new Index();

    //../classes/Index.php
    class Index
    {
    //blah
    }

    Expected result:
    ----------------
    In 5.1.6, it works ok, loads Index.php




    Actual result:
    --------------
    in 5.2.0,

    Fatal error: Class 'Index' not found in c:\docroot\index.php

    I suspect it's looking for a class in index.php (Which is the currently
    executed script).

    Is this an architectural change? Or is this a bug?


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    tony2001@php.net Guest

  6. #5

    Default #39542 [Opn->Fbk]: Search order for include/require wrong in get_include_path

    ID: 39542
    Updated by: [email]tony2001@php.net[/email]
    Reported By: snowy at corporatezoo dot com
    -Status: Open
    +Status: Feedback
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    What if you change "../classes" to the full path?


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 14:11:09] [email]tony2001@php.net[/email]

    I didn't use your example, I tested it in another way.

    ------------------------------------------------------------------------

    [2006-11-17 14:05:26] snowy at corporatezoo dot com

    tony, sorry I just realised that example might be different in linux
    because of being case sensitive.

    could you try renaming the files and class name to "index"... ie,
    "../classes/index.php" and "class index".

    See which one it tries to load up first. thx

    ------------------------------------------------------------------------

    [2006-11-17 11:35:53] [email]tony2001@php.net[/email]

    Not reproducible on Linux.

    ------------------------------------------------------------------------

    [2006-11-17 06:24:25] snowy at corporatezoo dot com

    Description:
    ------------
    Behaviour of require/include different to < 5.2.0.

    I'm not sure if this is by design, couldn't find any reference to it in
    release notes. Basically, the search order of an include seems to always
    start with ./ instead of in the order of get_include_path(). This is
    problematic, esp in the case of using autoload, where a filename eg in
    ../index.php might be the same as ../classes/Index.php, ./index.php gets
    autoloaded instead of ../classes/Index.php

    Reproduce code:
    ---------------
    //index.php
    set_include_path('../classes;.');
    function __autoload($class)
    {
    if (!require_once($class.'.php')) {
    error_log('Error: Autoload class: '.$class.' not found!');
    }
    }

    $index = new Index();

    //../classes/Index.php
    class Index
    {
    //blah
    }

    Expected result:
    ----------------
    In 5.1.6, it works ok, loads Index.php




    Actual result:
    --------------
    in 5.2.0,

    Fatal error: Class 'Index' not found in c:\docroot\index.php

    I suspect it's looking for a class in index.php (Which is the currently
    executed script).

    Is this an architectural change? Or is this a bug?


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    tony2001@php.net Guest

  7. #6

    Default #39542 [Fbk->Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    User updated by: snowy at corporatezoo dot com
    Reported By: snowy at corporatezoo dot com
    -Status: Feedback
    +Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    actually I am using full paths, I'm doing a:

    define('SITEROOT_DIR','/web/myproject');
    define('FRAMEWORK_DIR','/web/framework');
    define('SITECLASS_DIR',SITEROOT_DIR.'/_application');
    set_include_path(SITECLASS_DIR.';'.FRAMEWORK_DIR.' ;'.get_include_path());

    and /web/myproject/docroot is the docroot

    (I've always been using this kind of naming with "/" for windows since
    4.0.x in case I need compat)

    It's almost as if it found index.php in the current namespace, and
    decides it doesn't need to go to include_path to look for one? just
    guessing...


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 15:25:31] [email]tony2001@php.net[/email]

    What if you change "../classes" to the full path?

    ------------------------------------------------------------------------

    [2006-11-17 14:11:09] [email]tony2001@php.net[/email]

    I didn't use your example, I tested it in another way.

    ------------------------------------------------------------------------

    [2006-11-17 14:05:26] snowy at corporatezoo dot com

    tony, sorry I just realised that example might be different in linux
    because of being case sensitive.

    could you try renaming the files and class name to "index"... ie,
    "../classes/index.php" and "class index".

    See which one it tries to load up first. thx

    ------------------------------------------------------------------------

    [2006-11-17 11:35:53] [email]tony2001@php.net[/email]

    Not reproducible on Linux.

    ------------------------------------------------------------------------

    [2006-11-17 06:24:25] snowy at corporatezoo dot com

    Description:
    ------------
    Behaviour of require/include different to < 5.2.0.

    I'm not sure if this is by design, couldn't find any reference to it in
    release notes. Basically, the search order of an include seems to always
    start with ./ instead of in the order of get_include_path(). This is
    problematic, esp in the case of using autoload, where a filename eg in
    ../index.php might be the same as ../classes/Index.php, ./index.php gets
    autoloaded instead of ../classes/Index.php

    Reproduce code:
    ---------------
    //index.php
    set_include_path('../classes;.');
    function __autoload($class)
    {
    if (!require_once($class.'.php')) {
    error_log('Error: Autoload class: '.$class.' not found!');
    }
    }

    $index = new Index();

    //../classes/Index.php
    class Index
    {
    //blah
    }

    Expected result:
    ----------------
    In 5.1.6, it works ok, loads Index.php




    Actual result:
    --------------
    in 5.2.0,

    Fatal error: Class 'Index' not found in c:\docroot\index.php

    I suspect it's looking for a class in index.php (Which is the currently
    executed script).

    Is this an architectural change? Or is this a bug?


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at corporatezoo dot com Guest

  8. #7

    Default #39542 [Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    User updated by: snowy at corporatezoo dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    Oh btw (in case it wasn't obvious), the "remedy" is

    1) rename the class file to "fooIndex.php"
    2) rename the class to fooIndex
    3) in index.php, $index = new fooIndex();

    so the issue is when the script "driver" file (ie, the one in docroot)
    is named the same as the class file (in the class path) even when the 2
    files are of different case (index.php vs Index.php).


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 23:39:53] snowy at corporatezoo dot com

    actually I am using full paths, I'm doing a:

    define('SITEROOT_DIR','/web/myproject');
    define('FRAMEWORK_DIR','/web/framework');
    define('SITECLASS_DIR',SITEROOT_DIR.'/_application');
    set_include_path(SITECLASS_DIR.';'.FRAMEWORK_DIR.' ;'.get_include_path());

    and /web/myproject/docroot is the docroot

    (I've always been using this kind of naming with "/" for windows since
    4.0.x in case I need compat)

    It's almost as if it found index.php in the current namespace, and
    decides it doesn't need to go to include_path to look for one? just
    guessing...

    ------------------------------------------------------------------------

    [2006-11-17 15:25:31] [email]tony2001@php.net[/email]

    What if you change "../classes" to the full path?

    ------------------------------------------------------------------------

    [2006-11-17 14:11:09] [email]tony2001@php.net[/email]

    I didn't use your example, I tested it in another way.

    ------------------------------------------------------------------------

    [2006-11-17 14:05:26] snowy at corporatezoo dot com

    tony, sorry I just realised that example might be different in linux
    because of being case sensitive.

    could you try renaming the files and class name to "index"... ie,
    "../classes/index.php" and "class index".

    See which one it tries to load up first. thx

    ------------------------------------------------------------------------

    [2006-11-17 11:35:53] [email]tony2001@php.net[/email]

    Not reproducible on Linux.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at corporatezoo dot com Guest

  9. #8

    Default #39542 [Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    User updated by: snowy at corporatezoo dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    Hi any update on this? btw, in case it was confusing, that wasn't a
    "fix" I posted, it is merely a way to circumvent the behaviour.

    Obviously this "fix" would require the renaming of all php class files
    in old code, which is an extreme pain, but it would be ok, if I could
    just confirm what the new "behaviour" of includes is meant to be.

    If there is not supposed to be a change in the behaviour of
    includes/requires, then this is probably a bug


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-17 23:45:30] snowy at corporatezoo dot com

    Oh btw (in case it wasn't obvious), the "remedy" is

    1) rename the class file to "fooIndex.php"
    2) rename the class to fooIndex
    3) in index.php, $index = new fooIndex();

    so the issue is when the script "driver" file (ie, the one in docroot)
    is named the same as the class file (in the class path) even when the 2
    files are of different case (index.php vs Index.php).

    ------------------------------------------------------------------------

    [2006-11-17 23:39:53] snowy at corporatezoo dot com

    actually I am using full paths, I'm doing a:

    define('SITEROOT_DIR','/web/myproject');
    define('FRAMEWORK_DIR','/web/framework');
    define('SITECLASS_DIR',SITEROOT_DIR.'/_application');
    set_include_path(SITECLASS_DIR.';'.FRAMEWORK_DIR.' ;'.get_include_path());

    and /web/myproject/docroot is the docroot

    (I've always been using this kind of naming with "/" for windows since
    4.0.x in case I need compat)

    It's almost as if it found index.php in the current namespace, and
    decides it doesn't need to go to include_path to look for one? just
    guessing...

    ------------------------------------------------------------------------

    [2006-11-17 15:25:31] [email]tony2001@php.net[/email]

    What if you change "../classes" to the full path?

    ------------------------------------------------------------------------

    [2006-11-17 14:11:09] [email]tony2001@php.net[/email]

    I didn't use your example, I tested it in another way.

    ------------------------------------------------------------------------

    [2006-11-17 14:05:26] snowy at corporatezoo dot com

    tony, sorry I just realised that example might be different in linux
    because of being case sensitive.

    could you try renaming the files and class name to "index"... ie,
    "../classes/index.php" and "class index".

    See which one it tries to load up first. thx

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at corporatezoo dot com Guest

  10. #9

    Default #39542 [Com]: Search order for include/require wrong in get_include_path

    ID: 39542
    Comment by: jsnell at e-normous dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    Also seeing this in: PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)
    using Linux relay 2.4.29 #2 SMP Sat Mar 12 13:17:01 CST 2005 i686
    GNU/Linux


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-11-28 22:45:47] snowy at corporatezoo dot com

    Hi any update on this? btw, in case it was confusing, that wasn't a
    "fix" I posted, it is merely a way to circumvent the behaviour.

    Obviously this "fix" would require the renaming of all php class files
    in old code, which is an extreme pain, but it would be ok, if I could
    just confirm what the new "behaviour" of includes is meant to be.

    If there is not supposed to be a change in the behaviour of
    includes/requires, then this is probably a bug

    ------------------------------------------------------------------------

    [2006-11-17 23:45:30] snowy at corporatezoo dot com

    Oh btw (in case it wasn't obvious), the "remedy" is

    1) rename the class file to "fooIndex.php"
    2) rename the class to fooIndex
    3) in index.php, $index = new fooIndex();

    so the issue is when the script "driver" file (ie, the one in docroot)
    is named the same as the class file (in the class path) even when the 2
    files are of different case (index.php vs Index.php).

    ------------------------------------------------------------------------

    [2006-11-17 23:39:53] snowy at corporatezoo dot com

    actually I am using full paths, I'm doing a:

    define('SITEROOT_DIR','/web/myproject');
    define('FRAMEWORK_DIR','/web/framework');
    define('SITECLASS_DIR',SITEROOT_DIR.'/_application');
    set_include_path(SITECLASS_DIR.';'.FRAMEWORK_DIR.' ;'.get_include_path());

    and /web/myproject/docroot is the docroot

    (I've always been using this kind of naming with "/" for windows since
    4.0.x in case I need compat)

    It's almost as if it found index.php in the current namespace, and
    decides it doesn't need to go to include_path to look for one? just
    guessing...

    ------------------------------------------------------------------------

    [2006-11-17 15:25:31] [email]tony2001@php.net[/email]

    What if you change "../classes" to the full path?

    ------------------------------------------------------------------------

    [2006-11-17 14:11:09] [email]tony2001@php.net[/email]

    I didn't use your example, I tested it in another way.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    jsnell at e-normous dot com Guest

  11. #10

    Default #39542 [Com]: Search order for include/require wrong in get_include_path

    ID: 39542
    Comment by: jsnell at e-normous dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    Test case:
    Create a file called test.php with the following:
    <?php
    set_include_path(dirname(__FILE__).'/lib/');
    echo(get_include_path()."\n");
    require_once('test.php');
    ?>
    and create a subdirectory called lib, containing a file called test.php
    with the following contents:
    Included Test from lib/

    Results with php 4 (PHP 4.4.4 (cli) (built: Nov 1 2006 18:10:56) --
    osx 10.4.x:
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP 5.1.4 (PHP 5.1.4 (cli) (built: Jan 25 2007 11:50:25)
    ):
    php5 test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP CVS (anon checked out on February 2nd):
    .../sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/

    --
    I believe the original submission is wrong, by changing require_once()
    to require(), the file from lib/ is being loaded.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-02 16:48:00] jsnell at e-normous dot com

    Also seeing this in: PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)
    using Linux relay 2.4.29 #2 SMP Sat Mar 12 13:17:01 CST 2005 i686
    GNU/Linux

    ------------------------------------------------------------------------

    [2006-11-28 22:45:47] snowy at corporatezoo dot com

    Hi any update on this? btw, in case it was confusing, that wasn't a
    "fix" I posted, it is merely a way to circumvent the behaviour.

    Obviously this "fix" would require the renaming of all php class files
    in old code, which is an extreme pain, but it would be ok, if I could
    just confirm what the new "behaviour" of includes is meant to be.

    If there is not supposed to be a change in the behaviour of
    includes/requires, then this is probably a bug

    ------------------------------------------------------------------------

    [2006-11-17 23:45:30] snowy at corporatezoo dot com

    Oh btw (in case it wasn't obvious), the "remedy" is

    1) rename the class file to "fooIndex.php"
    2) rename the class to fooIndex
    3) in index.php, $index = new fooIndex();

    so the issue is when the script "driver" file (ie, the one in docroot)
    is named the same as the class file (in the class path) even when the 2
    files are of different case (index.php vs Index.php).

    ------------------------------------------------------------------------

    [2006-11-17 23:39:53] snowy at corporatezoo dot com

    actually I am using full paths, I'm doing a:

    define('SITEROOT_DIR','/web/myproject');
    define('FRAMEWORK_DIR','/web/framework');
    define('SITECLASS_DIR',SITEROOT_DIR.'/_application');
    set_include_path(SITECLASS_DIR.';'.FRAMEWORK_DIR.' ;'.get_include_path());

    and /web/myproject/docroot is the docroot

    (I've always been using this kind of naming with "/" for windows since
    4.0.x in case I need compat)

    It's almost as if it found index.php in the current namespace, and
    decides it doesn't need to go to include_path to look for one? just
    guessing...

    ------------------------------------------------------------------------

    [2006-11-17 15:25:31] [email]tony2001@php.net[/email]

    What if you change "../classes" to the full path?

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    jsnell at e-normous dot com Guest

  12. #11

    Default #39542 [Opn]: Search order for include/require wrong in get_include_path

    ID: 39542
    User updated by: snowy at corporatezoo dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    oh so maybe the search order is different between require and
    require_once?

    hmmm makes senses since it looks like a namespace caching issue.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-02 22:02:34] jsnell at e-normous dot com

    Test case:
    Create a file called test.php with the following:
    <?php
    set_include_path(dirname(__FILE__).'/lib/');
    echo(get_include_path()."\n");
    require_once('test.php');
    ?>
    and create a subdirectory called lib, containing a file called test.php
    with the following contents:
    Included Test from lib/

    Results with php 4 (PHP 4.4.4 (cli) (built: Nov 1 2006 18:10:56) --
    osx 10.4.x:
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP 5.1.4 (PHP 5.1.4 (cli) (built: Jan 25 2007 11:50:25)
    ):
    php5 test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP CVS (anon checked out on February 2nd):
    .../sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/

    --
    I believe the original submission is wrong, by changing require_once()
    to require(), the file from lib/ is being loaded.

    ------------------------------------------------------------------------

    [2007-02-02 16:48:00] jsnell at e-normous dot com

    Also seeing this in: PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)
    using Linux relay 2.4.29 #2 SMP Sat Mar 12 13:17:01 CST 2005 i686
    GNU/Linux

    ------------------------------------------------------------------------

    [2006-11-28 22:45:47] snowy at corporatezoo dot com

    Hi any update on this? btw, in case it was confusing, that wasn't a
    "fix" I posted, it is merely a way to circumvent the behaviour.

    Obviously this "fix" would require the renaming of all php class files
    in old code, which is an extreme pain, but it would be ok, if I could
    just confirm what the new "behaviour" of includes is meant to be.

    If there is not supposed to be a change in the behaviour of
    includes/requires, then this is probably a bug

    ------------------------------------------------------------------------

    [2006-11-17 23:45:30] snowy at corporatezoo dot com

    Oh btw (in case it wasn't obvious), the "remedy" is

    1) rename the class file to "fooIndex.php"
    2) rename the class to fooIndex
    3) in index.php, $index = new fooIndex();

    so the issue is when the script "driver" file (ie, the one in docroot)
    is named the same as the class file (in the class path) even when the 2
    files are of different case (index.php vs Index.php).

    ------------------------------------------------------------------------

    [2006-11-17 23:39:53] snowy at corporatezoo dot com

    actually I am using full paths, I'm doing a:

    define('SITEROOT_DIR','/web/myproject');
    define('FRAMEWORK_DIR','/web/framework');
    define('SITECLASS_DIR',SITEROOT_DIR.'/_application');
    set_include_path(SITECLASS_DIR.';'.FRAMEWORK_DIR.' ;'.get_include_path());

    and /web/myproject/docroot is the docroot

    (I've always been using this kind of naming with "/" for windows since
    4.0.x in case I need compat)

    It's almost as if it found index.php in the current namespace, and
    decides it doesn't need to go to include_path to look for one? just
    guessing...

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at corporatezoo dot com Guest

  13. #12

    Default #39542 [Opn->Fbk]: Search order for include/require wrong in get_include_path

    ID: 39542
    Updated by: [email]tony2001@php.net[/email]
    Reported By: snowy at corporatezoo dot com
    -Status: Open
    +Status: Feedback
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php5.2-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php5.2-win32-latest.zip[/url]




    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-02 22:22:26] snowy at corporatezoo dot com

    oh so maybe the search order is different between require and
    require_once?

    hmmm makes senses since it looks like a namespace caching issue.

    ------------------------------------------------------------------------

    [2007-02-02 22:02:34] jsnell at e-normous dot com

    Test case:
    Create a file called test.php with the following:
    <?php
    set_include_path(dirname(__FILE__).'/lib/');
    echo(get_include_path()."\n");
    require_once('test.php');
    ?>
    and create a subdirectory called lib, containing a file called test.php
    with the following contents:
    Included Test from lib/

    Results with php 4 (PHP 4.4.4 (cli) (built: Nov 1 2006 18:10:56) --
    osx 10.4.x:
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP 5.1.4 (PHP 5.1.4 (cli) (built: Jan 25 2007 11:50:25)
    ):
    php5 test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP CVS (anon checked out on February 2nd):
    .../sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/

    --
    I believe the original submission is wrong, by changing require_once()
    to require(), the file from lib/ is being loaded.

    ------------------------------------------------------------------------

    [2007-02-02 16:48:00] jsnell at e-normous dot com

    Also seeing this in: PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)
    using Linux relay 2.4.29 #2 SMP Sat Mar 12 13:17:01 CST 2005 i686
    GNU/Linux

    ------------------------------------------------------------------------

    [2006-11-28 22:45:47] snowy at corporatezoo dot com

    Hi any update on this? btw, in case it was confusing, that wasn't a
    "fix" I posted, it is merely a way to circumvent the behaviour.

    Obviously this "fix" would require the renaming of all php class files
    in old code, which is an extreme pain, but it would be ok, if I could
    just confirm what the new "behaviour" of includes is meant to be.

    If there is not supposed to be a change in the behaviour of
    includes/requires, then this is probably a bug

    ------------------------------------------------------------------------

    [2006-11-17 23:45:30] snowy at corporatezoo dot com

    Oh btw (in case it wasn't obvious), the "remedy" is

    1) rename the class file to "fooIndex.php"
    2) rename the class to fooIndex
    3) in index.php, $index = new fooIndex();

    so the issue is when the script "driver" file (ie, the one in docroot)
    is named the same as the class file (in the class path) even when the 2
    files are of different case (index.php vs Index.php).

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    tony2001@php.net Guest

  14. #13

    Default #39542 [Fbk->Opn]: Search order for include_once/require_once wrong in get_include_path

    ID: 39542
    User updated by: snowy at corporatezoo dot com
    -Summary: Search order for include/require wrong in
    get_include_path
    Reported By: snowy at corporatezoo dot com
    -Status: Feedback
    +Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    hi tried the windows snap, also just tried 5.2.1 and same problem.

    I'll just confirm with jsnell's observation that it is indeed
    require_once that is throwing that exception.

    require seems to work fine.

    ie

    function __autoload($class)
    {
    require_once($class . '.php');
    }

    breaks

    whilst

    function __autoload($class)
    {
    require($class . '.php');
    }

    works


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-05 14:01:19] [email]tony2001@php.net[/email]

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php5.2-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php5.2-win32-latest.zip[/url]



    ------------------------------------------------------------------------

    [2007-02-02 22:22:26] snowy at corporatezoo dot com

    oh so maybe the search order is different between require and
    require_once?

    hmmm makes senses since it looks like a namespace caching issue.

    ------------------------------------------------------------------------

    [2007-02-02 22:02:34] jsnell at e-normous dot com

    Test case:
    Create a file called test.php with the following:
    <?php
    set_include_path(dirname(__FILE__).'/lib/');
    echo(get_include_path()."\n");
    require_once('test.php');
    ?>
    and create a subdirectory called lib, containing a file called test.php
    with the following contents:
    Included Test from lib/

    Results with php 4 (PHP 4.4.4 (cli) (built: Nov 1 2006 18:10:56) --
    osx 10.4.x:
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP 5.1.4 (PHP 5.1.4 (cli) (built: Jan 25 2007 11:50:25)
    ):
    php5 test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP CVS (anon checked out on February 2nd):
    .../sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/

    --
    I believe the original submission is wrong, by changing require_once()
    to require(), the file from lib/ is being loaded.

    ------------------------------------------------------------------------

    [2007-02-02 16:48:00] jsnell at e-normous dot com

    Also seeing this in: PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)
    using Linux relay 2.4.29 #2 SMP Sat Mar 12 13:17:01 CST 2005 i686
    GNU/Linux

    ------------------------------------------------------------------------

    [2006-11-28 22:45:47] snowy at corporatezoo dot com

    Hi any update on this? btw, in case it was confusing, that wasn't a
    "fix" I posted, it is merely a way to circumvent the behaviour.

    Obviously this "fix" would require the renaming of all php class files
    in old code, which is an extreme pain, but it would be ok, if I could
    just confirm what the new "behaviour" of includes is meant to be.

    If there is not supposed to be a change in the behaviour of
    includes/requires, then this is probably a bug

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at corporatezoo dot com Guest

  15. #14

    Default #39542 [Com]: Search order for include_once/require_once wrong in get_include_path

    ID: 39542
    Comment by: jsnell at e-normous dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    still fails for me in the latest snapshot:

    One other thing to note, it functions differently depending on where
    you call the script from:
    e-normous:/Users/jsnell/delete/php5/testcase/lib$
    .../../../php5.2-200702131330/sapi/cli/php ../test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    vs.

    e-normous:/Users/jsnell/delete/php5/testcase$
    .../../php5.2-200702131330/sapi/cli/php ./test.php
    /Users/jsnell/delete/php5/testcase/lib/

    and

    e-normous:/Users/jsnell/delete/php5/testcase$
    .../../php5.2-200702131330/sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/lib/


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-09 05:11:00] snowy at corporatezoo dot com

    hi tried the windows snap, also just tried 5.2.1 and same problem.

    I'll just confirm with jsnell's observation that it is indeed
    require_once that is throwing that exception.

    require seems to work fine.

    ie

    function __autoload($class)
    {
    require_once($class . '.php');
    }

    breaks

    whilst

    function __autoload($class)
    {
    require($class . '.php');
    }

    works

    ------------------------------------------------------------------------

    [2007-02-05 14:01:19] [email]tony2001@php.net[/email]

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php5.2-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php5.2-win32-latest.zip[/url]



    ------------------------------------------------------------------------

    [2007-02-02 22:22:26] snowy at corporatezoo dot com

    oh so maybe the search order is different between require and
    require_once?

    hmmm makes senses since it looks like a namespace caching issue.

    ------------------------------------------------------------------------

    [2007-02-02 22:02:34] jsnell at e-normous dot com

    Test case:
    Create a file called test.php with the following:
    <?php
    set_include_path(dirname(__FILE__).'/lib/');
    echo(get_include_path()."\n");
    require_once('test.php');
    ?>
    and create a subdirectory called lib, containing a file called test.php
    with the following contents:
    Included Test from lib/

    Results with php 4 (PHP 4.4.4 (cli) (built: Nov 1 2006 18:10:56) --
    osx 10.4.x:
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP 5.1.4 (PHP 5.1.4 (cli) (built: Jan 25 2007 11:50:25)
    ):
    php5 test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP CVS (anon checked out on February 2nd):
    .../sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/

    --
    I believe the original submission is wrong, by changing require_once()
    to require(), the file from lib/ is being loaded.

    ------------------------------------------------------------------------

    [2007-02-02 16:48:00] jsnell at e-normous dot com

    Also seeing this in: PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)
    using Linux relay 2.4.29 #2 SMP Sat Mar 12 13:17:01 CST 2005 i686
    GNU/Linux

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    jsnell at e-normous dot com Guest

  16. #15

    Default #39542 [Com]: Search order for include_once/require_once wrong in get_include_path

    ID: 39542
    Comment by: snowy at coporatezoo dot com
    Reported By: snowy at corporatezoo dot com
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Windows XP
    PHP Version: 5.2.0
    New Comment:

    tried this on 5.2.1 on OSX as well and it also fails.

    Another thing:

    if my file is in /project/docroot/file.php

    even if I do a:

    require_once('/project/classes/File.php');

    it still fails.

    Notice that it's (1) case insensitive, (2) the actual full path is
    given in require_once.

    I thought it may have been caching the full path, but looks like it's
    only looking if '[F|f]ile.php' (the file name) has been loaded.

    Ie, even

    set_include_path('/project');
    require_once('classes/file.php'); // give a path name to avoid
    namespace clash

    doesn't work.

    Is this going to be fixed? Or should we go and change all our
    include_once/require_once if we want to upgrade to > 5.1.6?

    thx


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-13 16:42:02] jsnell at e-normous dot com

    still fails for me in the latest snapshot:

    One other thing to note, it functions differently depending on where
    you call the script from:
    e-normous:/Users/jsnell/delete/php5/testcase/lib$
    .../../../php5.2-200702131330/sapi/cli/php ../test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    vs.

    e-normous:/Users/jsnell/delete/php5/testcase$
    .../../php5.2-200702131330/sapi/cli/php ./test.php
    /Users/jsnell/delete/php5/testcase/lib/

    and

    e-normous:/Users/jsnell/delete/php5/testcase$
    .../../php5.2-200702131330/sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/lib/

    ------------------------------------------------------------------------

    [2007-02-09 05:11:00] snowy at corporatezoo dot com

    hi tried the windows snap, also just tried 5.2.1 and same problem.

    I'll just confirm with jsnell's observation that it is indeed
    require_once that is throwing that exception.

    require seems to work fine.

    ie

    function __autoload($class)
    {
    require_once($class . '.php');
    }

    breaks

    whilst

    function __autoload($class)
    {
    require($class . '.php');
    }

    works

    ------------------------------------------------------------------------

    [2007-02-05 14:01:19] [email]tony2001@php.net[/email]

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php5.2-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php5.2-win32-latest.zip[/url]



    ------------------------------------------------------------------------

    [2007-02-02 22:22:26] snowy at corporatezoo dot com

    oh so maybe the search order is different between require and
    require_once?

    hmmm makes senses since it looks like a namespace caching issue.

    ------------------------------------------------------------------------

    [2007-02-02 22:02:34] jsnell at e-normous dot com

    Test case:
    Create a file called test.php with the following:
    <?php
    set_include_path(dirname(__FILE__).'/lib/');
    echo(get_include_path()."\n");
    require_once('test.php');
    ?>
    and create a subdirectory called lib, containing a file called test.php
    with the following contents:
    Included Test from lib/

    Results with php 4 (PHP 4.4.4 (cli) (built: Nov 1 2006 18:10:56) --
    osx 10.4.x:
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP 5.1.4 (PHP 5.1.4 (cli) (built: Jan 25 2007 11:50:25)
    ):
    php5 test.php
    /Users/jsnell/delete/php5/testcase/lib/
    Included Test from lib/

    Results with PHP CVS (anon checked out on February 2nd):
    .../sapi/cli/php test.php
    /Users/jsnell/delete/php5/testcase/

    --
    I believe the original submission is wrong, by changing require_once()
    to require(), the file from lib/ is being loaded.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/39542[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=39542&edit=1[/url]
    snowy at coporatezoo dot com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139