Merge "Maintenance script for importing site info."
[lhc/web/wiklou.git] / includes / filebackend / FileOpBatch.php
index e90fcb7..faa1314 100644 (file)
@@ -55,7 +55,6 @@ class FileOpBatch {
         * @return Status
         */
        public static function attempt( array $performOps, array $opts, FileJournal $journal ) {
-               $section = new ProfileSection( __METHOD__ );
                $status = Status::newGood();
 
                $n = count( $performOps );
@@ -152,6 +151,8 @@ class FileOpBatch {
                                // We can't continue (even with $ignoreErrors) as $predicates is wrong.
                                // Log the remaining ops as failed for recovery...
                                foreach ( $performOpsBatch as $i => $fileOp ) {
+                                       $status->success[$i] = false;
+                                       ++$status->failCount;
                                        $performOpsBatch[$i]->logFailure( 'attempt_aborted' );
                                }
                                continue;
@@ -165,7 +166,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 {