[Favorite] Fix "Properly trigger DisfavorNotice on profile deletion"

Calling find() inside delete() is probably not a good idea.
This commit is contained in:
Alexei Sorokin
2020-08-04 13:23:31 +03:00
parent a9c365a5eb
commit ab4120721f
2 changed files with 14 additions and 11 deletions

View File

@@ -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) {