Skip to content

Fix: SupportedOption::isSupportedValue() fails after Redis deserialization#213

Merged
felixarntz merged 2 commits intoWordPress:trunkfrom
chloe-pomegranate:fix/supported-option-deserialization
Feb 28, 2026
Merged

Fix: SupportedOption::isSupportedValue() fails after Redis deserialization#213
felixarntz merged 2 commits intoWordPress:trunkfrom
chloe-pomegranate:fix/supported-option-deserialization

Conversation

@chloe-pomegranate
Copy link
Copy Markdown
Contributor

Summary

  • Fixes SupportedOption::isSupportedValue() failing when AbstractEnum singletons are deserialized from a persistent object cache (Redis/Memcached)
  • Normalizes AbstractEnum instances to their string ->value before comparison, so object identity (===) no longer breaks after unserialize()
  • Adds tests verifying both scalar and array enum values survive serialize/unserialize round-trips

Closes #212

Test plan

  • vendor/bin/phpunit --filter SupportedOptionTest — passing
  • vendor/bin/phpcs --standard=phpcs.xml.dist src/Providers/Models/DTO/SupportedOption.php — clean
  • vendor/bin/phpstan analyse src/Providers/Models/DTO/SupportedOption.php — no errors
  • Verify on a WordPress site with Redis object cache that model discovery no longer fails after cache is populated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 27, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: chloe-pomegranate <chloepomegranate@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: saarnilauri <laurisaarni@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@chloe-pomegranate chloe-pomegranate force-pushed the fix/supported-option-deserialization branch from c7587e1 to 56e3e26 Compare February 27, 2026 16:06
@chloe-pomegranate chloe-pomegranate force-pushed the fix/supported-option-deserialization branch from 56e3e26 to 9e5e0d5 Compare February 27, 2026 16:08
@felixarntz felixarntz added the [Type] Bug An existing feature does not function as intended label Feb 28, 2026
@felixarntz felixarntz added this to the 1.2.1 milestone Feb 28, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.45%. Comparing base (eb1241f) to head (cc6f1fd).
⚠️ Report is 3 commits behind head on trunk.

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              
Flag Coverage Δ
unit 87.45% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 felixarntz merged commit 317b451 into WordPress:trunk Feb 28, 2026
9 checks passed
@saarnilauri
Copy link
Copy Markdown
Contributor

saarnilauri commented Mar 1, 2026

@saarnilauri Would be great if you could double check that this addresses the bug you reported in #212. Thank you!

@felixarntz I can confirm that the fix addresses the bug. Thank you so much both of you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

3 participants