-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 json encode null #120
base: master
Are you sure you want to change the base?
Fix json encode null #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this, but I think it would make sense to simplify the surrounding logic a little while already at it:
public function handle(SettingsRepositoryInterface $settings, Dispatcher $dispatcher)
{
$autoAssignGroups = $settings->get('fof-gamification.autoAssignedGroups');
// If the setting is missing or empty, or if the subject user is an admin, we can skip this job
if (empty($autoAssignGroups) || $this->user->isAdmin()) {
return;
}
$entries = json_decode($autoAssignGroups, true);
..
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @datlechin!
@DavideIadeluca if you want to do an optimization, although just a slight one, stop early instead of accessing the settings repository first (which you then don't need for an admin): if ($this->user->isAdmin()) return;
return json_decode(
$settings->get('fof-gamification.autoAssignGroups', '[]'),
true
); |
Yeah right, makes sense. @datlechin Can you please use the suggestion of @luceos instead? 🙏 |
Fix json encode null in php8.3
Fixes #0000
Changes proposed in this pull request:
Reviewers should focus on:
Screenshot
Confirmed
composer test
).Required changes: