• Resolved Marcus

    (@alternamedia)


    The upgrade to 3.0 appears to break the REST API:

    ~~~~
    PHP Fatal error: Uncaught TypeError: Argument 2 passed to wp_statuses_rest_prepare_for_response() must be an instance of WP_Post, instance of stdClass given, called in …/wp-includes/class-wp-hook.php on line 307 and defined in /…/wp-content/plugins/lh-archived-post-status/includes/wp-statuses/inc/core/functions.php:541

    Stack trace:
    #0 /…/wp-includes/class-wp-hook.php(307): wp_statuses_rest_prepare_for_response(Object(WP_REST_Response), Object(stdClass), Array)
    #1 /…/wp-includes/plugin.php(191): WP_Hook->apply_filters(Object(WP_REST_Response), Array)
    #2 /…/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1959): apply_filters(‘rest_prepare_po…’, Object(WP_REST_Response), Object(stdClass), Array)
    #3 /…/wp-content/themes/…/lib/REST.php(157): WP_REST_Posts_Controller->prepare_item_for_response(Object(stdClass), Array)
    #4 /… in /…/wp-content/plugins/lh-archived-post-status/includes/wp-statuses/inc/core/functions.php on line 541
    ~~~~

    Is there are known resolution for this issue?

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author shawfactor

    (@shawfactor)

    Thanks for the heads up, very weird, I’ve never seen this error and I use my the plugin extensively across the platform I’ve built and I log all errors. It is weird that it is only now being reported

    Two questions

    1. Have you verified the issue is actually with the plugin by disabling all other plugins first. It is possible that some other plugin is manipulating the post object first

    2. Where, when is the error happening? Ie what specific url or rest endpoint?

    Plugin Author shawfactor

    (@shawfactor)

    I am resolving this for good order, but will reopen if needed

    On review this error is not caused by the plugin. The error location is a “red herring” (it’s misleading). It’s where PHP discovered the problem, not the root cause of the problem. You need to fix the root cause.

    Another plugin is filtering rest_prepare_{$this->post_type} earlier than this plugin and is returning incorrectly. Then this plugin tries to work with the incorrect return value.

    Deactivating plugins until you find the culprit is the best bet.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘3.0 breaks REST API calls’ is closed to new replies.