• This bug causes the following error as many others have reported:

    Fatal error: Cannot unset string offsets in ~\wwwroot\wp-content\plugins\wordpress-seo\admin\class-admin.php on line 440

    There is a bug in the following code (class-admin.php lines 65-77):

    function multisite_defaults() {
    		$option = get_option( 'wpseo' );
    		if ( function_exists( 'is_multisite' ) && is_multisite() && !is_array( $option ) ) {
    			$options = get_site_option( 'wpseo_ms' );
    			if ( is_array( $options ) && isset( $options['defaultblog'] ) && !empty( $options['defaultblog'] ) && $options['defaultblog'] != 0 ) {
    				foreach ( get_wpseo_options_arr() as $option ) {
    					update_option( $option, get_blog_option( $options['defaultblog'], $option ) );
    				}
    			}
    			$option['ms_defaults_set'] = true;
    			update_option( 'wpseo', $option );
    		}
    	}

    The line update_option( 'wpseo', $option ); updates the ‘wpseo’ option to a string “1pseo_social” which causes the error later on on line 440. To resolve this just add the line $option = get_option( 'wpseo' ); before $option['ms_defaults_set'] = true;.

    https://www.ads-software.com/extend/plugins/wordpress-seo/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter iDope

    (@idope)

    This is how it should look like after the fix:

    function multisite_defaults() {
    		$option = get_option( 'wpseo' );
    		if ( function_exists( 'is_multisite' ) && is_multisite() && !is_array( $option ) ) {
    			$options = get_site_option( 'wpseo_ms' );
    			if ( is_array( $options ) && isset( $options['defaultblog'] ) && !empty( $options['defaultblog'] ) && $options['defaultblog'] != 0 ) {
    				foreach ( get_wpseo_options_arr() as $option ) {
    					update_option( $option, get_blog_option( $options['defaultblog'], $option ) );
    				}
    			}
    			$option = get_option( 'wpseo' );
    			$option['ms_defaults_set'] = true;
    			update_option( 'wpseo', $option );
    		}
    	}
    Thread Starter iDope

    (@idope)

    One more thing, you will need to delete the bad ‘wpseo’ setting that has been saved to the db. Using phpMyAdmin or something similar logon to your db and open the wp_{blogid}_options table (where {blogid} is the blog id of the blog which is giving the error). Look for a ‘wpseo’ option (it should have the value ‘1pseo_social’) and delete it.

    Thanks worked for me!

    I’m not sure I completely understand the code, but wouldn’t it be better to rename the variable in the foreach statement? Like so:

    function multisite_defaults() {
    		$option = get_option( 'wpseo' );
    		if ( function_exists( 'is_multisite' ) && is_multisite() && !is_array( $option ) ) {
    			$options = get_site_option( 'wpseo_ms' );
    			if ( is_array( $options ) && isset( $options['defaultblog'] ) && !empty( $options['defaultblog'] ) && $options['defaultblog'] != 0 ) {
    				foreach ( get_wpseo_options_arr() as $wpseo_option ) {
    					update_option( $wpseo_option, get_blog_option( $options['defaultblog'], $wpseo_option ) );
    				}
    			}
    			$option['ms_defaults_set'] = true;
    			update_option( 'wpseo', $option );
    		}
    	}

    I mean, the problem seems to be that the programmer expects $option to still have the same value while in reality it has been overridden in the foreach statement.

    Thread Starter iDope

    (@idope)

    I mean, the problem seems to be that the programmer expects $option to still have the same value while in reality it has been overridden in the foreach statement.

    That is correct but you need to get the latest value of ‘wpseo’ before updating it. That’s why this line is needed
    $option = get_option( 'wpseo' );

    Alternatively, you could set $option['ms_defaults_set'] = true; within the foreach loop when the option key is ‘wpseo’;

    Very well. I’ve fixed it with your solution, for now, and I’ve directed the author to this thread.

    Thanks this fixes helped me alot and save my time. Can you please help me with one of my query, I have few existing subsites, which is not taking existing seo settings, what should I do to make it work?

    @idope and others; thanks for the fix. Happened today while adding a new site to my multisite. This fixed it lickidy split!

    Anyone able to answer Savita’s question and have a query that fixes the DB automatically instead of manually looking one by one?

    Hi. I tried to go in and remove the s on update_options on line 141 but I dn’t see that, mine says manage_options not update_options. Is that the same? I have the latest version 1.4.10

    But I was told by my hosting that my 500 server errors are coming from line 344. plugins/wordpress-seo/inc/wpseo-functions.php on line 344
    but I am not sure what I need to do there. It doesn’t give me this error all the time but at least half of the time. Can someone please help me with this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Bug in loading Default Blog Settings (multisite)’ is closed to new replies.