Viewing 15 replies - 1 through 15 (of 15 total)
  • I could not get get_current_site() to work, but I did find that commenting out two lines of sunrise.php as specified here does the trick. Since sunrise seems to set the $current_site variable twice, there don’t seem to be ill effects to eliminating the redundant code.

    It would be nice if the plugin were updated with this fix.

    Plugin Author Ron Rennick

    (@wpmuguru)

    @ecceleste – get_current_site() returns an object not a string. You need to use the site_name member of the object.

    The problem is get_current_site() isn’t available at the time sunrise.php is loaded.

    https://core.trac.wordpress.org/ticket/14965

    Plugin Author Ron Rennick

    (@wpmuguru)

    The problem is get_current_site() isn’t available at the time sunrise.php is loaded.

    That’s not what that trac ticket was about. If the function didn’t exist all installs running domain mapping would white screen.

    At the time sunrise.php is executed the $current_site object does not have the name attribute.

    Here is a code fix for this issue. Update the reference at the end of sunrise.php:

    if( function_exists( 'get_current_site' ) )
    {
    	$current_site_obj = get_current_site( $current_site );
    	$current_site = $current_site_obj->site_name;
    }

    What exactly does setting $current_site do? When I try out jonbeddoes fix then the function does in fact NOT exist, so the code does not run, yet everything seems to work fine. So is it not really required to set $current_site?

    Hi khromov,

    I am sorry my solution didn’t help you. I must admit I didn’t consider the outcome if the function was never called. In my case I was simply trying to modify the sunrise.php file to keep it’s behavior the same as it was before. Because the get_current_site_name() function was deprecated I essentially achieve the same thing with those two lines. Once I made this update my warnings went away.

    Are you running multiple sites through the domain mapping plugin? Do you have any warnings still? If not then you should probably assume everything is working as expected πŸ™‚

    JB

    You’re right jonbeddoes, the function doesn’t do anything as of WP 3.9.

    After removing the $current_site stuff, I had one deprecation warning left:

    Notice: wpdb::escape is <strong>deprecated</strong> since version 3.6! Use wpdb::prepare() or esc_sql() instead.

    It wasn’t all that easy though, as esc_sql() is not defined yet in sunrise, however you can use the hidden method $wpdb->_escape(); to get rid of the deprecation warnings. So just change every instance of $wpdb->escape(); to $wpdb->_escape();

    But I’m a bit worried about the state of this plugin. Is it actually usable or are there a lot of hidden edge cases and bugs?

    Plugin Author Ron Rennick

    (@wpmuguru)

    Notice: wpdb::escape is deprecated since version 3.6! Use wpdb::prepare() or esc_sql() instead.

    Download the development version. That warning has been fixed.

    What exactly does setting $current_site do?

    That’s necessary to bypass the core site lookup.

    @khromov I had that warning issue too but that change fixes it indeed. @RonRennick good to know that the official version fixes that too.

    @RonRennick Out of interest, are you happy with the proposed fix I suggested above for the other warning that spawned after the 3.9 update?

    Plugin Author Ron Rennick

    (@wpmuguru)

    @jonbeddoes – it looks good but I haven’t had a chance to test it.

    @RonRennick – jonbeddoes’s solution worked perfectly for wp3.9.1

    @jonbeddoes – Thank you!

    Plugin Author Ron Rennick

    (@wpmuguru)

    @haitham – jonbeddoes’s solution doesn’t actually do anything. It eliminates the warning by removing the function call. If you just deleted the code the warning would also go away.

    The development version has the warning fixed.

    @RonRennick – bit confused by your response;
    I wrote code to mimic the same functionality as was there before, but your suggestion to remove the code implies it has no purpose and is never executed?

    If that is the case, what change(a) did you make in the development version instead if it’s not my change and not deleting the code fragment? πŸ™‚

    Plugin Author Ron Rennick

    (@wpmuguru)

    but your suggestion to remove the code implies it has no purpose and is never executed?

    I didn’t say it didn’t execute. I said it didn’t do anything. The code below processes but doesn’t do anything:

    function get_x() {
    global $x;
    return $x;
    }
    
    $x = 1;
    $x = get_x( $x );
    // $x is 1

    https://plugins.trac.wordpress.org/changeset?sfp_email=&sfph_mail=&reponame=&new=940547%40wordpress-mu-domain-mapping&old=940546%40wordpress-mu-domain-mapping&sfp_email=&sfph_mail=

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Minor: get_current_site_name() Deprecated in 3.9’ is closed to new replies.