]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Memcached_DataObject extensions got their update functions more consistent
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Oct 2013 18:36:05 +0000 (19:36 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Oct 2013 18:36:05 +0000 (19:36 +0100)
classes/Config.php
classes/Memcached_DataObject.php
classes/Profile.php
classes/Profile_list.php
classes/Profile_tag.php
classes/Status_network.php
classes/Subscription.php
classes/User_group.php
plugins/OStatus/classes/HubSub.php

index bf9d880caef6168009fb25c615aa3d9a39dfef8a..33a556e579752324a6af0fef5e640691522fc8e3 100644 (file)
@@ -124,10 +124,10 @@ class Config extends Managed_DataObject
         return $result;
     }
 
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        $result = parent::update($orig);
-        if ($result) {
+        $result = parent::update($dataObject);
+        if ($result !== false) {
             Config::_blowSettingsCache();
         }
         return $result;
index 68dd6475f6d9bde16349be99b8181e768895a900..f9ace16ce6b1bf626f175e11c6ddb9d7270c7cec 100644 (file)
@@ -388,13 +388,13 @@ class Memcached_DataObject extends Safe_DataObject
         return $result;
     }
 
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        if (is_object($orig) && $orig instanceof Memcached_DataObject) {
-            $orig->decache(); # might be different keys
+        if (is_object($dataObject) && $dataObject instanceof Memcached_DataObject) {
+            $dataObject->decache(); # might be different keys
         }
-        $result = parent::update($orig);
-        if ($result) {
+        $result = parent::update($dataObject);
+        if ($result !== false) {
             $this->fixupTimestamps();
             $this->encache();
         }
index d697536b439b957b6d99ec674622ffe75e21465b..b2dab519a1599940733f0c1a9853860db52eeb3c 100644 (file)
@@ -842,12 +842,12 @@ class Profile extends Managed_DataObject
         return ($biolimit > 0 && !empty($bio) && (mb_strlen($bio) > $biolimit));
     }
 
-    public function update($orig)
+    function update($dataObject=false)
     {
-        if ($this->nickname != $orig->nickname) {
-            $local = User::getKV('id', $this->id);
-            if ($local instanceof User) {
-                common_debug("Updating User ({$this->id}) nickname from {$orig->nickname} to {$this->nickname}");
+        if (is_object($dataObject) && $this->nickname != $dataObject->nickname) {
+            try {
+                $local = $this->getUser();
+                common_debug("Updating User ({$this->id}) nickname from {$dataObject->nickname} to {$this->nickname}");
                 $origuser = clone($local);
                 $local->nickname = $this->nickname;
                 $result = $local->updateKeys($origuser);
@@ -861,10 +861,12 @@ class Profile extends Managed_DataObject
                 if ($local->hasRole(Profile_role::OWNER)) {
                     User::blow('user:site_owner');
                 }
+            } catch (NoSuchUserException $e) {
+                // Nevermind...
             }
         }
 
-        return parent::update($orig);
+        return parent::update($dataObject);
     }
 
     function delete()
index 8cf5d210f823c0012811e2a4c91cc6ebb6452708..509a1df242498fd546abce672f2c2b2ed945dba9 100644 (file)
@@ -356,23 +356,23 @@ class Profile_list extends Managed_DataObject
      * Update a people tag gracefully
      * also change "tag" fields in profile_tag table
      *
-     * @param Profile_list $orig    Object's original form
+     * @param Profile_list $dataObject    Object's original form
      *
      * @return boolean success
      */
 
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        $result = true;
-
-        if (!is_object($orig) && !$orig instanceof Profile_list) {
-            parent::update($orig);
+        if (!is_object($dataObject) && !$dataObject instanceof Profile_list) {
+            return parent::update($dataObject);
         }
 
+        $result = true;
+
         // if original tag was different
         // check to see if the new tag already exists
         // if not, rename the tag correctly
-        if($orig->tag != $this->tag || $orig->tagger != $this->tagger) {
+        if($dataObject->tag != $this->tag || $dataObject->tagger != $this->tagger) {
             $existing = Profile_list::getByTaggerAndTag($this->tagger, $this->tag);
             if(!empty($existing)) {
                 // TRANS: Server exception.
@@ -381,10 +381,9 @@ class Profile_list extends Managed_DataObject
             }
             // move the tag
             // XXX: allow OStatus plugin to send out profile tag
-            $result = Profile_tag::moveTag($orig, $this);
+            $result = Profile_tag::moveTag($dataObject, $this);
         }
-        parent::update($orig);
-        return $result;
+        return parent::update($dataObject);
     }
 
     /**
index 39095aeddedeb07f47bbac8c419e0599e625fdb6..5256aa13c8029805c4041be53b1f355858027f9d 100644 (file)
@@ -282,11 +282,11 @@ class Profile_tag extends Managed_DataObject
                                        $tags->escape($orig->tag),
                                        $tags->escape($orig->tagger)));
 
-        if (!$result) {
+        if ($result === false) {
             common_log_db_error($tags, 'UPDATE', __FILE__);
-            return false;
+            throw new Exception('Could not move Profile_tag, see db log for details.');
         }
-        return true;
+        return $result;
     }
 
     static function blowCaches($tagger, $tagged) {
index eb9bd69e1f94f1db07fbf3e89c88c1d8ede5b0f9..863dea98b4949c7956b671a39712d11d160d66ec 100644 (file)
@@ -147,12 +147,12 @@ class Status_network extends Safe_DataObject
         }
     }
 
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        if (is_object($orig)) {
-            $orig->decache(); # might be different keys
+        if (is_object($dataObject)) {
+            $dataObject->decache(); # might be different keys
         }
-        return parent::update($orig);
+        return parent::update($dataObject);
     }
 
     /**
index a9ffe8913e97123072b19c08870e6cd10b8b30c9..4f27537f278ff205260c71c36e7a2b215eb72adf 100644 (file)
@@ -389,18 +389,16 @@ class Subscription extends Managed_DataObject
      * Because we cache subscriptions, it's useful to flush them
      * here.
      *
-     * @param mixed $orig Original version of object
+     * @param mixed $dataObject Original version of object
      *
      * @return boolean success flag.
      */
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        $result = parent::update($orig);
-
         self::blow('subscription:by-subscriber:'.$this->subscriber);
         self::blow('subscription:by-subscribed:'.$this->subscribed);
 
-        return $result;
+        return parent::update($dataObject);
     }
 
     function getURI()
index bbae40209178c3573582247915485d703ddafff4..efac365da20bafe5c41b33bd647c0efb7bb3be36 100644 (file)
@@ -782,14 +782,14 @@ class User_group extends Managed_DataObject
         return parent::delete();
     }
 
-    public function update($orig)
+    public function update($dataObject=false)
     {
         // Whenever the User_group is updated, find the Local_group
-        // and updates it nickname too.
-        if ($this->nickname != $orig->nickname) {
+        // and update its nickname too.
+        if ($this->nickname != $dataObject->nickname) {
             $local = Local_group::getKV('group_id', $this->id);
             if ($local instanceof Local_group) {
-                common_debug("Updating Local_group ({$this->id}) nickname from {$orig->nickname} to {$this->nickname}");
+                common_debug("Updating Local_group ({$this->id}) nickname from {$dataObject->nickname} to {$this->nickname}");
                 $local->setNickname($this->nickname);
             }
         }
@@ -814,7 +814,7 @@ class User_group extends Managed_DataObject
             throw new ServerException(_('Unable to update profile'));
         }
 
-        return parent::update($orig);
+        return parent::update($dataObject);
     }
 
     function isPrivate()
index c0c4f142e4ff593dff39152bb8aa5129bc29a3ee..1bd158e6d22669fe2ce5928be6fa7fc1735d24f7 100644 (file)
@@ -191,16 +191,6 @@ class HubSub extends Managed_DataObject
         return parent::insert();
     }
 
-    /**
-     * Update wrapper; transparently update modified column.
-     * @return boolean success
-     */
-    function update($old=null)
-    {
-        $this->modified = common_sql_now();
-        return parent::update($old);
-    }
-
     /**
      * Schedule delivery of a 'fat ping' to the subscriber's callback
      * endpoint. If queues are disabled, this will run immediately.