fix: eliminate jsonb double-encoding that broke multiplayer sync
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:
Claude Opus 4.6 <noreply@anthropic.com>
Showing
Please register or sign in to comment