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

[4.x] Fix select fieldtype fallback differently #9087

Merged
merged 1 commit into from
Nov 30, 2023
Merged

Conversation

jasonvarga
Copy link
Member

This is an alternate solution of #9038.
The issue was that Arr::get will return only return the fallback if the key is completely missing.
In the bug's case, the key (the value) was there but the value (the label) was null.
This adjusts it to use a ?? so we always get the fallback and never null.

$arr = [
  'alfa' => 'Alfa',
  'bravo' => null,
];

Arr::get($arr, 'alfa', 'fallback'); // "Alfa"
Arr::get($arr, 'bravo', 'fallback'); // null - We were expecting "fallback"
Arr::get($arr, 'charlie', 'fallback'); // "fallback"

@jasonvarga jasonvarga merged commit 7a58ba3 into 4.x Nov 30, 2023
36 checks passed
@jasonvarga jasonvarga deleted the 9038-refactor branch November 30, 2023 00:16
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.

1 participant