* Corrected and improved FileBackend::getFileList() comments.
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 8 Feb 2012 22:13:03 +0000 (22:13 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 8 Feb 2012 22:13:03 +0000 (22:13 +0000)
* Added unit tests for using getFileList() iterators twice.

includes/filerepo/backend/FileBackend.php
tests/phpunit/includes/filerepo/FileBackendTest.php

index 1d699e5..79da6e1 100644 (file)
@@ -531,11 +531,14 @@ abstract class FileBackend {
 
        /**
         * Get an iterator to list out all stored files under a storage directory.
-        * If the directory is of the form "mwstore://container", then all items in
-        * the container should be listed. If of the form "mwstore://container/dir",
-        * then all items under that container directory should be listed.
+        * If the directory is of the form "mwstore://backend/container", 
+        * then all files in the container should be listed.
+        * If the directory is of form "mwstore://backend/container/dir",
+        * then all files under that container directory should be listed.
         * Results should be storage paths relative to the given directory.
         * 
+        * Storage backends with eventual consistency might return stale data.
+        * 
         * $params include:
         *     dir : storage path directory
         *
index 3a148cf..7b04a40 100644 (file)
@@ -1223,6 +1223,15 @@ class FileBackendTest extends MediaWikiTestCase {
 
                $this->assertEquals( $expected, $list, "Correct file listing ($backendName)." );
 
+               // Actual listing (using iterator second time)
+               $list = array();
+               foreach ( $iter as $file ) {
+                       $list[] = $file;
+               }
+               sort( $list );
+
+               $this->assertEquals( $expected, $list, "Correct file listing ($backendName), second iteration." );
+
                foreach ( $files as $file ) { // clean up
                        $this->backend->doOperation( array( 'op' => 'delete', 'src' => $file ) );
                }