diff --git a/classes/Config.php b/classes/Config.php index bf9d880cae..33a556e579 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -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; diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 68dd6475f6..f9ace16ce6 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -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(); } diff --git a/classes/Profile.php b/classes/Profile.php index d697536b43..b2dab519a1 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -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() diff --git a/classes/Profile_list.php b/classes/Profile_list.php index 8cf5d210f8..509a1df242 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -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); } /** diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index 39095aedde..5256aa13c8 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -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) { diff --git a/classes/Status_network.php b/classes/Status_network.php index eb9bd69e1f..863dea98b4 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -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); } /** diff --git a/classes/Subscription.php b/classes/Subscription.php index a9ffe8913e..4f27537f27 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -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() diff --git a/classes/User_group.php b/classes/User_group.php index bbae402091..efac365da2 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -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() diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php index c0c4f142e4..1bd158e6d2 100644 --- a/plugins/OStatus/classes/HubSub.php +++ b/plugins/OStatus/classes/HubSub.php @@ -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.