Opened 8 years ago
Closed 7 years ago
#44963 closed defect (bug) (invalid)
PHP Notice: Undefined variable in wp-includes/rest-api.php $args['type']
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | minor | Version: | 4.7 |
| Component: | REST API | Keywords: | has-patch reporter-feedback |
| Focuses: | rest-api | Cc: |
Description (last modified by )
This problem occur in rest_validate_value_from_schema and rest_sanitize_value_from_schema functions.
Please add
<?php #example: if ( isset($args['type']) && 'array' === $args['type'] )...
isset($args['type']) before *** === $args['type'] for fixed these.
Attachments (2)
Change History (7)
#2
@
8 years ago
- Keywords has-patch added; needs-patch removed
- Severity changed from normal to minor
#3
@
8 years ago
@weblogma Can you attach what schema you are using? Or are you using the function directly?
#5
@
7 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Version set to 4.7
Hi @weblogma,
I'm going to close out this ticket. At the moment, specifying a type for your schema is required. Otherwise rest_validate_value_from_schema won't have anything to do. If you don't want the default validator or sanitizers to be called, you can manually set validate_callback and sanitize_callback to null. For an example: https://github.com/WordPress/wordpress-develop/blob/75f82d8bc2b96074d67df09c371cfc1139c19d8c/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2081
If you have a use case as to why the type should be optional, feel free to comment and reopen the ticket.
I fixed bugs in this file.