Case sensitivity of require_once

php.internals

Jakub Vrana

22 years ago
File a.php is required twice with this code on Windows: <?php require_once "a.php"; require_once "A.php"; ?> Should I document this behavior or should patch similar to this be applied? Index: zend_execute.c =================================================================== RCS file: /repository/Zend/Attic/zend_execute.c,v retrieving revision 1.316.2.38 diff -u -r1.316.2.38 zend_execute.c --- zend_execute.c 12 Jul 2004 17:47:32 -0000 1.316.2.38 +++ zend_execute.c 19 Jul 2004 08:48:44 -0000 @@ -2148,6 +2148,10 @@ file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); } +#ifdef ZEND_WIN32 + zend_str_tolower(file_handle.opened_path, strlen(file_handle.opened_path)); +#endif + if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (EX(opline)->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC);
-- Jakub Vrana

Wez Furlong

22 years ago
Did you test require_once under PHP 5 yet? (without your patch) --Wez. On Mon, 19 Jul 2004 10:56:02 +0200, Jakub Vrana <vrana@php.net> wrote:

Antony Dovgal

22 years ago
On Mon, 19 Jul 2004 11:12:58 +0100 Wez Furlong <kingwez@gmail.com> wrote:
> Did you test require_once under PHP 5 yet? > (without your patch)
Yep. http://lists.php.net/php.doc/969361918 --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net || antony@dovgal.com

Jakub Vrana

22 years ago
Wez Furlong wrote:
> Did you test require_once under PHP 5 yet? > (without your patch)
This behavior is PHP 4 specific. Antony Dovgal wrote:
> http://lists.php.net/php.doc/969361918
The problem is not that the file isn't included at all. The problem is that the file is included twice. Jakub Vrana

Antony Dovgal

22 years ago
On Mon, 19 Jul 2004 14:45:12 +0200 Jakub Vrana <vrana@php.net> wrote:
> Wez Furlong wrote: > > Did you test require_once under PHP 5 yet? > > (without your patch) > This behavior is PHP 4 specific. > > Antony Dovgal wrote: > > http://lists.php.net/php.doc/969361918 > The problem is not that the file isn't included at all. The problem is > that the file is included twice.
That's right. I said exactly the same. Dunno if it's a problem or not, but it does ignore case. --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net || antony@dovgal.com

Michele Locati

22 years ago
There's another thing you should note: under Windows it is possible to specify file names in two ways: in the expanded (normal) way, and in a short way (8.3 file naming compatible). For example: C:\Program Files\SomeFileName.ext could be specified also as C:\PROGRA~1\SOMEFI~1.EXT or even C:\PROGRA~1\SomeFileName.ext or C:\Program Files\SOMEFI~1.EXT If there exists two files, say "SomeFileNameA.ext" and "SomeFileNameB.ext", they could be called also "SOMEFI~1.EXT" and "SOMEFI~2.EXT" Thank you for the whole great project you're bringing to us! Ciao Michele *********** In risposta al seguente messaggio *********** Il 19/07/2004 alle 11:12 Wez Furlong ha scritto:

Stanislav Malyshev

22 years ago
ML>>There's another thing you should note: under Windows it is possible to ML>>specify file names in two ways: in the expanded (normal) way, and in a ML>>short way (8.3 file naming compatible). I think there's a function in Win32 API which brings all these forms to common base.
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115

Wez Furlong

22 years ago
I think we're already using it in TSRM in PHP 5, which is why I asked for someone to confirm it there. --Wez. On Mon, 19 Jul 2004 15:55:58 +0300 (IDT), Stanislav Malyshev <stas@zend.com> wrote:

Paul G

22 years ago
----- Original Message ----- From: "Stanislav Malyshev" <stas@zend.com> To: "Michele Locati" <michele@locati.it> Cc: <internals@lists.php.net> Sent: Monday, July 19, 2004 8:55 AM Subject: Re: [PHP-DEV] Case sensitivity of require_once
> ML>>There's another thing you should note: under Windows it is possible to > ML>>specify file names in two ways: in the expanded (normal) way, and in a > ML>>short way (8.3 file naming compatible). > > I think there's a function in Win32 API which brings all these forms to > common base.
you are thinking of GetShortPathName(). not bringing it to the same base per se, but perfectly usable in this case. GetFileInformationByHandle() and the nFileIndex{High,Low} elements of the returned struct could possibly be a more elegant way of doing this. afair, the latter does not require mucking with nt native api, though an extended version of the same call does. don't shoot me, this is from memory ;) paul

Andi Gutmans

22 years ago
Very strange. We do a GetLongPathName() in virtual_file_ex() which opens the file. Can you see if it's reach that piece of code? Andi At 02:55 PM 7/19/2004 +0200, Michele Locati wrote: