#11261 closed defect (bug) (fixed)
method chmod in WP_Filesystem doesn't work in recursive mode
| Reported by: | G.Hue | Owned by: | dd32 |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Filesystem API | Version: | 2.8.4 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
The following code doesn't work when recursive mode is used :
File wp-admin\includes\class-wp-filesystem-ftpext.php
Line 142
function chmod($file, $mode = false, $recursive = false) {
if( ! $mode )
$mode = $this->permission;
if( ! $mode )
return false;
if ( ! $this->exists($file) && ! $this->is_dir($file) )
return false;
if ( ! $recursive || ! $this->is_dir($file) ) {
if ( ! function_exists('ftp_chmod') ){
return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
}
echo "@ftp_chmod(_$this->link, $mode, $file);";
return @ftp_chmod($this->link, $mode, $file);
}
//Is a directory, and we want recursive
$filelist = $this->dirlist($file);
foreach($filelist as $filename){
$this->chmod($file . '/' . $filename, $mode, $recursive);
}
return true;
}
No chmod is apply on the directory. Chmod is apply only on subfiles (and subdirectories but the same problem appear...)
$this->dirlist return an array of array. On this case:
$this->chmod($file . '/' . $filename, $mode, $recursive);
$filename is an array, not the filename. It can't work.
Attachments (2)
Change History (11)
#1
@
17 years ago
- Component General → Filesystem
- Keywords needs-patch added; ftpext chmod class-wp-filesystem-ftpext.php removed
- Milestone Unassigned → 2.9
- Owner set to
- Status new → accepted
#3
@
17 years ago
- Summary method chmod in class-wp-filesystem-ftpext doesn't work in recursive mode → method chmod in WP_Filesystem doesn't work in recursive mode
What should the settings on the directories be set to? ($mode & exec (browse) bits?)
#4
@
17 years ago
The attachment above is my attempt at fixing this bug. I reordered the logic so it checks to see if it's recursive and a directory first. It will then recursively call chmod (using the proper filename now).
#7
@
17 years ago
The only problem i can see with that is that in some cases, you'll need to chmod the folder before you can get a directory listing.. That should be a pretty rare case however.
I'm going to attempt testing this shortly along with a few other changes.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
See also #10889
Postponing to 3.0 since we don't have a patch.