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

Add utils to the wp-data script dependencies. #10384

Merged
merged 3 commits into from
Oct 8, 2018

Conversation

kopepasah
Copy link
Member

@kopepasah kopepasah commented Oct 7, 2018

The wp-data inline script relies on window.userSettings.uid, a property set in the utils script.

Fixes #10102

Description

Added utils as a script dependencies for wp-data.

How has this been tested?

Tested locally using WordPress 5.0-alpha-43661 and Gutenberg master with HEAD at 7ec834b77686c6b291ae1ee18fe5860714b58236.

Types of changes

This is a bug fix for #10102.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

The `wp-data` inline script relies on `window.userSettings.uid`, a property set in the `utils` script.

Fixes #10102
@kopepasah kopepasah requested a review from aduth October 7, 2018 11:43
@@ -246,6 +246,7 @@ function gutenberg_register_scripts_and_styles() {
'wp-data',
gutenberg_url( 'build/data/index.js' ),
array(
'utils',
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@youknowriad youknowriad left a 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.

@youknowriad youknowriad added this to the 4.0 milestone Oct 8, 2018
@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label Oct 8, 2018
@youknowriad youknowriad merged commit 96ce333 into master Oct 8, 2018
@youknowriad youknowriad deleted the fix/10102-uncaught-typeerror branch October 8, 2018 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gutenberg 3.9: Uncaught TypeError: Cannot read property 'uid' of undefined
2 participants