[Favorite] Fix "Properly trigger DisfavorNotice on profile deletion"
Calling find() inside delete() is probably not a good idea.
This commit is contained in:
parent
a9c365a5eb
commit
ab4120721f
@ -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,18 +137,14 @@ class Fave extends Managed_DataObject
|
|||||||
$result = null;
|
$result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->find()) {
|
$profile = $this->getActor();
|
||||||
while ($this->fetch()) {
|
$notice = $this->getTarget();
|
||||||
$profile = $this->getActor();
|
|
||||||
$notice = $this->getTarget();
|
|
||||||
|
|
||||||
if (Event::handle('StartDisfavorNotice', [$profile, $notice, &$result])) {
|
if (Event::handle('StartDisfavorNotice', [$profile, $notice, &$result])) {
|
||||||
$result = parent::delete($useWhere);
|
$result = parent::delete($useWhere);
|
||||||
|
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
Event::handle('EndDisfavorNotice', [$profile, $notice]);
|
Event::handle('EndDisfavorNotice', [$profile, $notice]);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NoResultException $e) {
|
} catch (NoResultException $e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user