Make WordPress Core

Opened 18 months ago

Last modified 17 months ago

#56627 new defect (bug)

Underscores are not allowed in block names; error message is misleading.

Reported by: skorasaurus's profile skorasaurus Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: Cc:

Description

The error when activating a plugin containing a register block whose name contains an underscore is vague and misleading.

If you do not have WP_DEBUG set to true in your site's wp-config.php file; there are no errors in the browser's javascript console while in the editor.

When you have WP_DEBUG set to true; and activate the plugin that contains the block, the error message displayed is misleading; the message, included verbatim below, states that a namespace prefix must be used and in my test case block, a name space was used; create-block

"Notice: Function WP_Block_Type_Registry::register was called <strong>incorrectly</strong>. Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 5.0.0.) in /srv/www/case/public_html/wp-includes/functions.php on line 5831"


A testcase for a block named 'my_test_case' is available at https://gitlab.com/skorasaurus/my_test_case
The block does has a namespace, create-block.

The full stacktrace for the error is at
https://gist.github.com/skorasaurus/6506770a49bedff53876b962c1d29b16

This has happened to me in the past, has been reported in the [gutenberg issue tracker]https://github.com/WordPress/gutenberg/issues/13074 (issue was closed and directed to report here)

Change History (2)

#1 @skorasaurus
18 months ago

An error message stating the allowed characters in a block name once existed; according to
https://github.com/WordPress/gutenberg/issues/2730 but the message no longer appears.

#2 @desrosj
17 months ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.