Fix server processing of wp-context getting out of sync#55436
Fix server processing of wp-context getting out of sync#55436luisherranz merged 2 commits intotrunkfrom
wp-context getting out of sync#55436Conversation
|
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/experimental/interactivity-api/class-wp-directive-context.php ❔ lib/experimental/interactivity-api/directives/wp-context.php ❔ phpunit/experimental/interactivity-api/directives/wp-context-test.php |
|
Flaky tests detected in f341fc1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6558724095
|
DAreRodz
left a comment
There was a problem hiding this comment.
The code looks good to me. Approved!
PS: There's a thing that worries me: this is supposed to fail only when the content of wp-context is not valid. Are we generating an invalid context somewhere, or could it be a different issue this time? 🤔
|
For now, let's cover invalid contexts. If more problems arise, we'll check them out 🙂 Thanks for the quick review, David! 🎉 |
|
👋 Hey! Checking if this PR should be included in 6.4 - if so, we should add the |
|
Hey @mikachan. No, this part is still experimental and it's not included in the 6.4 release. |
What?
Fix a problem where the internal stack of contexts could get out of sync when the JSON is not valid during the server processing of
wp-context.Why?
As spotted by @DAreRodz here, the internal stack of contexts can get out of sync when a call to
set_contextfails.How?
Make sure that we're always adding a new
arrayto the stack, even if the JSON is not valid.Testing Instructions
This is covered by a unit test, but if you want to test it out:
wp-contextdirective.wp-contextand invalid JSONs.