#56666 closed defect (bug) (fixed)
Bug/performance: No need to make repeat calls to `get_theme_file_path` in `register_block_style_handle`
Reported by: | aristath | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 6.1 |
Component: | General | Keywords: | has-patch add-to-field-guide |
Focuses: | performance | Cc: |
Description
The register_block_style_handle
function runs ~200 times on each page load.
Each time it runs, we call get_theme_file_path
and then run it through wp_normalize_path
.
get_theme_file_path
calls get_stylesheet_directory
, which calls get_stylesheet
, which calls get_option
, and there's a bunch of filters that run on each iteration of that - without ever changing.
We can cache the value and avoid 200 calls on many functions and filters - improving performance.
Change History (5)
This ticket was mentioned in PR #3341 on WordPress/wordpress-develop by aristath.
2 years ago
#1
- Keywords has-patch added
mukeshpanchal27 commented on PR #3341:
2 years ago
#2
@aristath Can we add this new cache related code after the if statement line no. 222? Because we required it there, not prior?
#3
@
2 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 54327:
SergeyBiryukov commented on PR #3341:
2 years ago
#4
Thanks for the PR! Merged in r54327.
Trac ticket: https://core.trac.wordpress.org/ticket/56666