Blocks: Include block name context in WP_Block_Type_Registry::registe…#11478
Blocks: Include block name context in WP_Block_Type_Registry::registe…#11478manishdhorepatil-art wants to merge 3 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @ManishDhorepatil. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The plugin includes the following invalid cases:
Result: |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR improves _doing_it_wrong() notices emitted by WP_Block_Type_Registry::register() by adding more context about invalid block type inputs, making debugging easier.
Changes:
- Include the received type when a non-string block name is passed.
- Include the invalid block name in notices for uppercase characters and missing namespace prefix.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com>
Co-authored-by: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com>
|
@desrosj done changes |
|
@desrosj changes done can you please review once |
Tested the existing patch and it works as expected.
Testing Instructions:
Apply the patch from PR Include block name context in _doing_it_wrong messages in WP_Block_Type_Registry::register() #11475.
In a test plugin or theme, try registering a block with an invalid name (e.g., containing uppercase characters):
register_block_type( 'MyBlock' );
Observe the _doing_it_wrong() notice.
Results:
Before applying the patch:
The error message is generic and does not indicate which block caused the issue.
Example:
"Block type names must not contain uppercase characters."
After applying the patch:
The error message correctly includes the block name, making debugging easier.
Example:
"Block type "MyBlock" must not contain uppercase characters."
Ticket track - https://core.trac.wordpress.org/ticket/65039
Testing the patch
https://www.dropbox.com/scl/fi/yydrbuv2saaf8w7gmw4yy/test-invalid-block.zip?rlkey=f1u85jp0424lqczpvtltve6j1&st=h30rmcia&dl=0
The plugin includes the following invalid cases:
https://github.com/user-attachments/files/26590078/debug.log
Result:
The _doing_it_wrong() messages now correctly include the block name causing the issue, improving debugging clarity.