WordPress.org

Forums

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

  1. Donatto
    Member
    Posted 1 year 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 1 year 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 1 year 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 1 year 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).

  5. serkanyucewp
    Member
    Posted 2 weeks ago #

    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>

  6. silvercent
    Member
    Posted 2 weeks ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

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

About this Topic

Tags

No tags yet.