[wp-trac] [WordPress Trac] #32120: WordPress updates damage .svn folders. Patch WP_Filesystem_Direct::delete() to preserve them.
WordPress Trac
noreply at wordpress.org
Fri Apr 24 16:34:55 UTC 2015
#32120: WordPress updates damage .svn folders. Patch WP_Filesystem_Direct::delete()
to preserve them.
----------------------------+-----------------------------
Reporter: philmprice | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Filesystem API | Version: 4.2
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
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;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32120>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list