Support » Plugin: SportsPress - Sports Club & League Manager » REST API – HTTP error 500 after upgrading to WordPress 4.7

  • Hey I’m back πŸ˜€

    after upgrading WordPress to 4.7 the REST API stopped working completely (no matter if I send a a request related to sportspress or for normal posts.) Every request ends in an HTTP error 500. In the PHP error log I got the entry:
    PHP Fatal error: Call to a member function get_field_schema() on null in *removedpath*/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php on line 1931

    I am posting this here in sportspress support because after deactivating sportspress the other requests (e.g. for normal posts) are back in action. So it must be an error of sportspress.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Roch

    (@rochesterj)

    Hi!

    Thanks for reaching out, and I’m sorry for the trouble.

    I’m sending this to our dev team so they can check, please stand by! πŸ™‚

    Kind Regards,
    -Roch

    Plugin Author Brian

    (@brianmiyaji)

    Hey @sagund07 thanks for your feedback! I’m trying to repro this error on our test site. Could you tell me which version of SportsPress you have installed, and if any other plugins are also active? If you could also find out the PHP version that would be good to know as well πŸ™‚

    Hey @rochesterj and @brianmiyaji,

    thanks for helping out. Currently I am running sportspress in version 2.1.4 + the REST API c
    hanges of version 2.1.5 because I used them from github as a hotfix. I did not update sportspress for a while because of the running season and the customizations I made. So updating sportspress maybe interfere the season. I looked through the github commits to find any changes refering to REST API but I did not found any. If you cannot reproduce the error I will upgrade to 2.1.7 and try to get things running. If this does not work I will try to deactivate all the other plugins.

    My PHP Version is 5.6 (alternative is 7.0)

    I have also encountered this same error upon updating a heavily customized WP install. It seems, actually, that endpoints that set the post_type as anything other than ‘post’ work fine, but if you hit an endpoint where the post_type is set to ‘post’ it throws this error.

    **this is also on a Multisite Install

    I am using a custom endpoint that looks like this:
    ?site=subsitename&post_type=post&posts_per_page=10&paged=0&return_args=limit

    Updating this issue:
    I have found the cause of this error.

    If you have a class that extends the WP_REST_Post_Controller for your custom endpoints, you may have redefined the __construct method without calling the parent::__construct, that will replace the construction of the class with your new controller, but the instantiation of the WP_REST_Post_Meta_Fields controller happens within the construct of the parent WP_REST_Post_Controller and is never set.

    To fix this problem:

    call on the parent::__construct($post_type) from within your custom class’ __construct method

    –OR–

    do not override the constructor at all.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘REST API – HTTP error 500 after upgrading to WordPress 4.7’ is closed to new replies.