-
Notifications
You must be signed in to change notification settings - Fork 2k
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
New Page Layout Picker: refresh page pattern cache when site lang changes (round 2) #51122
New Page Layout Picker: refresh page pattern cache when site lang changes (round 2) #51122
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
The php unit tests are failing because of this issue in wp-env WordPress/gutenberg#29800 p1615778999014600-slack-C02DQP0FP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! And tested that it's using the site's language correctly (and that the fallback behaves as expected) 👍
Good to know about the issue during deployment and working around the priority for loading the common module. I suppose another approach / future enhancement could be moving some of the things out of common/index.php
that don't need to be deferred until plugins_loaded
has fired. I imagine a few of those functions (like get_is_639_locale
) could be defined outside of a hook, but that's a refactor outside the scope of this change, of course 🙂
Thanks for improving how the language is loaded and cached!
Ah thanks for that @andrewserong! I'll merge as is since it's tested now, but now that you mention it, moving Scratch that, I think I'm going to change approaches. Even after I do the cleanup PR and remove the 🙇 |
Perfect, thanks for following up with that @p-jackson! |
The page pattern cache was keyed on the account language. However the account language isn't used when making the request to get the page pattern data. Switching to the site's language (i.e. the same locale slug used when fetching pattern data) means the cache will be invalidated correctly.
e70391b
to
2f41e84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just gave it another quick smoke test 👍
Tré cool 🎉 Thanks for the help all |
This is round to after having to revert #51087 which caused fatals during deploy.
Changes proposed in this Pull Request
Update execution order to ensure theget_iso_639_locale()
function is available when__construct()
is calledProtect against fatals during deploy by not callingRefactor: Load ETK common code before theget_iso_639_locale()
if the host still has the old version offull-site-editing-plugin.php
that hasn't updated the execution orderplugins_loaded
action #51158 has taken care of these itemsAfter changing the site language the layout names and categories in the page layout picker still show in the previous language. And when the pattern is inserted it inserts the pervious language. You'd have to wait a day after updating the site language before the picker would fix itself.
The problem is the pattern data is cached using a key that includes the account language, not the site language. This change makes sure the cache key is using the exact same locale slug that's being used in the query to get pattern data.
Testing instructions
install-plugin.sh etk update/refresh-page-pattern-cache-on-site-lang-change
on sandbox