WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Bug in loading Default Blog Settings (multisite) (11 posts)

  1. iDope
    Member
    Posted 1 year ago #

    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;.

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

  2. iDope
    Member
    Posted 1 year ago #

    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 );
    		}
    	}
  3. iDope
    Member
    Posted 1 year ago #

    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.

  4. jumpmuz
    Member
    Posted 1 year ago #

    Thanks worked for me!

  5. waltervos
    Member
    Posted 1 year ago #

    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.

  6. iDope
    Member
    Posted 1 year ago #

    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';

  7. waltervos
    Member
    Posted 1 year ago #

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

  8. Savita
    Member
    Posted 1 year ago #

    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?

  9. David Radovanovic
    Member
    Posted 1 year ago #

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

  10. Denis Lam
    Member
    Posted 1 year ago #

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

  11. ladan
    Member
    Posted 10 months ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.