Repository navigation
Conversation
Wpcom_Feature_Flags memoized the override map on the first resolution and kept it for the rest of the request, even after switch_to_blog(). On WordPress.com's public API a flag is resolved before the request switches to the requested site, so that site's overrides never applied to its REST responses. Drop the cache on switch_blog and pin it with a test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
2143e7b to
ca77ba2
Compare
|
Superseded by #52558, which keys the cache by blog instead of resetting on |
Proposed changes
Wpcom_Feature_Flagsmemoizes a site's flag overrides in a static property the first time any flag is resolved, and never re-reads them. On WordPress.com Simple, the public API process resolves flags before it switches to the requested site (premium-analytics-dashboard-compositionis checked oninit, for one), so the map memoized then is the process's first blog, not the site the request is for. Every override set on Tools → Feature Flags therefore applies in that site's wp-admin but not to itswpcom/v2REST responses, which is where a Premium Analytics dashboard reads its sections from.switch_blog, so the next resolution reads the current blog's option.switch_blog, and expects the new value. The bootstrap-wiring test now also checks theswitch_bloghook.Found while testing #52549 on a Simple site: with
premium-analytics-a11n-all-sectionsforced on, the Feature Flags screen reported it effective, yetGET /wpcom/v2/sites/…/dashboards/…/sectionskept returning the preview's two tabs. Running the same resolution in the sandbox CLI reproduced it:falseafterswitch_to_blog(),trueafterreset_overrides_cache().Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Automated:
jp test php packages/jetpack-mu-wpcom --filter Wpcom_Feature_FlagsOn a WordPress.com Simple sandbox, with a site whose Premium Analytics preview is switched on through its own opt-in and no
jetpack-premium-analyticsoverride (Traffic and Insights only), and with #52549 applied:public-api.wordpress.com.premium-analytics-a11n-all-sectionson, and save.https://public-api.wordpress.com/wpcom/v2/sites/<blog-id>/dashboards/jetpack-premium-analytics_dashboard/sectionsfrom the dashboard (or copy the request the tab bar makes).trafficandinsights. With this PR, it lists every section the site qualifies for, and the dashboard's tab bar follows.🤖 Generated with Claude Code