// check if game is in database
if($this->isGameInDB($GBID))
{
// get game from database
if($this->getGameFromDatabase($GBID, $userID))
// game found
return true;
}
isGameInDB returns true if more than zero records exist in the database. getGameFromDatabase fails if it doesn't find one record. A duplicate entry in the database will cause isGameInDB to be true, but getGameFromDatabase to fail, causing the code to fall through and add another entry to the database.
Fix this by erroring out if getGameFromDatabase fails.
There is a flaw in this logic: https://github.com/Clidus/gwl/blob/master/ignition_application/models/game.php#L40
isGameInDB
returns true if more than zero records exist in the database.getGameFromDatabase
fails if it doesn't find one record. A duplicate entry in the database will causeisGameInDB
to be true, butgetGameFromDatabase
to fail, causing the code to fall through and add another entry to the database.Fix this by erroring out if
getGameFromDatabase
fails.