[wp-gsoc] [Summer of Code] #382: Undefined index errors for /wp-json.php/posts/POST_ID/comments

Summer of Code noreply at wordpress.org
Sun Sep 29 01:04:42 UTC 2013

#382: Undefined index errors for /wp-json.php/posts/POST_ID/comments
 Reporter:  mordauk      |       Type:  defect
   Status:  new          |   Priority:  normal
Milestone:               |  Component:  JSON REST API
 Keywords:  needs-patch  |
 There are undefined index errors thrown in the `prepare_comment()`
 function due to `$post` never being defined.

 There is also an instance of `$post->comment_date_gmt` that is supposed to
 be `$comment->comment_date_gmt`.

 Adding `$post = (array) get_post( $fields['post'] );` at line 966 of
 `class=wp-json-posts.php` fixes the undefined index.

 And changing line 1033 of `class-wp-json-posts.php` from
 `$fields['date_gmt'] = date( 'c', strtotime( $post->comment_date_gmt ) );`
 to `$fields['date_gmt'] = date( 'c', strtotime( $comment->comment_date_gmt
 ) );` fixes the second issue.

Ticket URL: <https://gsoc.trac.wordpress.org/ticket/382>
Summer of Code <https://gsoc.trac.wordpress.org>
My example project

More information about the wp-gsoc mailing list