Skip to content

Commit

Permalink
Avoid 500 when adding player to an event that is already entered but …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
bakert committed Nov 26, 2024
1 parent ce8084e commit ff1c39e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gatherling/Models/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ff1c39e

Please sign in to comment.