Skip to content

Commit ace4450

Browse files
committed
delete all locks for post for delete by post id
1 parent 2f64bca commit ace4450

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Ushahidi/Modules/V5/Actions/Post/Handlers/UpdatePostLockCommandHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function updatePostLock($post_id)
4343
// if user can break the lock "has admin role" then release the old lock if it from other user
4444
// If the lock is inactive and the lock is not for current user release old one and create new one
4545

46-
$this->setCurrentPostLock($post_id);
46+
$this->getCurrentPostLock($post_id);
4747

4848
if ($this->current_post_lock) {
4949
if (($this->lockIsBreakable()) || (!$this->currentLockIsActive() && !$this->userOwnsCurrentLock())) {
@@ -76,7 +76,7 @@ private function userOwnsCurrentLock()
7676
$user = Auth::user();
7777
return intval($user->id) === intval($this->current_post_lock->user_id);
7878
}
79-
private function setCurrentPostLock($post_id): void
79+
private function getCurrentPostLock($post_id): void
8080
{
8181
try {
8282
$this->current_post_lock = $this->post_lock_repository->findByPostId($post_id);

src/Ushahidi/Modules/V5/Repository/Post/EloquentPostLockRepository.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public function deleteById(int $id): void
3838
}
3939
public function deleteByPostId(int $post_id): void
4040
{
41-
$this->findByPostId($post_id)->delete();
41+
$post_locks = PostLock::where('post_id', '=', $post_id)->get();
42+
foreach ($post_locks as $post_lock) {
43+
$post_lock->delete();
44+
}
4245
}
4346
public function deleteByUserId(int $user_id): void
4447
{

0 commit comments

Comments
 (0)