Script Loader: Add a check to see in style is registered in wp_maybe_inline_styles.

Add a check in `wp_maybe_inline_styles` to check that style is registered before processing items in queue. It is possible that developers may have called `wp_deregister_style`, unregistering style but the style still be in the queue to be processed. Without this check, typing to access the `src` property would result in a notice error. 

Follow on from [55888]. 

Props spacedmonkey, flixos90, dd32, kebbet.
See #58394.
Built from https://develop.svn.wordpress.org/trunk@55909


git-svn-id: http://core.svn.wordpress.org/trunk@55421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey 2023-06-13 09:53:23 +00:00
parent e2f7452084
commit c5f2ee51d9
2 changed files with 5 additions and 2 deletions

View File

@ -2872,8 +2872,11 @@ function wp_maybe_inline_styles() {
// Build an array of styles that have a path defined.
foreach ( $wp_styles->queue as $handle ) {
if ( ! isset( $wp_styles->registered[ $handle ] ) ) {
continue;
}
$src = $wp_styles->registered[ $handle ]->src;
$path = wp_styles()->get_data( $handle, 'path' );
$path = $wp_styles->get_data( $handle, 'path' );
if ( $path && $src ) {
$size = wp_filesize( $path );
if ( ! $size ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55908';
$wp_version = '6.3-alpha-55909';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.