Make WordPress Core


Ignore:
Timestamp:
09/19/2023 04:15:52 PM (21 months ago)
Author:
spacedmonkey
Message:

Themes: Improve performance of get_block_theme_folders function

This commit enhances the performance of the get_block_theme_folders function by introducing a new method called get_block_template_folders within the WP_Theme class. Previously, this function suffered from poor performance due to repeated file lookups using file_exists. The new method implements basic caching, storing the result in the theme's cache, similar to how block themes are cached in the block_theme property (see [55236]).

Additionally, this change improves error handling by checking if a theme exists before attempting to look up the file. It also enhances test coverage.

Props spacedmonkey, thekt12, swissspidy, flixos90, costdev, mukesh27.
Fixes #58319.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/themeDir.php

    r56548 r56621  
    177177            'Block Theme',
    178178            'Block Theme Child Theme',
     179            'Block Theme Child Deprecated Path',
    179180            'Block Theme Child with no theme.json',
    180181            'Block Theme Child Theme With Fluid Layout',
Note: See TracChangeset for help on using the changeset viewer.