php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60204 glob() function parameter string limited to 50 characters
Submitted: 2011-11-02 18:49 UTC Modified: 2013-02-18 00:35 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:0 of 0 (0.0%)
From: fred dot demers at gmail dot com Assigned:
Status: No Feedback Package: Documentation problem
PHP Version: 5.3.8 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fred dot demers at gmail dot com
New email:
PHP Version: OS:

 

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-21 15:37 UTC] bjori@php.net
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?
 [2011-12-21 15:37 UTC] bjori@php.net
-Status: Open +Status: Feedback
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC