Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

a simple way around this is to update the plugins by SVN from the plugin repository.

share|improve this answer
    
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. –  Matthew Xerri Jul 15 '11 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" –  Bainternet Jul 15 '11 at 22:51
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.