Skip to content

Problem with wordpress REST API /wp-json/wp/v2/comments endpoint #61

@ranjan-purbey

Description

@ranjan-purbey

When accessing the above-mentioned endpoint with wp-ulike plugin installed, the following notice is generated:

Notice: Trying to get property 'comment_ID' of non-object in /var/www/html/wp-includes/comment-template.php on line 673

This renders the JSON invalid. On debugging I found that wp_ulike_comments() function calls get_comment_ID which depends on the global $GLOBALS['comment'] to get the current comment. This variable is set by an instance of Walker_Comment class (or its subclass), which is instantiated in the get_comment_pages_count function of the file wp-includes/comment.php. Probably this function is not called when accessing the comments endpoint through rest API, and hence the notice.

I know I can set the WP_DEBUG flag to false and get rid of the notice, but this seems like broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions