From: Aaron Schulz Date: Fri, 26 Feb 2016 23:55:09 +0000 (-0800) Subject: Use sync writes for replication of 'store' operations X-Git-Tag: 1.31.0-rc.0~7813^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=c0446571d53139bc1a19afe136de33faf25faf80;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 );