Fix: Allow empty strings for event settings maps_url #623
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Allow empty strings for event settings maps_url
Problem
Users were unable to save empty values for the maps URL field in event settings. When attempting to clear an existing maps URL, the system would ignore the empty value and revert to the previously saved URL upon save.
Fixes 🐛 Cannot save empty maps URL in event settings #624
Cause
The issue occurred in the
PartialUpdateEventSettingsHandler.php
file where themaps_url
field was being handled using the null coalescing operator (??
):In PHP, this operator treats empty strings as falsy values, causing the system to fall back to the existing value when users attempted to save an empty string.
Solution
Updated the code to use
array_key_exists()
instead of the null coalescing operator, matching the pattern already used for other text fields in the same handler:This approach checks if the key exists in the settings array (regardless of its value), allowing empty strings to be properly saved.
Impact
Event organizers can now:
This change improves the user experience for event organizers who need to manage location settings for their events.
Checklist
Thank you for your contribution! 🎉