Home Forums Newsletter Plugin Support PHP Fatal error: Uncaught Error: Call to undefined function wp_json_decode()

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #331014
    Corrado Fiore
    Participant

    Hi All,

    I think I might have found a bug in the plugin’s code. When I installed it on my WP 6.6.1 instance running under PHP 8.3 and I tried to get a free license from the WP backend, the AJAX submission returned an error 500.

    In the server logs, I found this error:

    
    [...] request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/run/php/php8.3-fpm.sock:", host: "[...]", referrer: "https://myhost/wp-admin/admin.php?page=newsletter_extensions_index"
    2024/08/24 14:18:31 [error] 110651#110651: *171369 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function wp_json_decode() in /[...]/wp-content/plugins/newsletter-extensions/plugin.php:71
    Stack trace:
    #0 /[...]/wp-includes/class-wp-hook.php(324): NewsletterExtensions->_register()
    #1 /[...]/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #2 /[...]/wp-includes/plugin.php(517): WP_Hook->do_action()
    #3 /[...]/wp-admin/admin-ajax.php(192): do_action()
    #4 {main}
      thrown in /var/www/coramdeo.org.au/wp-content/plugins/newsletter-extensions/plugin.php on line 71"
    

    The error is expected, since wp_json_decode() is not defined anywhere in the WP code:

    
    root@frontend-1:~# grep -r wp_json_decode /[...]/
    
    /[...]/wp-content/plugins/newsletter-extensions/plugin.php:        $data = wp_json_decode(wp_remote_retrieve_body($response));
    root@frontend-1:~#
    

    AFAIK, wp_json_decode() was deprecated and json_decode() should be used instead. I see that /plugins/newsletter-extensions/plugin.php contains a mix of both versions.

    I replaced all instances of wp_json_decode() and wp_json_encode() in /plugins/newsletter-extensions/plugin.php with their newer equivalents and the free registration feature started working.

    I would have normally opened a ticket to report this, but I can not open one unless I am a paying customer. Hope this helps.

    #331015
    Stefano
    Keymaster

    Hi, thank you for reporting it’s an error in the addons manager addon. Fixed on version 1.3.2.
    To see the update notice, just save the Newsletter’s general options to reset the version cache.

    Stefano.

    #331021
    Corrado Fiore
    Participant

    Thank you Stefano for the prompt reply, much appreciated!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.