From c0446571d53139bc1a19afe136de33faf25faf80 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 26 Feb 2016 15:55:09 -0800 Subject: [PATCH] Use sync writes for replication of 'store' operations The local temporary file might not live long enough to be copied into storage during post-send. Bug: T128124 Change-Id: Ifb5260958db008ec8b9f4db90f95a42e5ecaeadc --- includes/filebackend/FileBackendMultiWrite.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/filebackend/FileBackendMultiWrite.php b/includes/filebackend/FileBackendMultiWrite.php index 132c4a68be..2d2745097f 100644 --- a/includes/filebackend/FileBackendMultiWrite.php +++ b/includes/filebackend/FileBackendMultiWrite.php @@ -199,7 +199,7 @@ class FileBackendMultiWrite extends FileBackend { } $realOps = $this->substOpBatchPaths( $ops, $backend ); - if ( $this->asyncWrites ) { + if ( $this->asyncWrites && !$this->hasStoreOperation( $ops ) ) { // Bind $scopeLock to the callback to preserve locks DeferredUpdates::addCallableUpdate( function() use ( $backend, $realOps, $opts, $scopeLock ) { @@ -467,6 +467,20 @@ class FileBackendMultiWrite extends FileBackend { ); } + /** + * @param array $ops File operation batch map + * @return bool + */ + protected function hasStoreOperation( array $ops ) { + foreach ( $ops as $op ) { + if ( $op['op'] === 'store' ) { + return true; + } + } + + return false; + } + protected function doQuickOperationsInternal( array $ops ) { $status = Status::newGood(); // Do the operations on the master backend; setting Status fields... @@ -480,7 +494,7 @@ class FileBackendMultiWrite extends FileBackend { } $realOps = $this->substOpBatchPaths( $ops, $backend ); - if ( $this->asyncWrites ) { + if ( $this->asyncWrites && !$this->hasStoreOperation( $ops ) ) { DeferredUpdates::addCallableUpdate( function() use ( $backend, $realOps ) { $backend->doQuickOperations( $realOps ); -- 2.20.1