Support » Plugin: Yoast SEO » Bug: Fatal error from unexpected option in database

  • I’ve been troubleshooting a multisite installation, where the dashboard for one of the sub-sites displays on a white page. Upon checking the logs, I see this message in the log file:

    [Wed Oct 24 15:45:56 2012] [error] [client 96.245.44.49] PHP Fatal error:  Cannot unset string offsets in /nas/wp/www/cluster-1182/kaseyacorp/wp-content/plugins/wordpress-seo/admin/class-admin.php on line 440, referer: http://blog.kaseya.com/wp-admin/network/plugins.php

    Digging into the wordpress-seo/admin/class-admin.php file, this is the block of code surrounding line 440:

    if ( version_compare( $current_version, '1.2.8', '<' ) ) {
        $options = get_option( 'wpseo' );
        if ( isset( $options['presstrends'] ) ) {
            $options['yoast_tracking'] = 'on';
            unset( $options['presstrends'] );
            update_option( 'wpseo', $options );
        }
    }

    When I actually look in the database to see what’s stored for the “wpseo” option, I see that it is a string, not an array. The string is “1pseo_social”. While it seems that the isset() if statement should prevent the code from running, it turns out that in PHP 5.3, evaluating a string as if it’s an array with isset() will return true. See isset() in the PHP manual.

    Here’s an update to that section of code that should resolve the issue:

    if ( version_compare( $current_version, '1.2.8', '<' ) ) {
        $options = get_option( 'wpseo' );
        if ( ! is_array( $options ) ) {
            $options = array( $options );
        }
        if ( isset( $options['presstrends'] ) ) {
            $options['yoast_tracking'] = 'on';
            unset( $options['presstrends'] );
        }
        update_option( 'wpseo', $options );
    }

    http://wordpress.org/extend/plugins/wordpress-seo/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Bug: Fatal error from unexpected option in database’ is closed to new replies.