Timezone field not required in blueprint #121
Merged
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.
This PR closes #118 and introduces fixes and improvements to how the computed
timezonefield is handled.🐛 Bug 1: Unaugmented Raw Value
Problem
If the blueprint doesn't contain a
timezonefield, but the entry has atimezonevalue, the computed field would return the raw$valuedirectly. This bypasses augmentation and could lead to unexpected behavior.Solution
Before returning an existing
$value, we now check if the blueprint has atimezonefieldtype that can handle augmentation.$valueas-is (it will be properly augmented).timezonefield on the fly and return the augmented value.🐛 Bug 2: Double
value()CallProblem
Calling
value()twice causes the raw value to be set to the augmented value, which is unintended behavior.statamic-events/src/ServiceProvider.php
Lines 101 to 105 in 75741b5
Solution
Ensure
value()is only called once.✨ Other Improvements
timezonefield on the fly is now simpler and no longer requires the field to exist in the blueprint.timezonefield from the blueprint entirely if they don’t want to store the timezone value.visibility: hiddento the blueprint field instead.