Clidus / gwl

Video game collection, wishlist and backlog tracker.
https://www.gamingwithlemons.com/
MIT License
18 stars 6 forks source link

Duplicate game entry produces more duplicate entries #114

Open Clidus opened 6 years ago

Clidus commented 6 years ago

There is a flaw in this logic: https://github.com/Clidus/gwl/blob/master/ignition_application/models/game.php#L40

        // 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.