-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Labels
REST API InteractionRelated to REST APIRelated to REST API[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] WP Core TicketRequires an upstream change from WordPress. Core Trac ticket should be linked.Requires an upstream change from WordPress. Core Trac ticket should be linked.
Description
Description
If enum
is used for variable value and type
is not used (docs for attributes say: The attribute definition will contain, at a minimum, either a type or an enum.
), PHP throws a lot of Warnings and several Notices
Step-by-step reproduction instructions
In block.json, use enum for one property, without type, e.g.:
...
"attributes": {
"level": {
"enum": [0, 1, 2, 3, 4, 5, 6],
"default": 2
}
},
...
Compile block, enable debugging in wp-config.php: define( 'WP_DEBUG', true );
Open site URL with block you created, you will get similar warnings and notices:
Notice: Function rest_validate_value_from_schema was called incorrectly. The "type" schema keyword for level is required. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\functions.php on line 6031
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2149
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2164
Notice: Function rest_validate_value_from_schema was called incorrectly. The "type" schema keyword for level can only be one of the built-in types: array, object, string, number, integer, boolean, and null. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\functions.php on line 6031
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2173
Notice: Function rest_sanitize_value_from_schema was called incorrectly. The "type" schema keyword for level is required. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\functions.php on line 6031
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2751
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2761
Notice: Function rest_sanitize_value_from_schema was called incorrectly. The "type" schema keyword for level can only be one of the built-in types: array, object, string, number, integer, boolean, and null. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\functions.php on line 6031
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2770
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2787
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2814
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2818
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2822
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2826
Warning: Undefined array key "type" in C:\Wamp.NET\sites\dancelib\wordpress\wp-includes\rest-api.php on line 2862
When "type" is used along with "enum" in block.json, warnings and notices disappear. However, in that case, attribute might not be enum anymore.
Screenshots, screen recording, code snippet
No response
Environment info
WordPress 6.4.2
Custom theme
FF developer 122
Windows 10 Desktop, local environment
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Metadata
Metadata
Assignees
Labels
REST API InteractionRelated to REST APIRelated to REST API[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] WP Core TicketRequires an upstream change from WordPress. Core Trac ticket should be linked.Requires an upstream change from WordPress. Core Trac ticket should be linked.