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

Bug #7270 rm_dir recursive
Submitted: 2006-03-31 06:47 UTC Modified: 2007-11-24 14:50 UTC
From: fabio dot esposito at gmail dot com Assigned: jorrit
Status: Closed Package: Net_FTP (version 1.3.2)
PHP Version: 4.3.11 OS: Linux
Roadmaps: 1.3.3    
Subscription  


 [2006-03-31 06:47 UTC] fabio dot esposito at gmail dot com (Fabio Esposito)
Description: ------------ When we try to remove recursively a dir on a unix server this error appear: "Uninitialized string offset: 0" (on windows it works) Test script: --------------- We change your _rm_dir_recursive function as below (see "/**/" comments) and now the code works on any plataform function _rm_dir_recursive($dir) { if (substr($dir, (strlen($dir) - 1), 1) != "/") { return $this->raiseError("Directory name '$dir' is invalid, has to end with '/'", NET_FTP_ERR_REMOTEPATHNODIR); } $file_list = $this->_ls_files($dir); foreach ($file_list as $file) { $file = $dir.$file["name"]; $res = $this->rm($file); if ($this->isError($res)) { return $res; } } $dir_list = $this->_ls_dirs($dir); foreach ($dir_list as $new_dir) { /** * in past the test isn't the position 'name' of the array but the entire array and the loop never ends. now works fine * **/ if ($new_dir['name'] == '.' || $new_dir['name'] == '..') { continue; } $new_dir = $dir.$new_dir["name"]."/"; //echo $new_dir."<br/>"; $res = $this->_rm_dir_recursive($new_dir); if ($this->isError($res)) { return $res; } } $res = $this->_rm_dir($dir); if (PEAR::isError($res)) { return $res; } else { return true; } } Expected result: ---------------- remove recursively a directory Actual result: -------------- with the patch the script works fine

Comments

 [2007-11-24 14:50 UTC] jorrit (Jorrit Schippers)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.