#58342 closed enhancement (fixed)
Use register_block_type_from_metadata in register_core_block_types_from_metadata
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.3 | Priority: | high |
Severity: | normal | Version: | 5.5 |
Component: | Editor | Keywords: | good-first-bug has-patch commit |
Focuses: | performance | Cc: |
Description
In register_core_block_types_from_metadata
function, register_block_type
is called. This does a file_exists check and then calls register_block_type_from_metadata
. However, register_block_type_from_metadata
can be called directly with the same effect. This saves around 21 files exists checks and results in improved performance.
Attachments (2)
Change History (14)
This ticket was mentioned in Slack in #core-editor by spacedmonkey. View the logs.
19 months ago
#2
@
19 months ago
- Keywords needs-refresh added
Thanks @nihar007 for the Patch!
Your patch has PHPCS error. Instead of arrange in single line just replace register_block_type
with register_block_type_from_metadata
function.
This ticket was mentioned in PR #4488 on WordPress/wordpress-develop by sudip-md.
19 months ago
#4
- Keywords has-patch added; needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/58342
#7
@
19 months ago
The changes proposed make sense. In retrospect, the direct call seems like a reasonable choice in WordPress Core.
#8
@
19 months ago
@gziolo Would there ever be a case where there are core blocks without block.json? I am guessing not.
I am good to commit this then?
#9
@
19 months ago
Good to commit. All core blocks need to have block.json
. It's also optimized behind the scenes, and all core blocks have block.json
transformed into a single PHP file during the build process to avoid reading and parsing all individual JSON files.
#10
@
18 months ago
- Keywords commit added
- Milestone changed from Future Release to 6.3
- Owner set to spacedmonkey
- Priority changed from normal to high
- Status changed from new to assigned
Making this as ready for commit.
This is not just a code quality change. This change removes 31 calls to file exists, so this change has a performance benefit. Flagging the performance lead @flixos90 for review.
@spacedmonkey commented on PR #4488:
18 months ago
#12
Committed.
Replaced register_block_type with register_block_type_from_metadata