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

Bug #5895 Recursive chmod ends in endless loop
Submitted: 2005-11-08 13:22 UTC
From: sasha_k at techs dot com dot ua Assigned: toby
Status: Closed Package: Net_FTP
PHP Version: 4.4.1 OS:
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 : 22 + 42 = ?

 
 [2005-11-08 13:22 UTC] sasha_k at techs dot com dot ua
Description: ------------ The problem is as "Bug #4969 Recursive rm ends in endless loop" in "chmode_recursive" too. was: ------------------------------------ function chmodRecursive($target, $permissions) { static $dir_permissions; if(!isset($dir_permissions)){ // Making directory specific permissions $dir_permissions = $this->_makeDirPermissions($permissions); } // If $target is an array: Loop through it if (is_array($target)) { for ($i = 0; $i < count($target); $i++) { $res = $this->chmodRecursive($target[$i], $permissions); if (PEAR::isError($res)) { return $res; } // end if isError } // end for i < count($target) } else { $remote_path = $this->_construct_path($target); // Chmod the directory itself $result = $this->chmod($remote_path, $dir_permissions); if (PEAR::isError($result)) { return $result; } // If $remote_path last character is not a slash, add one if (substr($remote_path, strlen($remote_path)-1) != "/") { $remote_path .= "/"; } $dir_list = array(); $mode = NET_FTP_DIRS_ONLY; $dir_list = $this->ls($remote_path, $mode); foreach ($dir_list as $dir_entry) { $remote_path_new = $remote_path.$dir_entry["name"]."/"; // Chmod the directory we're about to enter $result = $this->chmod($remote_path_new, $dir_permissions); if (PEAR::isError($result)) { return $result; } $result = $this->chmodRecursive($remote_path_new, $permissions); if (PEAR::isError($result)) { return $result; } } // end foreach dir_list as dir_entry $file_list = array(); $mode = NET_FTP_FILES_ONLY; $file_list = $this->ls($remote_path, $mode); foreach ($file_list as $file_entry) { $remote_file = $remote_path.$file_entry["name"]; $result = $this->chmod($remote_file, $permissions); if (PEAR::isError($result)) { return $result; } } // end foreach $file_list } // end if is_array return true; // No errors } // end method chmodRecursive ------------------------------------ patch: ------------------------------------ function chmodRecursive($target, $permissions) { static $dir_permissions; if(!isset($dir_permissions)){ // Making directory specific permissions $dir_permissions = $this->_makeDirPermissions($permissions); } // If $target is an array: Loop through it if (is_array($target)) { for ($i = 0; $i < count($target); $i++) { $res = $this->chmodRecursive($target[$i], $permissions); if (PEAR::isError($res)) { return $res; } // end if isError } // end for i < count($target) } else { $remote_path = $this->_construct_path($target); // Chmod the directory itself $result = $this->chmod($remote_path, $dir_permissions); if (PEAR::isError($result)) { return $result; } // If $remote_path last character is not a slash, add one if (substr($remote_path, strlen($remote_path)-1) != "/") { $remote_path .= "/"; } $dir_list = array(); $mode = NET_FTP_DIRS_ONLY; $dir_list = $this->ls($remote_path, $mode); foreach ($dir_list as $dir_entry) { if (($dir_entry["name"] != '.') && ($dir_entry["name"] != '..')) { $remote_path_new = $remote_path.$dir_entry["name"]."/"; // Chmod the directory we're about to enter $result = $this->chmod($remote_path_new, $dir_permissions); if (PEAR::isError($result)) { return $result; } $result = $this->chmodRecursive($remote_path_new, $permissions); if (PEAR::isError($result)) { return $result; } } } // end foreach dir_list as dir_entry $file_list = array(); $mode = NET_FTP_FILES_ONLY; $file_list = $this->ls($remote_path, $mode); foreach ($file_list as $file_entry) { $remote_file = $remote_path.$file_entry["name"]; $result = $this->chmod($remote_file, $permissions); if (PEAR::isError($result)) { return $result; } } // end foreach $file_list } // end if is_array return true; // No errors } // end method chmodRecursive ------------------------------------

Comments

 [2006-02-09 22:52 UTC] toby
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.