MFB: Catch errors from incorrectly configured VFS.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 24 Oct 2009 18:51:30 +0000 (14:51 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 24 Oct 2009 18:51:30 +0000 (14:51 -0400)
Bug: 7741

turba/lib/Object.php

index 06f9d77..1ae8b2b 100644 (file)
@@ -272,9 +272,11 @@ class Turba_Object {
      */
     function deleteFile($file)
     {
-        $this->_vfsInit();
-
-        return $this->_vfs->deleteFile(TURBA_VFS_PATH . '/' . $this->getValue('__uid'), $file);
+        if (!is_a($result = $this->_vfsInit(), 'PEAR_Error')) {
+            return $this->_vfs->deleteFile(TURBA_VFS_PATH . '/' . $this->getValue('__uid'), $file);
+        } else {
+            return $result;
+        }
     }
 
     /**
@@ -282,13 +284,15 @@ class Turba_Object {
      */
     function deleteFiles()
     {
-        $this->_vfsInit();
+        if (!is_a($result = $this->_vfsInit(), 'PEAR_Error')) {
+            if ($this->_vfs->exists(TURBA_VFS_PATH, $this->getValue('__uid'))) {
+                return $this->_vfs->deleteFolder(TURBA_VFS_PATH, $this->getValue('__uid'), true);
+            }
 
-        if ($this->_vfs->exists(TURBA_VFS_PATH, $this->getValue('__uid'))) {
-            return $this->_vfs->deleteFolder(TURBA_VFS_PATH, $this->getValue('__uid'), true);
+            return true;
         }
 
-        return true;
+        return $result;
     }
 
     /**