Aaron Schulz has submitted this change and it was merged.

Change subject: Fixed move bug that caused test failures.
......................................................................


Fixed move bug that caused test failures.

Change-Id: Iad368435a7aff88f78aee72133130da307a9e2be
---
M php-cloudfiles-wmf/cloudfiles.php
1 file changed, 25 insertions(+), 4 deletions(-)

Approvals:
  Aaron Schulz: Verified
  Demon: Looks good to me, approved



diff --git a/php-cloudfiles-wmf/cloudfiles.php 
b/php-cloudfiles-wmf/cloudfiles.php
index afb276a..f2f92aa 100644
--- a/php-cloudfiles-wmf/cloudfiles.php
+++ b/php-cloudfiles-wmf/cloudfiles.php
@@ -959,6 +959,14 @@
        }
 
        /**
+        * @param $cont CF_Container|string
+        * @return bool Whether this is the same container as the given one
+        */
+       public function equals( $cont ) {
+               return ( $this->name === self::get_container_name( $cont ) );
+       }
+
+       /**
         * Enable Container content to be served via CDN or modify CDN 
attributes
         *
         * Either enable this Container's content to be served via CDN or
@@ -1573,9 +1581,15 @@
        public function move_object_to(
                $obj, $container_target, $dest_obj_name = NULL, $metadata = 
NULL, $headers = NULL
        ) {
+               $src_obj_name = self::get_object_name( $obj );
+               $dest_obj_name = isset( $dest_obj_name ) ? $dest_obj_name : 
$src_obj_name;
                $retVal = $this->copy_object_to(
                        $obj, $container_target, $dest_obj_name, $metadata, 
$headers );
-               return $retVal ? $this->delete_object( $obj, $this->name ) : 
False;
+               if ( $this->equals( $container_target ) && $src_obj_name === 
$dest_obj_name ) {
+                       return $retVal; // nothing to delete
+               } else {
+                       return $retVal ? $this->delete_object( $obj, 
$this->name ) : False;
+               }
        }
 
        /**
@@ -1585,9 +1599,16 @@
        public function move_object_to_async(
                $obj, $container_target, $dest_obj_name = NULL, $metadata = 
NULL, $headers = NULL
        ) {
-               return $this->copy_object_to_async(
-                       $obj, $container_target, $dest_obj_name, $metadata, 
$headers
-               )->combine( $this->delete_object_async( $obj, $this->name ) );
+               $src_obj_name = self::get_object_name( $obj );
+               $dest_obj_name = isset( $dest_obj_name ) ? $dest_obj_name : 
$src_obj_name;
+               if ( $this->equals( $container_target ) && $src_obj_name === 
$dest_obj_name ) {
+                       return $this->copy_object_to_async(
+                               $obj, $container_target, $dest_obj_name, 
$metadata, $headers );
+               } else {
+                       return $this->copy_object_to_async(
+                               $obj, $container_target, $dest_obj_name, 
$metadata, $headers
+                       )->combine( $this->delete_object_async( $obj, 
$this->name ) );
+               }
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/56935
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iad368435a7aff88f78aee72133130da307a9e2be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SwiftCloudFiles
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Demon <ch...@wikimedia.org>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to