[wp-trac] [WordPress Trac] #59490: Performance issues in _register_theme_block_patterns
WordPress Trac
noreply at wordpress.org
Tue Oct 3 15:17:10 UTC 2023
#59490: Performance issues in _register_theme_block_patterns
------------------------------+---------------------------
Reporter: spacedmonkey | Owner: spacedmonkey
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.4
Component: Editor | Version: 6.0
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses: performance
------------------------------+---------------------------
Changes (by spacedmonkey):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"56765" 56765]:
{{{
#!CommitTicketReference repository="" revision="56765"
Editor: Improve performance of _register_theme_block_patterns function.
The `_register_theme_block_patterns` function imposed a significant
resource overhead. This issue primarily stems from themes, such as TT4,
that register a substantial number of block patterns. These patterns
necessitate numerous file operations, including file lookups, file reading
into memory, and related processes. To provide an overview, the
_register_theme_block_patterns function performed the following file
operations:
- is_dir
- is_readable
- file_exists
- glob
- file_get_contents (utilized via get_file_data)
To address these issues, caching using a transient has been added to a new
function call `_wp_get_block_patterns`. If theme development mode is
disabled and theme exists, the block patterns are saved in a transient
cache. This cache is used all requests after that, saving file lookups and
reading files into memory. Cache invalidation is done, when themes are
switched, deleted or updated. Meaning that block patterns are not stored
in the cache incorrectly.
Props flixos90, joemcgill, peterwilsoncc, costdev, swissspidy, aristath,
westonruter, spacedmonkey.
Fixes #59490
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59490#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list