From ff1c39eea2b150d3eb7f5fb7ff9cb87d444f058c Mon Sep 17 00:00:00 2001 From: Thomas David Baker Date: Tue, 26 Nov 2024 15:47:42 -0800 Subject: [PATCH] Avoid 500 when adding player to an event that is already entered but has no deck There's no reason to 500 here and in fact this is a regression. This method used to look for num_rows > 0 rather than requiring an entry for deck. I just messed it up when cutting it across to new db style. --- gatherling/Models/Entry.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gatherling/Models/Entry.php b/gatherling/Models/Entry.php index b5e761f46..e45cefe7a 100644 --- a/gatherling/Models/Entry.php +++ b/gatherling/Models/Entry.php @@ -48,10 +48,10 @@ public function __construct(int $event_id, string $playername) public static function findByEventAndPlayer(int $event_id, string $playername): ?self { - $sql = 'SELECT deck FROM entries WHERE event_id = :event_id AND player = :player'; + $sql = 'SELECT player FROM entries WHERE event_id = :event_id AND player = :player'; $params = ['event_id' => $event_id, 'player' => $playername]; - $deckId = db()->optionalInt($sql, $params); - if (!$deckId) { + $player = db()->optionalString($sql, $params); + if (!$player) { return null; } return new self($event_id, $playername);