When querying revisions $post is not an object in get_the_content() #2836

Closed
Shelob9 opened this Issue Oct 14, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@Shelob9
Contributor

Shelob9 commented Oct 14, 2016

I am making GET request to /wp-json/wp/v2/posts/1/revisions/ Error is: Trying to get property of non-object in wp-includes/post-template.php on line 298

That is in get_the_content(), where it uses $post->post_content L263 is $post = get_post(); but there is way that will return a WP_Post in that context.

Here is my xdebug output to show how it got to get_the_content() https://pastebin.com/p6jDpqjn

I am using:
WordPress 4.7-alpha-38786
REST API Version 2.0-beta15

@kadamwhite kadamwhite self-assigned this Oct 14, 2016

@kadamwhite

This comment has been minimized.

Show comment
Hide comment
@kadamwhite

kadamwhite Oct 14, 2016

Contributor

working on this now

Contributor

kadamwhite commented Oct 14, 2016

working on this now

@kadamwhite

This comment has been minimized.

Show comment
Hide comment
@kadamwhite

kadamwhite Oct 14, 2016

Contributor

Looks like the error is originating in this line within class-wp-rest-revisions-controller:

$excerpt = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $excerpt, $post ) );

If this is changed to $excerpt = $excerpt the bug does not occur and proper JSON is returned.

This sequence of filters is traceable to fb04533 and https://github.com/WP-API/WP-API/blob/develop/lib/endpoints/class-wp-rest-posts-controller.php#L1248 we are digging in to why it's the case

Contributor

kadamwhite commented Oct 14, 2016

Looks like the error is originating in this line within class-wp-rest-revisions-controller:

$excerpt = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $excerpt, $post ) );

If this is changed to $excerpt = $excerpt the bug does not occur and proper JSON is returned.

This sequence of filters is traceable to fb04533 and https://github.com/WP-API/WP-API/blob/develop/lib/endpoints/class-wp-rest-posts-controller.php#L1248 we are digging in to why it's the case

@kadamwhite

This comment has been minimized.

Show comment
Hide comment
@kadamwhite

kadamwhite Oct 14, 2016

Contributor

Should be resolved by #2837

Contributor

kadamwhite commented Oct 14, 2016

Should be resolved by #2837

@kadamwhite kadamwhite closed this Oct 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment