[wp-trac] [WordPress Trac] #58394: Performance of wp_maybe_inline_styles

WordPress Trac noreply at wordpress.org
Thu Jun 8 06:45:23 UTC 2023


#58394: Performance of wp_maybe_inline_styles
---------------------------+---------------------------
 Reporter:  spacedmonkey   |       Owner:  spacedmonkey
     Type:  enhancement    |      Status:  reopened
 Priority:  normal         |   Milestone:  6.3
Component:  Script Loader  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:  performance
---------------------------+---------------------------
Changes (by dd32):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 Just noting that this change has caused PHP Notices on WordPress.org. I'm
 unsure if this is a WordPress.org-specific oddity, or if it's a sign of
 something wider.

 {{{
 E_NOTICE: Undefined index: block-name-here in wp-includes/script-
 loader.php:2875
 E_NOTICE: Trying to get property 'src' of non-object in wp-includes
 /script-loader.php:2875
 }}}

 In short, `$wp_styles->registered[ $handle ]` is `false`, but the
 `$handle` is present within `$wp_styles->queue`.

 Previously this didn't throw a notice, as `wp_styles()->get_data( $handle,
 'path' )` returned false.

 I believe the trigger is this code:
 {{{
 add_filter( 'wp_enqueue_scripts', function() {
         wp_deregister_style( 'wporg-block-name' );
 }, 201 );
 }}}

 It appears that registering a style that is enqueued, doesn't actually
 dequeue the style, just removes the data and relies upon script-loader to
 skip over it when outputting on the page. It appears that `WP_Scripts`
 relies upon `WP_Dependencies::do_item()` to short-circuit when processing
 a no-longer-registered item:
 https://github.com/WordPress/wordpress-
 develop/blob/e8846318cf9a4c8d012ae32b4de9a51655237a24/src/wp-includes
 /class-wp-dependencies.php#LL159C1-L161C2

 re-opening this as a result.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58394#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list