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

Conversation

wescopeland
Copy link
Member

Resolves #3234.

Root Cause
I have never been able to repro this issue locally, but I can see how it would happen. Because emulator names are not normalized in addInactiveEmulators, subtle nuances in the decoded client string could plausibly cause a duplicate emulator to be inserted into the $emulators collection.

We could alternatively solve this issue in the front-end, but that feels too far downstream when it's technically a logic error in the back-end action.

@wescopeland wescopeland requested a review from a team February 22, 2025 22:01
@@ -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));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken emulator tab when reporting tickets while using BizHawk
2 participants