Commit b95c3bce authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: tiebreak_rules is already decoded array from Supabase JSONB

Supabase returns JSONB columns as native arrays, not JSON strings.
json_decode() on an array throws TypeError. Now checks if already array.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 50f492d2
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* Tiebreak configuration with drag-to-reorder * Tiebreak configuration with drag-to-reorder
* Expects: $tournament * Expects: $tournament
*/ */
$currentTiebreaks = json_decode($tournament['tiebreak_rules'] ?? '["buchholz_cut_1","buchholz","sonneborn_berger"]', true); $rawTiebreaks = $tournament['tiebreak_rules'] ?? '["buchholz_cut_1","buchholz","sonneborn_berger"]';
$currentTiebreaks = is_array($rawTiebreaks) ? $rawTiebreaks : (json_decode($rawTiebreaks, true) ?? ['buchholz_cut_1', 'buchholz', 'sonneborn_berger']);
$availableTiebreaks = [ $availableTiebreaks = [
'buchholz' => 'Buchholz', 'buchholz' => 'Buchholz',
'buchholz_cut_1' => 'Buchholz Cut 1', 'buchholz_cut_1' => 'Buchholz Cut 1',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment