[wp-trac] [WordPress Trac] #57797: WP_Block_Type_Registry::register issues incorrect error message when block.json folder doesn't exist

WordPress Trac noreply at wordpress.org
Thu Feb 23 16:19:42 UTC 2023


#57797: WP_Block_Type_Registry::register issues incorrect error message when
block.json folder doesn't exist
--------------------------+-----------------------------
 Reporter:  Tonygirling   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I called
 {{{#!php
 <?php
 register_block_type( path_to_block.json );
 }}}

 but the path does not exist.

 I get error message:

 {{{
 Notice: Function WP_Block_Type_Registry::register was called incorrectly.
 }}}
 {{{
 Block type names must not contain uppercase characters.
 }}}

 This error message does not reflect the problem.


 Stepping through the code in wp-includes/blocks.php:
 {{{#!php
 <?php
 function register_block_type( $block_type, $args = array() ) {
         if ( is_string( $block_type ) && file_exists( $block_type ) ) {
                 return register_block_type_from_metadata( $block_type,
 $args );
         }

         return WP_Block_Type_Registry::get_instance()->register(
 $block_type, $args );
 }
 }}}
 I see ->register is still called even though the call to file_exists()
 fails

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57797>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list