filebackend: Avoid using popen() when "parallelize" is disabled
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 18 Jun 2014 17:18:49 +0000 (10:18 -0700)
committerKrinkle <krinklemail@gmail.com>
Wed, 18 Jun 2014 20:12:03 +0000 (20:12 +0000)
Bug: 66467
Change-Id: Iaf8eb2ecfad166e26e265a98933399dc4bc255a3

includes/filebackend/FileBackendStore.php
includes/filebackend/FileOpBatch.php

index 340c315..ee9a49d 100644 (file)
@@ -1147,6 +1147,7 @@ abstract class FileBackendStore extends FileBackend {
                $this->clearCache();
 
                $supportedOps = array( 'create', 'store', 'copy', 'move', 'delete', 'describe', 'null' );
+               // Parallel ops may be disabled in config due to dependencies (e.g. needing popen())
                $async = ( $this->parallelize === 'implicit' && count( $ops ) > 1 );
                $maxConcurrency = $this->concurrency; // throttle
 
index 56d7000..b0d83e0 100644 (file)
@@ -167,7 +167,11 @@ class FileOpBatch {
                        // or the backend does not support async ops and did it synchronously.
                        foreach ( $performOpsBatch as $i => $fileOp ) {
                                if ( !isset( $status->success[$i] ) ) { // didn't already fail in precheck()
-                                       $subStatus = $fileOp->attemptAsync();
+                                       // Parallel ops may be disabled in config due to missing dependencies,
+                                       // (e.g. needing popen()). When they are, $performOpsBatch has size 1.
+                                       $subStatus = ( count( $performOpsBatch ) > 1 )
+                                               ? $fileOp->attemptAsync()
+                                               : $fileOp->attempt();
                                        if ( $subStatus->value instanceof FileBackendStoreOpHandle ) {
                                                $opHandles[$i] = $subStatus->value; // deferred
                                        } else {