• 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
.claude Loading commit data...
ChessPieces Loading commit data...
Connections and docs Loading commit data...
Logo El3ab Loading commit data...
admin Loading commit data...
api Loading commit data...
app icons Loading commit data...
config Loading commit data...
docs Loading commit data...
includes Loading commit data...
ludo-playtest Loading commit data...
promo Loading commit data...
public Loading commit data...
screenshots Loading commit data...
test-screenshots Loading commit data...
.gitignore Loading commit data...
.htaccess Loading commit data...
ARCHITECTURE.md Loading commit data...
ASSET_REGISTRY.json Loading commit data...
ASSET_REGISTRY.md Loading commit data...
BUILD_ORDER.md Loading commit data...
DATABASE_REFERENCE.md Loading commit data...
DESIGN.md Loading commit data...
Dockerfile Loading commit data...
MULTIPLAYER_RULES.md Loading commit data...
PLAN.md Loading commit data...
Stockfishbotsapi.txt Loading commit data...
backgammon-test.mjs Loading commit data...
bell.png Loading commit data...
captain-definition Loading commit data...
index.php Loading commit data...
logof.png Loading commit data...
manifest.json Loading commit data...
package-lock.json Loading commit data...
package.json Loading commit data...
privacy-policy.php Loading commit data...
qr-code.png Loading commit data...
terms.php Loading commit data...
test-tournament-swiss.mjs Loading commit data...
test-tournament-ui.mjs Loading commit data...