diff --git a/classes/Profile.php b/classes/Profile.php index 8239cfe5c4..47f4824acd 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -978,6 +978,13 @@ class Profile extends Managed_DataObject $this->_deleteAttentions(); Avatar::deleteFromProfile($this, true); + $this->grantRole(Profile_role::DELETED); + + $localuser = User::getKV('id', $this->id); + if ($localuser instanceof User) { + $localuser->delete(); + } + // Warning: delete() will run on the batch objects, // not on individual objects. $related = [ @@ -993,13 +1000,6 @@ class Profile extends Managed_DataObject $inst->delete(); } - $this->grantRole(Profile_role::DELETED); - - $localuser = User::getKV('id', $this->id); - if ($localuser instanceof User) { - $localuser->delete(); - } - return parent::delete($useWhere); } diff --git a/classes/User_group.php b/classes/User_group.php index d10920da01..8b3c3200dd 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -747,13 +747,6 @@ class User_group extends Managed_DataObject return parent::delete($useWhere); } - try { - $profile = $this->getProfile(); - $profile->delete(); - } catch (GroupNoProfileException $unp) { - common_log(LOG_INFO, "Group {$this->nickname} has no profile; continuing deletion."); - } - // Safe to delete in bulk for now $related = array('Group_inbox', @@ -791,10 +784,22 @@ class User_group extends Managed_DataObject $local->delete(); } + $result = parent::delete($useWhere); + + try { + $profile = $this->getProfile(); + $profile->delete(); + } catch (GroupNoProfileException $unp) { + common_log( + LOG_INFO, + "Group {$this->nickname} has no profile; continuing deletion." + ); + } + // blow the cached ids self::blow('user_group:notice_ids:%d', $this->id); - return parent::delete($useWhere); + return $result; } public function update($dataObject=false)