Make WordPress Core

Changeset 55910


Ignore:
Timestamp:
06/13/2023 11:44:14 AM (12 months ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r55822 r55910  
    327327        $file_or_folder;
    328328
    329     if ( ! file_exists( $metadata_file ) ) {
     329    $is_core_block = str_starts_with( $file_or_folder, ABSPATH . WPINC );
     330
     331    if ( ! $is_core_block && ! file_exists( $metadata_file ) ) {
    330332        return false;
    331333    }
     
    333335    // Try to get metadata from the static cache for core blocks.
    334336    $metadata = false;
    335     if ( str_starts_with( $file_or_folder, ABSPATH . WPINC ) ) {
     337    if ( $is_core_block ) {
    336338        $core_block_name = str_replace( ABSPATH . WPINC . '/blocks/', '', $file_or_folder );
    337339        if ( ! empty( $core_blocks_meta[ $core_block_name ] ) ) {
Note: See TracChangeset for help on using the changeset viewer.