#43772 closed defect (bug) (duplicate)
Undefined property: WP_Error::$term_id in /var/www/html/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php on line 655
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | 4.9.5 |
| Component: | REST API | Keywords: | |
| Focuses: | Cc: |
Description
I've faced with the following error while using wp-json/wp/v2/categories API
<b>Notice</b>: Undefined property: WP_Error::$term_id in <b>/var/www/html/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php</b> on line <b>655</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:655) in <b>/var/www/html/web/wp/wp-includes/rest-api/class-wp-rest-server.php</b> on line <b>1248</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:655) in <b>/var/www/html/web/wp/wp-includes/rest-api/class-wp-rest-server.php</b> on line <b>1248</b><br />
Change History (7)
#2
@
8 years ago
- Keywords reporter-feedback added; needs-patch removed
Hey! Welcome to Trac!
What's the REST API call that you're performing to get this warning?
What's the setup on the categories like?
#3
@
8 years ago
I am performing POST request to /wp-json/wp/v2/categories with the data including name, description, slug, and parent (may be null).
#5
in reply to:
↑ 4
@
8 years ago
Replying to soulseekah:
Does this still happen or did you figure things out?
Yep, this still happen if parent is null.
Note: See
TracTickets for help on using
tickets.
if ( isset( $request['parent'] ) && ! empty( $schema['properties']['parent'] ) ) { $parent_term_id = 0; $parent_term = get_term( (int) $request['parent'], $this->taxonomy ); if ( $parent_term ) { 655-> $parent_term_id = $parent_term->term_id; } $prepared_term->parent = $parent_term_id; }