Repository navigation
Conversation
When no preference is stored for a user, getPreference now returns false instead of null. This fixes an issue where user preferences would have inverted values displayed in checkboxes. BREAKING CHANGE: Code that relied on the previous default value of null may need adjustment. Users should audit their code that calls getPreference without an explicit default parameter.
Adjust assertions to expect false instead of null when no preference is stored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When no preference is stored for a user and a given key,
getPreference()returnednullas the default. This caused an inconsistency with checkbox form inputs:false(unchecked, opt-out by default)trueby default in templates, but returnsnullfrom codeAdditionally, the form field value and the database value were inverted:
falseSolution
Changed the default return value in
getPreference()fromnulltofalse. This ensures consistent behavior where:false(opt-out by default)true=true(explicitly opted-in)false=false(explicitly opted-out)Breaking Change Warning⚠️
This is a breaking change for any code that:
getPreference()without an explicit default parameternullto be returned when no preference is storedRecommendation: Review all code calling
getPreference()and explicitly pass a default value if the previous behavior was intentional. This is especially important for applications with existing user preference data.Related
This fix works in conjunction with the fix to rainlab/vanilla-theme for the promotional emails checkbox.
🤖 Generated with Claude Code