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 client error retrieving softcore unlocks with aggregate queries on #1919

Merged
merged 2 commits into from
Oct 21, 2023

Conversation

Jamiras
Copy link
Member

@Jamiras Jamiras commented Oct 15, 2023

'DateEarnedHardcore' => $unlock->unlocked_hardcore_at?->format('Y-m-d H:i:s'),

would return a null entry for DateEarnedHardcore, whereas the non-aggregate code does not populate the key. This caused the filtering code for the unlocks and startsession requests to not produce the desired results.

RAWeb/public/dorequest.php

Lines 392 to 394 in c0fa537

$response['UserUnlocks'] = collect($userUnlocks)
->filter(fn ($value, $key) => array_key_exists('DateEarnedHardcore', $value))
->keys();

RAWeb/public/dorequest.php

Lines 325 to 335 in c0fa537

if (array_key_exists('DateEarnedHardcore', $unlock)) {
$response['HardcoreUnlocks'][] = [
'ID' => $achId,
'When' => strtotime($unlock['DateEarnedHardcore']),
];
} else {
$response['Unlocks'][] = [
'ID' => $achId,
'When' => strtotime($unlock['DateEarned']),
];
}

In fact, the strtotime call would change the value from null to false resulting in unparseable timestamps for the client.

{"Success":true,"HardcoreUnlocks":[{"ID":361917,"When":false},{"ID":361918,"When":false},{"ID":361919,"When":false},
{"ID":361921,"When":false},{"ID":361922,"When":false},{"ID":361924,"When":false},{"ID":361925,"When":false},
{"ID":361928,"When":false},{"ID":361931,"When":false}],"ServerNow":1697396485}

@luchaos luchaos merged commit 2d2bd81 into RetroAchievements:master Oct 21, 2023
5 checks passed
@Jamiras Jamiras deleted the aggregate_unlocks branch November 4, 2023 14:12
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.

2 participants