ID: 42501
Comment by: tzachi at zend dot com
Reported By: eric at ericmmartin dot com
Status: Open
Bug Type: Filesystem function related
Operating System: Windows XP
PHP Version: 5.2.4
New Comment:
It seems to be a problem with PHP thread-safe. With PHP-NTS that is
provided from 5.2.1 and on it seems to work as expected. Apparently the
thread-safety version (which is what common in windows) of glob has a
problem with pattern that begins with '{'.
Previous Comments:
------------------------------------------------------------------------
[2007-09-03 14:39:11] eric at ericmmartin dot com
>From my previous comment: "I added BLOG_NOCHECK and found"...
- I mean GLOB_NOCHECK, of course =)
------------------------------------------------------------------------
[2007-09-03 14:37:32] eric at ericmmartin dot com
I added BLOG_NOCHECK and found that I needed to update my first test
(it was missing a directory seperator...but even after fixing that, it
still fails. Here are the updated tests and results.
Reproduce code:
---------------
<?php
$paths = '{c:/globtest/firstfolder/,c:/globtest/secondfolder/}';
$ext = '*.png';
print_r(get_files($paths,$ext));
$paths = 'c:/globtest/';
$ext = '{firstfolder/*.png,secondfolder/*.png}';
print_r(get_files($paths,$ext));
function get_files($paths, $ext) {
return glob($paths.$ext,GLOB_BRACE+GLOB_NOCHECK);
}
?>
Actual result:
--------------
Array
(
[0] => c:/globtest/firstfolder/*.png
[1] => c:/globtest/secondfolder/*.png
)
Array
(
[0] => c:/globtest/firstfolder/arrow_down.png
[1] => c:/globtest/firstfolder/arrow_off.png
[2] => c:/globtest/firstfolder/arrow_up.png
[3] => c:/globtest/secondfolder/arrow_down.png
[4] => c:/globtest/secondfolder/arrow_off.png
[5] => c:/globtest/secondfolder/arrow_up.png
)
The pattern looks correct! Even if I use 'arrow_off.png' instead of
'*.png' for $ext, glob() fails. It seems like the colon breaks it, for
some reason...
------------------------------------------------------------------------
[2007-09-03 11:30:01] [EMAIL PROTECTED]
Try passing GLOB_NOCHECK as flag too, it should return the actual
pattern used then when it doesn't find any files.
------------------------------------------------------------------------
[2007-08-31 18:05:57] eric at ericmmartin dot com
Description:
------------
glob() with the GLOB_BRACE flag seems to have a bug. I believe that the
colon (:) in a pattern in braces, is causing the problem.
I tried escaping the colon, but that did not seem to work.
Reproduce code:
---------------
<?php
$paths = '{c:/globtest/firstfolder,c:/globtest/secondfolder}';
$ext = '*.png';
print_r(get_files($paths,$ext));
$paths = 'c:/globtest/';
$ext = '{firstfolder/*.png,secondfolder/*.png}';
print_r(get_files($paths,$ext));
function get_files($paths, $ext) {
return glob($paths.$ext,GLOB_BRACE);
}
?>
Expected result:
----------------
Array
(
[0] => c:/globtest/firstfolder/arrow_down.png
[1] => c:/globtest/firstfolder/arrow_off.png
[2] => c:/globtest/firstfolder/arrow_up.png
[3] => c:/globtest/secondfolder/arrow_down.png
[4] => c:/globtest/secondfolder/arrow_off.png
[5] => c:/globtest/secondfolder/arrow_up.png
)
Array
(
[0] => c:/globtest/firstfolder/arrow_down.png
[1] => c:/globtest/firstfolder/arrow_off.png
[2] => c:/globtest/firstfolder/arrow_up.png
[3] => c:/globtest/secondfolder/arrow_down.png
[4] => c:/globtest/secondfolder/arrow_off.png
[5] => c:/globtest/secondfolder/arrow_up.png
)
Actual result:
--------------
Array
(
)
Array
(
[0] => c:/globtest/firstfolder/arrow_down.png
[1] => c:/globtest/firstfolder/arrow_off.png
[2] => c:/globtest/firstfolder/arrow_up.png
[3] => c:/globtest/secondfolder/arrow_down.png
[4] => c:/globtest/secondfolder/arrow_off.png
[5] => c:/globtest/secondfolder/arrow_up.png
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42501&edit=1