Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BuildTicketCreationDataAction): deduplicate emulators #3236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/Platform/Actions/BuildTicketCreationDataAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ private function addInactiveEmulators(Collection &$emulators, Achievement $achie
if ($needsOther) {
$emulators->add(new EmulatorData(0, 'Other (please specify in description)'));
}

// Deduplicate without needing to normalize decoded client strings.
$emulators = $emulators->unique('name');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am able to reproduce this by changing some data in the DB and then trying to create a ticket.

update player_sessions set user_id=[me] where game_id=22308 and user_id=13448;
update player_games set user_id=[me] where game_id=22308 and user_id=13448;

http://localhost:64000/achievement/285575/tickets/create?type=2

The problem is the contains check on line 82 is case sensitive. The DB contains "Bizhawk" as an emulator, but the User-Agent is "BizHawk". We should probably update the DB to be "BizHawk", but there's going to be a secondary issue with the new "EmuHawk" user agent. I think the correct solution is to double check the collection after resolving the emulator:

if (!$emulators->contains('name', $decoded['client'])) {
    $emulatorUserAgent = EmulatorUserAgent::firstWhere('client', $decoded['client']);
    if (!$emulatorUserAgent) {
        $needsOther = true;
    } else if (!$emulators->contains('name', $emulatorUserAgent->emulator->name)) { // <---
        $emulators->add(EmulatorData::fromEmulator($emulatorUserAgent->emulator));
    }
}

}

/**
Expand Down