From 2283c94a22a2b805a3fca4136c8586bdd0196a87 Mon Sep 17 00:00:00 2001 From: Whykioh Date: Sun, 12 Jul 2026 21:23:04 +0200 Subject: [PATCH] Fix remove/mark-watched not working on common-list movies getLists() returned the common list via MAX(id) grouped across both users' rows, so the id handed back could belong to either partner. remove()/markWatched() scope by (id, user_id), so whenever it picked the partner's id, the query silently matched zero rows while still reporting success. Now each user's own is_common=1 rows are returned directly, so the id is always theirs. Also fixes the frontend never recognizing common movies as "already added" (see watchgether-web). Co-Authored-By: Claude Sonnet 5 --- models/Movie.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/models/Movie.php b/models/Movie.php index 3979bf7..6dac8e4 100644 --- a/models/Movie.php +++ b/models/Movie.php @@ -63,13 +63,11 @@ class Movie { } // 3. Commune - $stmt = $this->db->prepare(" - SELECT MAX(id) as id, tmdb_id, title, poster_path, media_type, is_common, MAX(added_at) as added_at - FROM movies - WHERE is_common = 1 AND (user_id = ? OR user_id = ?) - GROUP BY tmdb_id, title, poster_path, media_type, is_common - "); - $stmt->execute([$myId, $partnerId]); + // On renvoie MA propre ligne (pas une fusion avec celle du/de la partenaire) : + // chacun a sa propre ligne is_common=1 pour le même film, et remove/mark-watched + // ont besoin de MON id pour agir sur MA ligne, pas une autre. + $stmt = $this->db->prepare("SELECT * FROM movies WHERE user_id = ? AND is_common = 1 ORDER BY added_at DESC"); + $stmt->execute([$myId]); $common = $stmt->fetchAll(PDO::FETCH_ASSOC); return ["perso" => $perso, "partner" => $partner, "common" => $common];