[wp-trac] [WordPress Trac] #52592: PHP notice when the label property is missing from register_block_style
WordPress Trac
noreply at wordpress.org
Mon Feb 22 08:43:03 UTC 2021
#52592: PHP notice when the label property is missing from register_block_style
--------------------------+-----------------------------
Reporter: poena | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 5.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
If I register a block style using the PHP function
{{{register_block_style}}}, and I leave out the label property, there is a
PHP notice:
{{{
Notice: Undefined index: label in /var/www/src/wp-includes/script-
loader.php on line 2312
}}}
The label is required, but the class does not check if a label exists or
not, see:
https://core.trac.wordpress.org/browser/tags/5.6.1/src/wp-includes/class-
wp-block-styles-registry.php#L43
In comparison, if I leave out the {{{name}}} property, a
{{{_doing_it_wrong}}} message is shown.
I think a {{{_doing_it_wrong}}} should be shown for the label too.
Steps to reproduce the issue:
Register an incomplete block style in a theme or plugin file using
register_block_style.
{{{
register_block_style(
'core/quote',
array(
'inline_style' => '.wp-block-quote.is-style-blue-quote { color:
blue; }',
)
);
}}}
Confirm that the doing it wrong message for the name is showing.
Add the name property:
{{{
register_block_style(
'core/quote',
array(
'name' => 'test',
'inline_style' => '.wp-block-quote.is-style-blue-quote { color:
blue; }',
)
);
}}}
Open the block editor. Confirm that a PHP notice for the label is showing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52592>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list