-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Ticket/53566 #2313
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
base: trunk
Are you sure you want to change the base?
Ticket/53566 #2313
Conversation
|
Sorry this took so long to get to @Neychok! Could you refresh this PR against the current state of |
|
@desrosj, just refreshed it. Thank you for looking into this! |
src/wp-includes/blocks.php
Outdated
| ) | ||
| ); | ||
| if ( ! file_exists( $script_asset_path ) ) { | ||
| if ( false === $script_asset_path ) { |
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.
Also commented on the ticket, but it appears my initial suggestion to use a false === $script_asset_path comparison was incorrect. While realpath() returns explicit false when a file does not exist, wp_normalize_path() will return an empty string when passed false. Seems an empty() check would be more appropriate.
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.
src/wp-includes/blocks.php
Outdated
| /* translators: 1: Field name, 2: Block name. */ | ||
| __( 'The asset file for the "%1$s" defined in "%2$s" block definition is missing.' ), | ||
| __( 'The asset file (%1$s) for the "%2$s" defined in "%3$s" block definition is missing.' ), | ||
| dirname( $metadata['file'] ) . '/' . substr_replace( $script_path, '.asset.php', - strlen( '.js' ) ), |
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.
Could we avoid having to do this twice? A third variable in addition to $script_handle, and $script_asset_path could store the result of this line before passing to wp_normalize_path( realpath() )above and then to the_doing_it_wrong()`.
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.
I agree. 749efcf stores the result in a variable for reuse.
src/wp-includes/blocks.php
Outdated
| _doing_it_wrong( | ||
| __FUNCTION__, | ||
| sprintf( | ||
| /* translators: 1: Field name, 2: Block name. */ |
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.
The translator comment needs to be updated to correctly describe all three placeholders.
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.
Done in 9a48f68 ✅
|
Working as expected, no fatal error occured. |
Added asset file path in
_doing_it_wrong()notice inregister_block_script_handle()Changed the
! file_exists()check to! file_exists( $script_asset_pathas suggested by desrosjTrac ticket: https://core.trac.wordpress.org/ticket/53566