From 812487e902b8149fbc500e4d2cd2c5ec8a74229c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 5 Oct 2012 15:07:23 -0700 Subject: [PATCH] [FileBackend] Tweaked FileBackendMultiWrite behavior to fix test leakage. Change-Id: I0a967780b64d1883cfeb1a7a183bbb82dc1ae432 --- includes/filebackend/FileBackendMultiWrite.php | 9 +++++---- tests/phpunit/includes/filerepo/FileBackendTest.php | 9 ++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/filebackend/FileBackendMultiWrite.php b/includes/filebackend/FileBackendMultiWrite.php index 7df09d180a..e62cdaa6e3 100644 --- a/includes/filebackend/FileBackendMultiWrite.php +++ b/includes/filebackend/FileBackendMultiWrite.php @@ -179,10 +179,11 @@ class FileBackendMultiWrite extends FileBackend { // Actually attempt the operation batch on the master backend... $masterStatus = $mbe->doOperations( $realOps, $opts ); $status->merge( $masterStatus ); - // Propagate the operations to the clone backends if there were no fatal errors. - // If $ops only had one operation, this might avoid backend inconsistencies. - // This also avoids inconsistency for expected errors (like "file already exists"). - if ( !count( $masterStatus->getErrorsArray() ) ) { + // Propagate the operations to the clone backends if there were no unexpected errors + // and if there were either no expected errors or if the 'force' option was used. + // However, if nothing succeeded at all, then don't replicate any of the operations. + // If $ops only had one operation, this might avoid backend sync inconsistencies. + if ( $masterStatus->isOK() && $masterStatus->successCount > 0 ) { foreach ( $this->backends as $index => $backend ) { if ( $index !== $this->masterIndex ) { // not done already $realOps = $this->substOpBatchPaths( $ops, $backend ); diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php index fa2afaa6bf..cb54bb66b7 100644 --- a/tests/phpunit/includes/filerepo/FileBackendTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendTest.php @@ -50,7 +50,7 @@ class FileBackendTest extends MediaWikiTestCase { 'parallelize' => 'implicit', 'backends' => array( array( - 'name' => 'localmutlitesting1', + 'name' => 'localmultitesting1', 'class' => 'FSFileBackend', 'lockManager' => 'nullLockManager', 'containerPaths' => array( @@ -59,7 +59,7 @@ class FileBackendTest extends MediaWikiTestCase { 'isMultiMaster' => false ), array( - 'name' => 'localmutlitesting2', + 'name' => 'localmultitesting2', 'class' => 'FSFileBackend', 'lockManager' => 'nullLockManager', 'containerPaths' => array( @@ -1893,7 +1893,7 @@ class FileBackendTest extends MediaWikiTestCase { foreach ( $this->filesToPrune as $file ) { @unlink( $file ); } - $containers = array( 'unittest-cont1', 'unittest-cont2', 'unittest-cont3' ); + $containers = array( 'unittest-cont1', 'unittest-cont2' ); foreach ( $containers as $container ) { $this->deleteFiles( $container ); } @@ -1905,8 +1905,7 @@ class FileBackendTest extends MediaWikiTestCase { $iter = $this->backend->getFileList( array( 'dir' => "$base/$container" ) ); if ( $iter ) { foreach ( $iter as $file ) { - $this->backend->delete( array( 'src' => "$base/$container/$file" ), - array( 'force' => 1, 'nonLocking' => 1 ) ); + $this->backend->quickDelete( array( 'src' => "$base/$container/$file" ) ); } } $this->backend->clean( array( 'dir' => "$base/$container", 'recursive' => 1 ) ); -- 2.20.1