Author: kn
Date: Thu Oct  4 11:02:35 2007
New Revision: 6356

Log:
- Really fix error handling in memory backend

Modified:
    trunk/Webdav/src/backends/memory.php
    trunk/Webdav/tests/backend_memory_test.php

Modified: trunk/Webdav/src/backends/memory.php
==============================================================================
--- trunk/Webdav/src/backends/memory.php [iso-8859-1] (original)
+++ trunk/Webdav/src/backends/memory.php [iso-8859-1] Thu Oct  4 11:02:35 2007
@@ -594,7 +594,8 @@
      */
     protected function performDelete( $path )
     {
-        // Remove all content nodes starting with requested path
+        // Check if any errors would occur during deletion process
+        $error = array();
         foreach ( $this->content as $name => $content )
         {
             if ( strpos( $name, $path ) === 0 && ( substr( $name, strlen( 
$path ), 1 ) === '/' || $name === $path ) )
@@ -602,16 +603,29 @@
                 // Check if we want to cause some errors here.
                 if ( $this->options->failingOperations & 
ezcWebdavMemoryBackendOptions::REQUEST_DELETE && preg_match( 
$this->options->failForRegexp, $name ) > 0 )
                 {
-                    return new ezcWebdavErrorResponse(
+                    $error[] = new ezcWebdavErrorResponse(
                         ezcWebdavResponse::STATUS_423,
                         $name
                     );
                 }
-                else
-                {
-                    unset( $this->content[$name] );
-                    unset( $this->props[$name] );
-                }
+            }
+        }
+
+        // If errors occured, return them
+        if ( count( $error ) )
+        {
+            return new ezcWebdavMultistatusResponse(
+                $error
+            );
+        }
+
+        // Remove all content nodes starting with requested path
+        foreach ( $this->content as $name => $content )
+        {
+            if ( strpos( $name, $path ) === 0 && ( substr( $name, strlen( 
$path ), 1 ) === '/' || $name === $path ) )
+            {
+                unset( $this->content[$name] );
+                unset( $this->props[$name] );
             }
         }
 

Modified: trunk/Webdav/tests/backend_memory_test.php
==============================================================================
--- trunk/Webdav/tests/backend_memory_test.php [iso-8859-1] (original)
+++ trunk/Webdav/tests/backend_memory_test.php [iso-8859-1] Thu Oct  4 11:02:35 
2007
@@ -1324,9 +1324,13 @@
         $response = $backend->delete( $request );
 
         $this->assertEquals(
-            new ezcWebdavErrorResponse(
-                ezcWebdavResponse::STATUS_423,
-                '/foo'
+            new ezcWebdavMultistatusResponse(
+                array(
+                    new ezcWebdavErrorResponse(
+                        ezcWebdavResponse::STATUS_423,
+                        '/foo'
+                    ),
+                )
             ),
             $response,
             'Expected response does not match real response.',


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to