[wp-trac] [WordPress Trac] #59111: A stale register_core_block_style_handles cache can cause styles not to load

WordPress Trac noreply at wordpress.org
Tue Aug 15 16:37:12 UTC 2023


#59111: A stale register_core_block_style_handles cache can cause styles not to
load
--------------------------+-------------------------
 Reporter:  joemcgill     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  6.4
Component:  Themes        |    Version:  6.3
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:  performance   |
--------------------------+-------------------------
 In [56044], a transient caching strategy was added to
 `register_core_block_style_handles` to avoid expensive file operations for
 core block styles. However, this can cause styles for blocks to not get
 registered if the normalized path for those assets change after the
 transient is saved.

 To reproduce with the Twenty Twenty-three theme:

 1. Make sure the transient is deleted: `npm run env:cli wp transient
 delete wp_core_block_css_files`
 2. Make sure `WP_DEVELOPMENT_MODE` is not set to 'core'
 3. Set `LOCAL_DIR=src` in `.env`
 4. Build and start the environment `npm run build:develop && npm run
 env:start`
 5. Load the homepage in your browser (styles should all be loaded)
 6. Set `LOCAL_DIR=build` in `env` to switch to the build folder
 7. Build and restart the environment `npm run build && npm run
 env:restart`
 8. Refresh the homepage in your browser and see styles for the navigation
 block is not loaded
 9. Set `WP_DEVELOPMENT_MODE` to `core` to see that the problem goes away.

 A few options to consider here:

 1. We could skip the transient if we determine the site is running in any
 development mode, not just core.
 2. Rewrite the `in_array` check for relative paths based on the blocks
 directory, rather than the full normalized file path

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59111>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list