From: Aaron Date: Tue, 18 Sep 2012 23:04:13 +0000 (-0700) Subject: [FileBackend] Factored out setConcurrencyFlags() function. X-Git-Tag: 1.31.0-rc.0~22343 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=d97f671fdfc4853f5f5f66e27ed8b558cb8075d8;p=lhc%2Fweb%2Fwiklou.git [FileBackend] Factored out setConcurrencyFlags() function. * This moves some options code from FileBackend to FileBackendStore, where it belongs. This also allows for reuse by other operations. Change-Id: Ic9a7d36a6e4bc6b815a7d68926105401f65c53fb --- diff --git a/includes/filebackend/FileBackend.php b/includes/filebackend/FileBackend.php index 523b8592c0..042cb675ba 100644 --- a/includes/filebackend/FileBackend.php +++ b/includes/filebackend/FileBackend.php @@ -284,16 +284,6 @@ abstract class FileBackend { unset( $opts['nonLocking'] ); unset( $opts['allowStale'] ); } - $opts['concurrency'] = 1; // off - if ( $this->parallelize === 'implicit' ) { - if ( !isset( $opts['parallelize'] ) || $opts['parallelize'] ) { - $opts['concurrency'] = $this->concurrency; - } - } elseif ( $this->parallelize === 'explicit' ) { - if ( !empty( $opts['parallelize'] ) ) { - $opts['concurrency'] = $this->concurrency; - } - } return $this->doOperationsInternal( $ops, $opts ); } diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 083dfea9cd..582332673d 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -1016,6 +1016,7 @@ abstract class FileBackendStore extends FileBackend { $this->primeContainerCache( $performOps ); // Actually attempt the operation batch... + $opts = $this->setConcurrencyFlags( $opts ); $subStatus = FileOpBatch::attempt( $performOps, $opts, $this->fileJournal ); // Merge errors into status fields @@ -1546,6 +1547,26 @@ abstract class FileBackendStore extends FileBackend { wfProfileOut( __METHOD__ . '-' . $this->name ); wfProfileOut( __METHOD__ ); } + + /** + * Set the 'concurrency' option from a list of operation options + * + * @param $opts array Map of operation options + * @return Array + */ + final protected function setConcurrencyFlags( array $opts ) { + $opts['concurrency'] = 1; // off + if ( $this->parallelize === 'implicit' ) { + if ( !isset( $opts['parallelize'] ) || $opts['parallelize'] ) { + $opts['concurrency'] = $this->concurrency; + } + } elseif ( $this->parallelize === 'explicit' ) { + if ( !empty( $opts['parallelize'] ) ) { + $opts['concurrency'] = $this->concurrency; + } + } + return $opts; + } } /**