Support » Plugin: All in One SEO – Best WordPress SEO Plugin – Easily Improve SEO Rankings & Increase Traffic » ErrorException: “json_decode() expects parameter 1 to be string

  • I’m receiving the following error with AIOSEO when accessing the AIO Settings page or a CPT page in admin:

    
    /Users/***/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/Helpers/Vue.php 135
    
    ErrorException thrown with message "json_decode() expects parameter 1 to be string, array given"
    

    The line referred to in the error is:

    'helpPanel' => json_decode( aioseo()->help->getDocs() ),

    The getDocs() call is sending an array to json_decode instead of a string.

    This is occurring with WP_DEBUG enabled and WP_ENVIRONMENT_TYPE set to either ‘local’ or ‘staging’. The local environment uses valet and staging is a WHM/cPanel server. The only way to get around it is to disable WP_DEBUG. I have seen this occur on multiple sites.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support shivamtyagi

    (@shivamtyagi)

    Hi @joshf,

    It looks like there’s an error in your cache. Can you please try clearing it through the debug tools and see if that fixes the issue?

    Thread Starter Joshua Fredrickson

    (@joshf)

    I tried this on three different sites as well as incognito window. Same results unfortunately.

    Plugin Support shivamtyagi

    (@shivamtyagi)

    Hi @joshf,

    Are you seeing the same error after updating to the latest version of AIOSEO – v4.1.9.4?

    Thread Starter Joshua Fredrickson

    (@joshf)

    Yep! Looks good on the latest version.

    Thanks!

    Hello,
    I’m receiving the same warning after updating to the version 4.2.2.
    PHP Warning: json_decode() expects parameter 1 to be string, array given in …/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/Helpers/Vue.php on line 162

    it’s the same line:
    ‘helpPanel’ => json_decode( aioseo()->help->getDocs() ),

    It’s logged every time I load or save any “edit” screen in WP admin, for any post type, including media.

    Could you please take a look at this?
    Eva

    • This reply was modified 3 months, 1 week ago by temereva.
    • This reply was modified 3 months, 1 week ago by temereva.
    Thread Starter Joshua Fredrickson

    (@joshf)

    I can confirm that this has cropped back up across several different sites I’ve seen. We’ve had to migrate to Yoast for a few of them as the error proved too difficult to work around in some staging environments.

    Found the issue and a few ways to fix it.

    The main problem is that getDocs() function is supposed to return a string, but there are cases where it returns “false” or an empty array, and in Vue.php file there is no check for the data type, hence – the json_decode() function that expects for the string only throws a notice into my php log on every load of the page/post edit screen.

    Fixes:
    In short, @shivamtyagi , it would be great if you just added a simple datatype check to Vue.php.

    (is_string(aioseo()->help->getDocs()) === true) ? json_decode( aioseo()->help->getDocs()) : ”,

    If more detailed, getDocs() function can also be revised to ensure it returns same type of response.

    Also, in my case the core of the problem was that my WordPress is configured to limit the external http requests to a few that are absolutely necessary (for various reasons). So when getDocs() can’t get the docs from WP cache, it tries to fetch it from the plugin’s cdn, and receives wp_error object. Ideally, there should be a message thrown to the admin panel offering to add the specified domain name to the accessible hosts: define(‘WP_ACCESSIBLE_HOSTS’, ‘*.aioseo.com’); in wp-config.php – this would fix the logging issue too.

    Plugin Support Steve M

    (@wpsmort)

    Hi @temereva, thanks for the information. I’ve opened a Github issue for our Development team to look into this fix.

    Plugin Support Steve M

    (@wpsmort)

    Hi @temereva,

    I wanted to let you know that we’ve now released All in One SEO version 4.2.4 which includes a fix for this issue.

    That’s great to know! Thank you! I can confirm that it’s fixed.

    Thread Starter Joshua Fredrickson

    (@joshf)

    I dunno. I’m still seeing this in WP 6.1, AIOSEO 4.2.4 and PHP 8.0. Specifically, when attempting to view a CPT listing in admin. I’m seeing this across quite a few sites on several different themes.

    ⇒  php -v
    PHP 8.0.21 (cli) (built: Jul  7 2022 13:13:21) ( NTS )
    ⇒  wp core version
    6.0.1
    ⇒  wp plugin list 
    +-------------------------------------+----------+--------+---------+
    | name                                | status   | update | version |
    +-------------------------------------+----------+--------+---------+
    ...
    | all-in-one-seo-pack                 | active   | none   | 4.2.4   |

    wp-admin/edit.php?post_type=example:

    Fatal error: Uncaught TypeError: json_decode(): Argument #1 ($json) must be of type string, array given in /site/wp-content/plugins/all-in-one-seo-pack/app/Common/Help/Help.php:73 Stack trace: #0 /site/wp-content/plugins/all-in-one-seo-pack/app/Common/Help/Help.php(73): json_decode(Array, true) #1 /site/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/Helpers/Vue.php(164): AIOSEO\Plugin\Common\Help\Help->getDocs() #2 /site/wp-content/plugins/all-in-one-seo-pack/app/Common/Standalone/DetailsColumn.php(117): AIOSEO\Plugin\Common\Utils\Helpers->getVueData() #3 /site/wp-includes/class-wp-hook.php(307): AIOSEO\Plugin\Common\Standalone\DetailsColumn->enqueueScripts('edit.php') #4 /site/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array) #5 /site/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #6 /site/wp-admin/admin-header.php(118): do_action('admin_enqueue_s...', 'edit.php') #7 /site/wp-admin/edit.php(397): require_once('/site/...') #8 /Users/joshf/.composer/vendor/laravel/valet/server.php(234): require('/site/...') #9 {main} thrown in /site/wp-content/plugins/all-in-one-seo-pack/app/Common/Help/Help.php on line 73

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