From c2861f924c7fdd79f12f0821cf79138cf326c09e Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 8 Feb 2012 22:13:03 +0000 Subject: [PATCH] * Corrected and improved FileBackend::getFileList() comments. * Added unit tests for using getFileList() iterators twice. --- includes/filerepo/backend/FileBackend.php | 9 ++++++--- tests/phpunit/includes/filerepo/FileBackendTest.php | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 1d699e5555..79da6e17d7 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -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 * diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php index 3a148cf727..7b04a40752 100644 --- a/tests/phpunit/includes/filerepo/FileBackendTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendTest.php @@ -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 ) ); } -- 2.20.1