Commit 3ba6374b authored by mmn's avatar mmn

Memcached_DataObject extensions got their update functions more consistent

parent fa91bc71
......@@ -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;
......
......@@ -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();
}
......
......@@ -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()
......
......@@ -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);
}
/**
......
......@@ -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) {
......
......@@ -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);
}
/**
......
......@@ -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()
......
......@@ -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()
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment