I have a blog with all the plugins I need committed to an internal svn repository. Wordpress is showing that some plugins need to be updated but when I do, Wordpress will delete the folder for that plugin so the .svn files are deleted as well. This will break the repository for that plugin. Any way around this?
3 Answers
a simple way around this is to update the plugins by SVN from the plugin repository.
-
but like that I'll need to edit the tags in the svn:external settings every time a plugin needs updating. Also what is the safest way of finding the plugin in the repository. Lots of plugins have similar names and don't want to download the wrong one.....in others words if I want wordpress.org/extend/plugins/all-in-one-seo-pack , how can I find the repository folder and be sure its the correct one. Commented Jul 15, 2011 at 15:23
-
You can find the repository by clicking on "OTHER VERSIONS" on the left side of plugin page and at the bottom you have "Subversion Repository" Commented Jul 15, 2011 at 22:51
I just decided to patch the core to fix this. We manage a lot of separate development projects built on wordpress and we like to keep plugin updates under our own control without the associated hassles of externals. I'd prefer a hook but one does not exist and it's probably best not to provide one for such low level actions. But on the plus side the modifications only affect a single function in the class-wp-filesystem-direct.php file and that file hasn't changed significantly in almost two years.
//@version 3.4
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;
}
The key differences are to ignore /.svn/ folders entirely, and then to not fail when directories can't be removed. They'll still be removed if they don't contain child .svn folders. As a result you may need to prune a couple "empty" directories every now and then but I haven't had to do that yet. And you'll of course need to re-patch the file each time you update the core.
Another option is to download the plugin as a zip file from the wordpress plugins directory and use a file manager utility to do a one-way merge or sync between the two directories. Windows explorer will do this natively if you just drag and drop the new plugin folder over the existing one. But it's just far easier to click that update now link in the wp-admin area.
How are you updating the plugins?
The only way around this I have found is to go in to each folder and replace files folder by folder without replacing a folder. A pain but it's the only way I know of.