|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-02 18:49 UTC] fred dot demers at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/function.glob --- Documentation shortcoming for glob(). glob() does not seem to find any pattern that is longer than 50 characters. In particular, if one expands the search pattern to remove case sensitivity using sql_regcase() or an equivalent function as available the glob() manual page, (eg. which transforms "cake*" into "[cC][aA][kK][eE]*"), the number of characters is reduced four times to about 12 characters. This 50 character limitation should be documented in my opinion. Test script: --------------- //recursive glob() find function find($dir, $pattern){ //get a list of all matching files in the current directory $files = glob("$dir/".$pattern); //find a list of all directories in the current directory //directories beginning with a dot are also included foreach (glob("$dir/{.[^.]*,*}", GLOB_BRACE|GLOB_ONLYDIR) as $sub_dir){ $arr = find($sub_dir, $pattern); // resursive call $files = array_merge($files, $arr); // merge array with files from subdirectory } //return all found files return $files; } Expected result: ---------------- Nil. Alternatively, users can use preg_find (http://www.pgregg.com/projects/php/preg_find/preg_find.phps) which does not have a 50 character limitation. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. └─▪ mkdir "this is a very long directory name, which definetly exceeds 50 chars to test the bug"┌─[bjori][][~] └─▪ php -r '$n = sql_regcase("this is a very long directory name, which definetly exceeds 50 chars to test the bug"); var_dump(glob("./$n", GLOB_BRACE|GLOB_ONLYDIR));' array(1) { [0] => string(86) './this is a very long directory name, which definetly exceeds 50 chars to test the bug' } Works fine for me?