From 68f97dcb83d466e2028bd4b546e27a15a8b154fd Mon Sep 17 00:00:00 2001 From: spacedmonkey Date: Tue, 13 Jun 2023 11:46:27 +0000 Subject: [PATCH] Editor: Skip file_exist check for core blocks. In `register_block_type_from_metadata` function, skip calling `file_exists` on core blocks. Core blocks are part of the codebase and will never not exist. Not calling this function is better for performance, as the file lookup can be expensive. Props spacedmonkey, joemcgill. Fixes #58385. Built from https://develop.svn.wordpress.org/trunk@55910 git-svn-id: http://core.svn.wordpress.org/trunk@55422 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 3bdcdcc452..41b8430f98 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -326,13 +326,15 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { trailingslashit( $file_or_folder ) . 'block.json' : $file_or_folder; - if ( ! file_exists( $metadata_file ) ) { + $is_core_block = str_starts_with( $file_or_folder, ABSPATH . WPINC ); + + if ( ! $is_core_block && ! file_exists( $metadata_file ) ) { return false; } // Try to get metadata from the static cache for core blocks. $metadata = false; - if ( str_starts_with( $file_or_folder, ABSPATH . WPINC ) ) { + if ( $is_core_block ) { $core_block_name = str_replace( ABSPATH . WPINC . '/blocks/', '', $file_or_folder ); if ( ! empty( $core_blocks_meta[ $core_block_name ] ) ) { $metadata = $core_blocks_meta[ $core_block_name ]; diff --git a/wp-includes/version.php b/wp-includes/version.php index 73014d8326..68ed4a2eea 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55909'; +$wp_version = '6.3-alpha-55910'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.