From 6fb779e5847d131ad5e16ec6d5f8224acc5a8101 Mon Sep 17 00:00:00 2001 From: corentin-soriano Date: Wed, 18 Sep 2024 15:34:24 +0200 Subject: [PATCH] Fix favorites remove issue. --- sources/favourites.queries.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sources/favourites.queries.php b/sources/favourites.queries.php index 1325b37c0..aa23f5a9d 100755 --- a/sources/favourites.queries.php +++ b/sources/favourites.queries.php @@ -104,19 +104,8 @@ //Get actual favourites $data = DB::queryfirstrow('SELECT favourites FROM '.prefixTable('users').' WHERE id = %i', $session->get('user-id')); $tmp = explode(';', $data['favourites']); - $favorites = ''; - $arrayFavorites = array(); - //redefine new list of favourites - foreach ($tmp as $favorite) { - if (!empty($favorite) && $favorite != $post_id) { - if (empty($favorites)) { - $favorites = $favorite; - } else { - $favorites = ';'.$favorite; - } - array_push($arrayFavorites, $favorite); - } - } + $arrayFavorites = array_diff($tmp, [$post_id]); + //update user's account DB::update( prefixTable('users'),