Skip to content

Commit

Permalink
[B] Like deleted callback triggered even if there is no likes #1643
Browse files Browse the repository at this point in the history
  • Loading branch information
lianglee committed Jan 30, 2020
1 parent 7ecb3b3 commit d0a1f24
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions components/OssnLikes/classes/OssnLikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,22 @@ public function deleteLikes($subject_id, $type = 'post') {
if(empty($subject_id) || empty($type)) {
return false;
}
$this->statement("DELETE FROM ossn_likes WHERE(subject_id='{$subject_id}' AND type='{$type}');");
if($this->execute()) {
$vars = array();
$vars['subject_id'] = $subject_id;
$vars['type'] = $type;
ossn_trigger_callback('like', 'deleted', $vars);
return true;
//[B]Like deleted callback triggered even if there is no likes #1643
$likes = $this->GetLikes($subject_id, $type);
if($likes){
$this->statement("DELETE FROM ossn_likes WHERE(subject_id='{$subject_id}' AND type='{$type}');");
if($this->execute()) {
$vars = array();
$vars['subject_id'] = $subject_id;
$vars['type'] = $type;
ossn_trigger_callback('like', 'deleted', $vars);
return true;
}
}
return false;
}
/**
* Delte likes by user guid
* Delete likes by user guid
*
* @params integer $owner_guid Guid of user
*
Expand Down

0 comments on commit d0a1f24

Please sign in to comment.