Fix: SupportedOption::isSupportedValue() fails after Redis deserialization#213
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
c7587e1 to
56e3e26
Compare
56e3e26 to
9e5e0d5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #213 +/- ##
============================================
+ Coverage 87.41% 87.45% +0.03%
- Complexity 1189 1194 +5
============================================
Files 60 60
Lines 3846 3858 +12
============================================
+ Hits 3362 3374 +12
Misses 484 484
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
felixarntz
left a comment
There was a problem hiding this comment.
@chloe-pomegranate Thank you for the PR, this looks excellent and implements the most suitable solution suggested in #212.
Appreciate you jumping in on this!
@saarnilauri Would be great if you could double check that this addresses the bug you reported in #212. Thank you!
| * (e.g. Redis/Memcached object cache), where AbstractEnum singletons | ||
| * are reconstructed as separate instances. | ||
| * | ||
| * @since 1.2.1 |
There was a problem hiding this comment.
Just an FYI for any future contributions: We normally use @since n.e.x.t everywhere, so that we can dynamically inject the actual version prior to a release.
But since this coming release is indeed going to be 1.2.1, this is good as is 👍
@felixarntz I can confirm that the fix addresses the bug. Thank you so much both of you! |
Summary
SupportedOption::isSupportedValue()failing whenAbstractEnumsingletons are deserialized from a persistent object cache (Redis/Memcached)AbstractEnuminstances to their string->valuebefore comparison, so object identity (===) no longer breaks afterunserialize()Closes #212
Test plan
vendor/bin/phpunit --filter SupportedOptionTest— passingvendor/bin/phpcs --standard=phpcs.xml.dist src/Providers/Models/DTO/SupportedOption.php— cleanvendor/bin/phpstan analyse src/Providers/Models/DTO/SupportedOption.php— no errors