• Mahmoud Aglan's avatar
    fix: eliminate jsonb double-encoding that broke multiplayer sync · 6517bd2d
    Mahmoud Aglan authored
    The root cause: PHP's json_encode() was used on jsonb fields before
    passing to SupabaseClient->insert/update, which json_encodes the entire
    payload. This double-encoded game_state into a JSON string scalar.
    
    When the match_heartbeat RPC did `jsonb_string || jsonb_object`,
    PostgreSQL created an array instead of merging, corrupting game_state.
    The polling logic then couldn't find move_count or last_move in the
    array, so moves never synced between players.
    
    Fix: pass PHP arrays directly for all jsonb columns (game_state, moves,
    positions, scores, winners, hands, boneyard). The Supabase client
    handles encoding once at the HTTP layer.
    
    Also: when reading game_state back from the DB, handle the case where
    PostgREST returns it as a decoded array/object (not a string) since
    jsonb columns are deserialized automatically.
    
    Affected: chess, ludo, domino — all multiplayer match creation and
    move/state updates.
    Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    6517bd2d
Name
Last commit
Last update
..
achievements.php Loading commit data...
activity.php Loading commit data...
ads.php Loading commit data...
analysis.php Loading commit data...
auth.php Loading commit data...
avatar.php Loading commit data...
backgammon-match.php Loading commit data...
battlepass.php Loading commit data...
bots.php Loading commit data...
branding.php Loading commit data...
challenges.php Loading commit data...
chat.php Loading commit data...
config.php Loading commit data...
daily-reward.php Loading commit data...
domino-match.php Loading commit data...
domino.php Loading commit data...
friends.php Loading commit data...
game.php Loading commit data...
groups.php Loading commit data...
leaderboard.php Loading commit data...
ludo-match.php Loading commit data...
ludo.php Loading commit data...
match-cleanup.php Loading commit data...
match-history.php Loading commit data...
matchmaking.php Loading commit data...
multiplayer.php Loading commit data...
notifications.php Loading commit data...
org-apply.php Loading commit data...
orgs.php Loading commit data...
profile.php Loading commit data...
puzzles.php Loading commit data...
ratings.php Loading commit data...
shop.php Loading commit data...
swiss.php Loading commit data...
theme.php Loading commit data...
tournament-match.php Loading commit data...
tournaments.php Loading commit data...