• Resolved jimingkui

    (@jimingkui)


    Hi there.

    Thanks for the great plugin, but I got following warning after installed it on my wordpress site:

    FastCGI sent in stderr: “PHP messa
    ge: PHP Warning: Invalid argument supplied for foreach() in /usr/share/nginx/ww
    w/wp-includes/rest-api/endpoints/class-wp-rest-controller.php on line 298” while
    reading response header from upstream, client: 31.7.245.53, server: , request: “OPTIONS /index.php/wp-json/wordpress-popular-posts/v1/popular
    -posts/ HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock:”, host: “”

    Please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @jimingkui,

    Thanks for the report. I’ll look into it as soon as possible.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Which WordPress version are you using at the moment?

    Thread Starter jimingkui

    (@jimingkui)

    WordPress 4.7.5,

    Will upgrade wordpress to the latest fix the problem?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Thanks for reporting back, @jimingkui.

    Will upgrade wordpress to the latest fix the problem?

    No, I needed to know which version of WordPress you have there to see what line 298 in /wp-includes/rest-api/endpoints/class-wp-rest-controller.php does on WordPress version 4.7.5.

    In case you’re curious, it’s this:

    
    /**
     * Retrieves the item's schema for display / public consumption purposes.
     *
     * @since 4.7.0
     * @access public
     *
     * @return array Public item schema data.
     */
    public function get_public_item_schema() {
    
        $schema = $this->get_item_schema();
    
        foreach ( $schema['properties'] as &$property ) { // <-- Here!
            unset( $property['arg_options'] );
        }
    
        return $schema;
    }

    You don’t really need to upgrade to the latest version of WordPress (but you really should consider upgrading, your site is currently open to many known security holes right now!)

    Anyways, please try this:

    1. Go to Plugins > Editor and select WordPress Popular Posts from the dropdown.
    2. Click on includes, then on class-wordpress-popular-posts-rest-controller.php to edit it.
    3. Find (around line 37):

      'schema' => array( $this, 'get_public_item_schema' ),

      and change it to:

      //'schema' => array( $this, 'get_public_item_schema' ),

    4. Next, click on Update file to save changes.

    Please report back your results.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Warning: Invalid argument supplied for foreach()’ is closed to new replies.