[wp-trac] [WordPress Trac] #57706: REST_Block_Type_Controller_Test::test_get_item_invalid() throws PHP Warning for invalid 'styles' data type
WordPress Trac
noreply at wordpress.org
Mon Feb 13 17:52:05 UTC 2023
#57706: REST_Block_Type_Controller_Test::test_get_item_invalid() throws PHP Warning
for invalid 'styles' data type
------------------------------+-------------------------
Reporter: hellofromTonya | Owner: (none)
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.2
Component: Build/Test Tools | Version:
Severity: normal | Keywords: needs-patch
Focuses: |
------------------------------+-------------------------
The `REST_Block_Type_Controller_Test::test_get_item_invalid()` throws a
PHP Warning due to the `'styles'` setting not being an `array` data type.
{{{
Warning: foreach() argument must be of type array|object, string given in
wp-includes/class-wp-theme-json.php on line 835
}}}
`WP_Block_Type` expects the `'styles'` property to be an array. The code
in `WP_Theme_JSON` (added in #57583 / [55172] expects the property to be
an array as it is passed into a `foreach()`. But this test sets it to a
string.
The PHP Warning alerts the developer of a problem which in this case is an
incorrect data type when registering the block type.
This ticket proposes either checking for the PHP Warning OR setting the
`'styles'` property to an empty `array()` instead.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57706>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list