Skip to content

Commit

Permalink
fix(match2): opponent extradata is empty array instead of null (#4548)
Browse files Browse the repository at this point in the history
* fix(match2): Prevent bad (array) serialization of opponent extradata

* linter...

* move the check to storage & add same check for match2player data

---------

Co-authored-by: hjpalpha <[email protected]>
  • Loading branch information
mbergen and hjpalpha authored Aug 16, 2024
1 parent 1ff72ce commit 4d68ec9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/match2/commons/match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,18 @@ function Match._storeMatch2InLpdb(unsplitMatchRecord)

local opponentIndexes = Array.map(records.opponentRecords, function(opponentRecord, opponentIndex)
local playerIndexes = Array.map(records.playerRecords[opponentIndex], function(player, playerIndex)

player.extradata = Logic.nilIfEmpty(player.extradata)

return mw.ext.LiquipediaDB.lpdb_match2player(
matchRecord.match2id .. '_m2o_' .. string.format('%02d', opponentIndex)
.. '_m2p_' .. string.format('%02d', playerIndex),
player
)
end)

opponentRecord.extradata = Logic.nilIfEmpty(opponentRecord.extradata)

opponentRecord.match2players = table.concat(playerIndexes)
return mw.ext.LiquipediaDB.lpdb_match2opponent(
matchRecord.match2id .. '_m2o_' .. string.format('%02d', opponentIndex),
Expand Down

0 comments on commit 4d68ec9

Please sign in to comment.