Opened 10 years ago
Closed 10 years ago
#32120 closed enhancement (wontfix)
WordPress updates damage .svn folders. Patch WP_Filesystem_Direct::delete() to preserve them.
Reported by: | philmprice | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2 |
Component: | Filesystem API | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
Can you please update the WP_Filesystem_Direct::delete() function to preserve .svn folders? We manage a large number of SVN version controlled WordPress installations, and it would really help us (and anybody who uses SVN) a lot. The patched function looks like this:
public function delete($file, $recursive = false, $type = false) { if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. return false; $file = str_replace('\\', '/', $file); //for win32, occasional problems deleting files otherwise if ( 'f' == $type || $this->is_file($file) ) return @unlink($file); if ( ! $recursive && $this->is_dir($file) ) return @rmdir($file); //At this point its a folder, and we're in recursive mode $file = trailingslashit($file); $retval = true; //preserve svn folders if (preg_match("|\/\.svn\/$|", $file)) return $retval; $filelist = $this->dirlist($file, true); if ( is_array($filelist) ) //false if no files, So check first. foreach ($filelist as $filename => $fileinfo) if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) $retval = false; //don't worry if directories are left behind if ( file_exists($file) ) @rmdir($file); return $retval; }
Change History (2)
#2
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
The behaviour here would be expected, the delete method completely removes a directory and all it's contents, including hidden files & directories, and the methods that use it require that behaviour.
If you're using a VCS, I'd suggest not using WordPress's built in upgrade routines, or upgrade to SVN 1.8 which doesn't require a .svn
directory in every sub directory (only the root).
Note: See
TracTickets for help on using
tickets.
Thanks for the report Phil.
Can you provide a little more context? Are you using the
delete()
method in a plugin, or are you seeing problems caused by its use by WordPress core? This issue would also affect the other filesystem drivers, such asWP_Filesystem_SSH2
.If the
delete()
method is wiping out.svn
directories when that's not desired, then obviously we need to consider other directories that shouldn't be deleted too, such as.git
,.hg
, etc.