BackUpWordPress plugin produces tarballs containing duplicates

I’m using BackUpWordPress to do regular database and file tree backups of this blog. Unfortunately, there is a nasty bug in this plugin which may cause the tarball to contain every backuped file multiple times (to be precise, every file except the first one will go into the tarball exactly three times).

The problem is that the . and .. directories may appear in a somewhat random order and not necessarily as the first entries in a directory. This is probably host specific (I encountered this error for the first time after I relocated this blog to another server).

To fix BackUpWordPress v0.4.5, locate line 103 in Directory.php (resides in wp-content/plugins/backupwordpress/Archive/Reader/) and change the while-loop inside the next() function

...
        while ($this->source === null ||
              ($error = $this->source->next()) !== true) {
...

like this

...
        $file = null; 
        while ($this->source === null ||
              $file == '.' || $file == '..' || 
              ($error = $this->source->next()) !== true) {
...

Alternatively, you can use the following patch:

--- Directory.php.orig	2010-07-17 15:02:56.093238736 +0200
+++ Directory.php	2010-07-17 15:04:10.367237641 +0200
@@ -103,0 +104 @@
+        $file = null; 

@@ -104,0 +106 @@
+              $file == '.' || $file == '..' || 

Resources:
http://pear.php.net/bugs/bug.php?id=6546

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.