Return all attributes in a hash.
authorGunnar Wrobel <p@rdus.de>
Wed, 8 Apr 2009 16:51:38 +0000 (18:51 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 8 Apr 2009 16:54:19 +0000 (18:54 +0200)
Fix initializing the cache if the object did not exist.

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

index d390633..338384c 100644 (file)
@@ -468,11 +468,17 @@ class Horde_Kolab_Server_Object
     {
         $result = array();
 
-        if (isset($attrs)) {
-            foreach ($attrs as $key) {
-                $value        = $this->get($key);
-                $result[$key] = $value;
-            }
+        /**
+         * Return all supported attributes if no specific attributes were
+         * requested.
+         */
+        if (empty($attrs)) {
+            $attrs = array_keys($this->attributes);
+        }
+
+        foreach ($attrs as $key) {
+            $value        = $this->get($key);
+            $result[$key] = $value;
         }
 
         return $result;
@@ -615,8 +621,12 @@ class Horde_Kolab_Server_Object
 
         $result = $this->server->save($this->uid, $info, $this->exists());
 
-        $this->_exists = true;
-        $this->_cache  = array_merge($this->_cache, $info);
+        if (!$this->_exists) {
+            $this->_exists = true;
+            $this->_cache  = $info;
+        } else {
+            $this->_cache  = array_merge($this->_cache, $info);
+        }
 
         return $result;
     }