# Case sensitivity of require_once

- Thread: https://externals.io/message/11339
- Original archive: https://news-web.php.net/php.internals/11339
- Started by Jakub Vrana on 2004-07-19T08:56:02+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11339 — Jakub Vrana — 2004-07-19T08:56:02+00:00

URL: https://externals.io/message/11339#11339

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

---

## #11341 — Wez Furlong — 2004-07-19T10:12:58+00:00

URL: https://externals.io/message/11339#11341 · In reply to: #11339

Did you test require_once under PHP 5 yet?
(without your patch)

--Wez.


> 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

---

## #11342 — Antony Dovgal — 2004-07-19T10:17:51+00:00

URL: https://externals.io/message/11339#11342 · In reply to: #11341

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

---

## #11345 — Jakub Vrana — 2004-07-19T12:45:12+00:00

URL: https://externals.io/message/11339#11345 · In reply to: #11341

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

---

## #11346 — Antony Dovgal — 2004-07-19T12:50:56+00:00

URL: https://externals.io/message/11339#11346 · In reply to: #11345

On Mon, 19 Jul 2004 14:45:12 +0200
Jakub Vrana <vrana@php.net> wrote:

> Wez Furlong wrote:
> > […]
> This behavior is PHP 4 specific.
> 
> Antony Dovgal wrote:
> > […]
> 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

---

## #11347 — Michele Locati — 2004-07-19T12:55:52+00:00

URL: https://externals.io/message/11339#11347 · In reply to: #11341

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:

>Did you test require_once under PHP 5 yet?
>(without your patch)
>
>--Wez.
>
>
> > […]
>estrndup(inc_filename->value.str.val, inc_filename->value.str.len);
> > […]
>zend_str_tolower(file_handle.opened_path, strlen(file_handle.opened_path));
> > […]
>(zend_hash_add(&EG(included_files), file_handle.opened_path,
>strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int),
>NULL)==SUCCESS) {
> > […]
>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);
> > […]

---

## #11348 — Stanislav Malyshev — 2004-07-19T12:55:58+00:00

URL: https://externals.io/message/11339#11348 · In reply to: #11347

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

---

## #11350 — Paul G — 2004-07-19T13:04:01+00:00

URL: https://externals.io/message/11339#11350 · In reply to: #11348

----- 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

---

## #11349 — Wez Furlong — 2004-07-19T13:06:40+00:00

URL: https://externals.io/message/11339#11349 · In reply to: #11348

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:
> 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.
