Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code review for 6.1.1 global stylesheet invalidation testing plugin #1

Merged
merged 11 commits into from
Dec 7, 2022

Conversation

ironprogrammer
Copy link
Owner

@ironprogrammer ironprogrammer commented Dec 7, 2022

Creates a testing plugin to address issue described in Trac 56970.

Why a testing plugin?

Because the issue occurs after upgrade from WordPress 5.9/6.0 to 6.1.1 specifically, is hard to reproduce. Making a plugin available to the community allows for easier testing to validate whether this approach is works. If this plugin is found to address the reported issue, then the implementation may be adapted in an upcoming minor release.

Details

  • Runs under WordPress 6.1.1.
  • Hooks the transient_$transient_name filter to invalidate the cache for `'global_styles_'.
  • Only runs the hook once. This is sufficient to force regeneration of the global stylesheet, which is subsequently cached.

Note that this is a different approach from that proposed in wp-hotfix-56970/pull/1. While the other plugin does resolve the issue in local controlled testing, it also introduces caching changes from Gutenberg to Core that should ideally ship with the next major after the code has had more time to bake in Gutenberg. 43%.

Testing

Tested with 5.9 and 6.0, and addresses issue described per the testing instructions.

More testing is needed by the community in different hosting environments, to determine whether it works when external caching is at play.

Invalidation works with any "global_styles_<stylesheet>" name.
Makes `wp_get_global_stylesheet()` rebuild global styles.
@azaozz
Copy link

azaozz commented Dec 7, 2022

LGTM, good job!

@ironprogrammer ironprogrammer merged commit 183944d into main Dec 7, 2022
@ironprogrammer ironprogrammer deleted the code-review branch December 7, 2022 21:50
Copy link
Collaborator

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

I've tested this PR.
I installed this plugin, and updated WP 5.9.5 to 6.1.1 using the update button in the admin area.
The issue is that the wp_test_56970_transient_global_styles_stylesheet() callback function doesn't get called during the upgrade process (or later).
Are there any steps/prerequisites to make this work?

@ironprogrammer
Copy link
Owner Author

Thanks, @anton-vlasenko -- yes, the steps to test can be found here.

The global stylesheet transient is loaded on the frontend or in the editor, so the hook should only fire the first time either of those are loaded. Caching must not be disabled (e.g. WP_DEBUG must not be enabled).

@anton-vlasenko
Copy link
Collaborator

anton-vlasenko commented Dec 8, 2022

Thanks, @anton-vlasenko -- yes, the steps to test can be found here.

The global stylesheet transient is loaded on the frontend or in the editor, so the hook should only fire the first time either of those are loaded. Caching must not be disabled (e.g. WP_DEBUG must not be enabled).

Thanks, @ironprogrammer.
I've just tested it again and it worked.
Maybe it didn't work for me before because I was on the "Twenty Twenty Two" theme.
Anyway, I confirm that the plugin works as intended.
Great job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants