Use executeOpHandlesInternal() in SwiftFileBackend
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 13 Mar 2017 21:26:56 +0000 (14:26 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 20 Mar 2017 18:04:40 +0000 (18:04 +0000)
Instead calling doExecuteOpHandlesInternal() directly, use the
wrapper parent class method instead so that closeResources() is
called on all of the handles.

Change-Id: Iab0d4f7c08d155639a44f48147b78283059a6d24

includes/libs/filebackend/FileBackendStore.php
includes/libs/filebackend/SwiftFileBackend.php

index 7cb26c6..039bd42 100644 (file)
@@ -1200,21 +1200,20 @@ abstract class FileBackendStore extends FileBackend {
         * to the order in which the handles where given.
         *
         * @param FileBackendStoreOpHandle[] $fileOpHandles
-        *
-        * @throws FileBackendError
         * @return StatusValue[] Map of StatusValue objects
+        * @throws FileBackendError
         */
        final public function executeOpHandlesInternal( array $fileOpHandles ) {
                $ps = $this->scopedProfileSection( __METHOD__ . "-{$this->name}" );
 
                foreach ( $fileOpHandles as $fileOpHandle ) {
                        if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) {
-                               throw new InvalidArgumentException( "Got a non-FileBackendStoreOpHandle object." );
+                               throw new InvalidArgumentException( "Expected FileBackendStoreOpHandle object." );
                        } elseif ( $fileOpHandle->backend->getName() !== $this->getName() ) {
-                               throw new InvalidArgumentException(
-                                       "Got a FileBackendStoreOpHandle for the wrong backend." );
+                               throw new InvalidArgumentException( "Expected handle for this file backend." );
                        }
                }
+
                $res = $this->doExecuteOpHandlesInternal( $fileOpHandles );
                foreach ( $fileOpHandles as $fileOpHandle ) {
                        $fileOpHandle->closeResources();
index 631f6fd..ae0ad6f 100644 (file)
@@ -287,7 +287,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually write the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -353,7 +353,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually write the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -401,7 +401,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually write the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -460,7 +460,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually move the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -500,7 +500,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually delete the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;
@@ -556,7 +556,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['async'] ) ) { // deferred
                        $status->value = $opHandle;
                } else { // actually change the object in Swift
-                       $status->merge( current( $this->doExecuteOpHandlesInternal( [ $opHandle ] ) ) );
+                       $status->merge( current( $this->executeOpHandlesInternal( [ $opHandle ] ) ) );
                }
 
                return $status;