diff --git a/modules/Favorite/FavoriteModule.php b/modules/Favorite/FavoriteModule.php index 4073690d06..ae33ad512f 100644 --- a/modules/Favorite/FavoriteModule.php +++ b/modules/Favorite/FavoriteModule.php @@ -342,7 +342,14 @@ class FavoriteModule extends ActivityVerbHandlerModule { $fave = new Fave(); $fave->user_id = $profile->id; - $fave->delete(); // Will perform a DELETE matching "user_id = {$user->id}" + + // Will perform a DELETE matching "user_id = {$user->id}" + if ($fave->find()) { + while ($fave->fetch()) { + $fave->delete(); + } + } + $fave->free(); Fave::blowCacheForProfileId($profile->id); diff --git a/modules/Favorite/classes/Fave.php b/modules/Favorite/classes/Fave.php index 3a42c21ff4..285f0f684c 100644 --- a/modules/Favorite/classes/Fave.php +++ b/modules/Favorite/classes/Fave.php @@ -137,18 +137,14 @@ class Fave extends Managed_DataObject $result = null; try { - if ($this->find()) { - while ($this->fetch()) { - $profile = $this->getActor(); - $notice = $this->getTarget(); + $profile = $this->getActor(); + $notice = $this->getTarget(); - if (Event::handle('StartDisfavorNotice', [$profile, $notice, &$result])) { - $result = parent::delete($useWhere); + if (Event::handle('StartDisfavorNotice', [$profile, $notice, &$result])) { + $result = parent::delete($useWhere); - if ($result !== false) { - Event::handle('EndDisfavorNotice', [$profile, $notice]); - } - } + if ($result !== false) { + Event::handle('EndDisfavorNotice', [$profile, $notice]); } } } catch (NoResultException $e) {