• I have upgraded both WordPress and feed-json plugins.

    Each time I use feed (but not any other) URL, I see in apache error logs file:

    PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /var/www/website/wp-includes/plugin.php on line 470

    I checked already, it’s because of do_feed_json(). Can you fix this for later version?

    Please, let me know if you need more details.

    Versions:
    * WordPress: 3.9.1
    * Feed Json: 1.0.9

    https://www.ads-software.com/plugins/feed-json/

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have the same problem, and I think the issue is in this method declaration, lines 81-83 of feed-json.php:

    static public function add_feed_json() {
      add_feed('json', array($this, 'do_feed_json'));
    }

    If I remove the ‘static’ keyword, it resolves the error. This method is called nonstatically a few lines above in the method add_feed_json_once(), and I think it’s barfing because the $this variable is not available in static functions.

    Is there a reason why add_feed_json() is declared to be static? I don’t immediately see any static calls to the function.

    I was able to resolve the issue by placing the following line under comments:

    //add_action( 'init', array( $this, 'add_feed_json') );

    then changed the function to non static as indicated by rohnjeynolds. hope that helps anyone else until the plugin is updated.

    The problem is that add_feed_json is marked as static method so there is no $this (object instance variable). Plugin uses singleton pattern, so maybe one way to correct the class would be getting the instance variable with get_instance -method or simply drop all static methods (because there can be only one instance anyways).

    how can i fix this problem

    <b>Warning</b>: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in <b>/home/bato.org.tr/httpdocs/wp-includes/plugin.php</b> on line <b>496</b>

    I removed the static keyword in public function add_feed_json() and it resolved the error, but im not sure if it perfect solution

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP warning: call_user_func_array() expects parameter 1 to be a valid callback’ is closed to new replies.