WordPress.org

Forums

Feed JSON
PHP warning: call_user_func_array() expects parameter 1 to be a valid callback (4 posts)

  1. Donatto
    Member
    Posted 11 months ago #

    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://wordpress.org/plugins/feed-json/

  2. rohnjeynolds
    Member
    Posted 11 months ago #

    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.

  3. goidxmario
    Member
    Posted 11 months ago #

    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.

  4. joumak
    Member
    Posted 11 months ago #

    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).

Reply

You must log in to post.

About this Plugin

  • Feed JSON
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.