Make WordPress Core

Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#59475 closed defect (bug) (fixed)

6.4 beta 1: Function WP_Scripts::add_data was called incorrectly.

Reported by: kebbet's profile kebbet Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.4 Priority: normal
Severity: normal Version: 6.4
Component: Editor Keywords: has-patch
Focuses: Cc:


Just updated to 6.4 beta 1, and got this warning with Query Monitor under the section ”Doing it wrong”, on both frontend and backend:

Function WP_Scripts::add_data was called incorrectly. 
Cannot supply a strategy `defer` for script `wp-block-image-view` 
because it is an alias (it lacks a `src` value). 
(This message was added in version 6.3.0.)

Call stack


Change History (7)

#1 @mukesh27
8 months ago

  • Keywords needs-testing added

Thanks @kebbet you beats on the reporting the issue.

This ticket was mentioned in PR #5320 on WordPress/wordpress-develop by @spacedmonkey.

8 months ago

  • Keywords has-patch added; needs-patch removed

#4 @swissspidy
8 months ago

  • Milestone changed from Awaiting Review to 6.4

#5 @mukesh27
8 months ago

  • Keywords needs-testing removed
  • Owner set to spacedmonkey
  • Status changed from new to assigned

@kebbet Could you please review the PR as its working for me.

#6 @spacedmonkey
8 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56744:

Editor: Avoid Deferring Loading for Empty Block Script URI

In the context of register_block_script_handle, the get_block_asset_url function may return false when an empty string is provided as the input. This behavior is intended to prevent the generation of invalid URLs. However, when the script loading strategy is set to "defer" while passing false, it triggers a "doing it wrong" message.

This situation becomes problematic, especially for scenarios where the scripts haven't been built yet. In such cases, the realpath call returns an empty string because the file doesn't exist. To address this issue, we now perform a simple check to ensure that the script URI is not empty before applying the "defer" loading strategy. This adjustment prevents unnecessary deferral of loading for scripts with empty URIs.

Follow on from [56683] and [56033].

Props kebbet, mukesh27, swissspidy, westonruter, spacedmonkey.
Fixes #59475

Note: See TracTickets for help on using tickets.