-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add utils to the wp-data script dependencies. #10384
Conversation
The `wp-data` inline script relies on `window.userSettings.uid`, a property set in the `utils` script. Fixes #10102
lib/client-assets.php
Outdated
@@ -246,6 +246,7 @@ function gutenberg_register_scripts_and_styles() { | |||
'wp-data', | |||
gutenberg_url( 'build/data/index.js' ), | |||
array( | |||
'utils', |
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.
Maybe we can use get_current_user_id
in the inline script to avoid loading another script just for a variable?
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.
@youknowriad the utils
script is a dependency for other scripts (/wp-includes/js/media-views.js
, /wp-admin/js/common.js
, /wp-admin/js/editor.js
) and will load anyway, it's just a matter of timing.
However, if the intention is to move away from older libraries, then using just get_current_user_id()
in the inline script makes sense.
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.
Gotcha, I think I have a small preference towards avoiding the dependency. Maybe at some point, these dependencies won't be needed anymore.
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.
Sounds good to me. I pushed up the change.
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 👍 Let's merge when the tests pass.
The
wp-data
inline script relies onwindow.userSettings.uid
, a property set in theutils
script.Fixes #10102
Description
Added
utils
as a script dependencies forwp-data
.How has this been tested?
Tested locally using WordPress
5.0-alpha-43661
and Gutenbergmaster
with HEAD at7ec834b77686c6b291ae1ee18fe5860714b58236
.Types of changes
This is a bug fix for #10102.
Checklist: