[Favorite] Fix "Properly trigger DisfavorNotice on profile deletion"
Calling find() inside delete() is probably not a good idea.
This commit is contained in:
parent
10f0a15614
commit
3429a3644d
@ -342,7 +342,14 @@ class FavoriteModule extends ActivityVerbHandlerModule
|
|||||||
{
|
{
|
||||||
$fave = new Fave();
|
$fave = new Fave();
|
||||||
$fave->user_id = $profile->id;
|
$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->free();
|
||||||
|
|
||||||
Fave::blowCacheForProfileId($profile->id);
|
Fave::blowCacheForProfileId($profile->id);
|
||||||
|
@ -137,8 +137,6 @@ class Fave extends Managed_DataObject
|
|||||||
$result = null;
|
$result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->find()) {
|
|
||||||
while ($this->fetch()) {
|
|
||||||
$profile = $this->getActor();
|
$profile = $this->getActor();
|
||||||
$notice = $this->getTarget();
|
$notice = $this->getTarget();
|
||||||
|
|
||||||
@ -149,8 +147,6 @@ class Fave extends Managed_DataObject
|
|||||||
Event::handle('EndDisfavorNotice', [$profile, $notice]);
|
Event::handle('EndDisfavorNotice', [$profile, $notice]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NoResultException $e) {
|
} catch (NoResultException $e) {
|
||||||
// In case there's some inconsistency where the profile or notice was deleted without losing the fave db entry
|
// In case there's some inconsistency where the profile or notice was deleted without losing the fave db entry
|
||||||
common_log(LOG_INFO, '"'.get_class($e->obj).'" with id=='.var_export($e->obj->id, true).' object not found when deleting favorite, ignoring...');
|
common_log(LOG_INFO, '"'.get_class($e->obj).'" with id=='.var_export($e->obj->id, true).' object not found when deleting favorite, ignoring...');
|
||||||
|
Loading…
Reference in New Issue
Block a user