Support » Plugin: WP OAuth Server (OAuth Authentication) » PHP 7.2 Warning: count()

  • Resolved BrianHenryIE



    PHP 7.2 adds a new error when trying to count(null). This is in our logs:

    PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/oursite/wp-content/plugins/oauth2-provider/library/OAuth2/Server.php on line 458

    For this line:

    protected function createDefaultAuthorizeController() {
    if (0 == count( $this->responseTypes ) ) {

    And running error_log shows $this->responseTypes is null.

    Is it ok to be null or do I have a deeper issue? Is nothing equal to zero?! I was tempted to rewrite the line as:

    if ( $this->responseTypes == null || 0 == count( $this->responseTypes ) ) {

    Thanks for the plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Justin Greer


    Forum Moderator

    Thanks for reporting this. We will be pushing an update to patch this. You can write it the way you suggested. IN the next update the we will be adding our own code to the plugin to patch which should have the same affect.

    Hey Justin!

    I’m encountering this issue myself as well. Do you happen to know when there will be an update available? For the time being I have modified the code myself to get by.


    Plugin Author Justin Greer


    Forum Moderator

    We are trying to move the release up. We are hoping to have something in place by the end of the week. We are still running our test for the latest version of PHP.

    Plugin Author Justin Greer


    Forum Moderator

    We just released a new update of WP OAuth Server. The updated contains the fix for this issue. Please update to the latest version when possible and update this thread to let us know it is working for you.

    Hey Justin,

    Seems like that fixed the error for line 457, however the same issue is on line 477.

    Changing it to this fixes the problem.

    if ( is_null($this->grantTypes ) || 0 == count( $this->grantTypes ) ) {

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP 7.2 Warning: count()’ is closed to new replies.