Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.3

Bug #4669 Repeated calls to search or maptree return multiple copies of results
Submitted: 2005-06-23 18:24 UTC
From: epgremill3 at yahoo dot com Assigned: tuupola
Status: Closed Package: File_Find
PHP Version: 5.0.3 OS: Windows XP Pro
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 46 + 9 = ?

 
 [2005-06-23 18:24 UTC] epgremill3 at yahoo dot com
Description: ------------ Repeated calls to File_Find::search with the same parameters yields multiple copies of the matching files in the results. I'm using File_Find 0.2.0. I believe this is happening because maptree does not clear the $directories and $files member variables of the File_Find class. I can correct for this problem by creating a new instance of File_Find before each call to maptree or search. I alternatively corrected for the problem by modifying the maptree and _build functions to use function-scope variables instead of the class member variables. This gave the added benefit of allowing static calls to maptree and search. If you would like to see my code, I would happily email it to you. Reproduce code: --------------- require_once("File/Find.php"); $pattern = "/User.*\.php/"; $dirpath = $_SERVER["DOCUMENT_ROOT"] . "/com/exceptionals"; $dirpath = str_replace("/", "\\", $dirpath); $pattern_type = "perl"; $f = new File_Find(); $res = $f->search($pattern, $dirpath, $pattern_type); $res = $f->search($pattern, $dirpath, $pattern_type); echo("<p>\n"); print_r($res); echo("</p>\n"); Expected result: ---------------- Array ( [0] => C:\Documents and Settings\Ernie Gremillion\My Documents\Exceptionals\Website\com\exceptionals\data_access\UserData.class.php [1] => C:\Documents and Settings\Ernie Gremillion\My Documents\Exceptionals\Website\com\exceptionals\application\User.class.php ) Actual result: -------------- Array ( [0] => C:\Documents and Settings\Ernie Gremillion\My Documents\Exceptionals\Website\com\exceptionals\data_access\UserData.class.php [1] => C:\Documents and Settings\Ernie Gremillion\My Documents\Exceptionals\Website\com\exceptionals\application\User.class.php [2] => C:\Documents and Settings\Ernie Gremillion\My Documents\Exceptionals\Website\com\exceptionals\data_access\UserData.class.php [3] => C:\Documents and Settings\Ernie Gremillion\My Documents\Exceptionals\Website\com\exceptionals\application\User.class.php )

Comments

 [2005-08-11 07:54 UTC] tuupola
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/File_Find 0.4.0 is the latest version and has this problem fixed.