Check if a modification might lead to renaming the object. Rename if required.
authorGunnar Wrobel <p@rdus.de>
Thu, 9 Apr 2009 20:14:33 +0000 (22:14 +0200)
committerGunnar Wrobel <p@rdus.de>
Thu, 9 Apr 2009 20:14:33 +0000 (22:14 +0200)
Fix collapsing attributes if none of the attributes to collapse have been set.

framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php

index 9e7e95e..2a71585 100644 (file)
@@ -409,6 +409,9 @@ class Horde_Kolab_Server_Object
                     break;
                 }
             }
+            if ($empty == 0) {
+                return;
+            }
             ksort($attributes);
             $unset = $attributes;
             $result = '';
@@ -620,6 +623,16 @@ class Horde_Kolab_Server_Object
                                                                    $key));
                 }
             }
+
+            /* Check for potential renaming of the object here */
+            $new_info = array_merge($this->_cache, $info);
+            $new_uid = $this->server->generateServerUid(get_class($this),
+                                                        $this->generateId($new_info),
+                                                        $new_info);
+            if ($new_uid != $this->uid) {
+                $this->server->rename($this->uid, $new_uid);
+                $this->uid = $new_uid;
+            }
         }
 
         $result = $this->server->save($this->uid, $info, $this->exists());