Opened 2 weeks ago
Last modified 3 days ago
#58385 new enhancement
Skip file_exists check for core blocks in register_block_type_from_metadata
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | high |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch |
Focuses: | performance | Cc: |
Description
In the register_block_type_from_metadata
function, there is a call to file_exists
to see if the metadata file existing before registering. However, it is extremely unlikely the core blocks would not exist. As file lookups are expensive, saving 91 file_exists would improve site performance.
Change History (5)
This ticket was mentioned in PR #4492 on WordPress/wordpress-develop by @spacedmonkey.
2 weeks ago
#1
- Keywords has-patch added
@presstoke commented on PR #4492:
3 days ago
#3
This makes sense to me. In the same vein of avoiding unneeded file_exists
it looks like there’s one nearby in register_block_type
:
The check is extraneous there since it's going to be done in register_block_type_from_metadata
. Does that seem right? Core blocks aren’t using that code path but plenty of third parties may be.
@spacedmonkey commented on PR #4492:
3 days ago
#4
This makes sense to me. In the same vein of avoiding unneeded
file_exists
it looks like there’s one nearby inregister_block_type
:
The check is extraneous there since it's going to be done in
register_block_type_from_metadata
. Does that seem right? Core blocks aren’t using that code path but plenty of third parties may be.
@stokesman Already done in https://github.com/WordPress/wordpress-develop/commit/537eb2145a356b471f474927ab8458ddef6802c1
@presstoke commented on PR #4492:
3 days ago
#5
True that it’s now side-stepped by core blocks but any calls to register_block_type
with a string for the first parameter are checking file_exists
and forwarding directly to register_block_type_from_metadata
where it again checks file_exists
. It seems like the first one can be dropped, no?
Do excuse me if it's not really related enough to be bringing up on this PR but it did seem so.
Trac ticket: https://core.trac.wordpress.org/ticket/58385