WordPress.org

Support

Support » Plugins and Hacks » WordPress MU Domain Mapping » [Plugin: WordPress MU Domain Mapping] Performance: MU-DM Javascript takes lots of time to get genera

[Plugin: WordPress MU Domain Mapping] Performance: MU-DM Javascript takes lots of time to get genera

  • A small problem with a script by wordpress-mu-domain-mapping – it slows down my site a lot. It looks like this:

    http://sectio-aurea.org/?dm=7b66257d40972188e443498008bdcc5f&action=load&blogid=19&siteid=1&t=1245958239&back=http%3A%2F%2Fblog.ruhrmobil-e.de%2F

    To see the problem of slowdown have a look at this site: http://tools.pingdom.com/fpt/ (try http://blog.ruhrmobil-e.de). I get this line at http://blog.ruhrmobil-e.de/, my main site is http://sectio-aurea.org/. Its generated in domain mapping plugin file line 797:
    //echo "<script src='{$protocol}{$current_site->domain}{$current_site->path}?dm={$hash}&action=load&blogid={$current_blog->blog_id}&siteid={$current_blog->site_id}&t=" . mt_rand() . "&back=" . urlencode( $protocol . $current_blog->domain . $_SERVER[ 'REQUEST_URI' ] ) . "' type='text/javascript'></script>";

    Its part of this function (line 787ff):
    function remote_login_js_loader() {

    It seems to get generated in this function line 739ff:

    function remote_login_js() {
            global $current_blog, $current_user, $wpdb;
    
            if ( 0 == get_site_option( 'dm_remote_login' ) )
                    return false;
    
            $wpdb->dmtablelogins = $wpdb->base_prefix . 'domain_mapping_logins';
            $hash = get_dm_hash();
            if ( false == isset( $_SERVER[ 'HTTPS' ] ) )
                    $_SERVER[ 'HTTPS' ] = 'Off';
            $protocol = ( 'on' == strtolower( $_SERVER[ 'HTTPS' ] ) ) ? 'https://' : 'http://';
            if ( $_GET[ 'dm' ] == $hash ) {
                    if ( $_GET[ 'action' ] == 'load' ) {
                            if ( !is_user_logged_in() )
                                    exit;
                            $key = md5( time() . mt_rand() );
                            $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->dmtablelogins} ( <code>id</code>, <code>user_id</code>, <code>blog_id</code>, <code>t</code> ) VALUES( %s, %d, %d, NOW() )", $key, $current_user->ID, $_GET[ 'blogid' ] ) );
                            $url = add_query_arg( array( 'action' => 'login', 'dm' => $hash, 'k' => $key, 't' => mt_rand() ), $_GET[ 'back' ] );
                            echo "window.location = '$url'";
                            exit;
                    } elseif ( $_GET[ 'action' ] == 'login' ) {
                            if ( $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->dmtablelogins} WHERE id = %s AND blog_id = %d", $_GET[ 'k' ], $wpdb->blogid ) ) ) {
                                    if ( $details->blog_id == $wpdb->blogid ) {
                                            $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->dmtablelogins} WHERE id = %s", $_GET[ 'k' ] ) );
                                            $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->dmtablelogins} WHERE t < %d", ( time() - 120 ) ) ); // remote logins survive for only 2 minutes if not used.
                                            wp_set_auth_cookie( $details->user_id );
                                            wp_redirect( remove_query_arg( array( 'dm', 'action', 'k', 't', $protocol . $current_blog->domain . $_SERVER[ 'REQUEST_URI' ] ) ) );
                                            exit;
                                    } else {
                                            wp_die( __( "Incorrect or out of date login key", 'wordpress-mu-domain-mapping' ) );
                                    }
                            } else {
                                    wp_die( __( "Unknown login key", 'wordpress-mu-domain-mapping' ) );
                            }
                    } elseif ( $_GET[ 'action' ] == 'logout' ) {
                            if ( $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->dmtablelogins} WHERE id = %d AND blog_id = %d", $_GET[ 'k' ], $_GET[ 'blogid' ] ) ) ) {
                                    $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->dmtablelogins} WHERE id = %s", $_GET[ 'k' ] ) );
                                    $blog = get_blog_details( $_GET[ 'blogid' ] );
                                    wp_clear_auth_cookie();
                                    wp_redirect( trailingslashit( $blog->siteurl ) . "wp-login.php?loggedout=true" );
                                    exit;
                            } else {
                                    wp_die( __( "Unknown logout key", 'wordpress-mu-domain-mapping' ) );
                            }
                    }
            }
    }

    I don’t really have an idea what exacly this function does, especially because its is empty (or perhaps I just don’t get the moment where it’s not empty).

    So – can somebody help me out …

    • … understanding what exacly this function does
    • … understanding why its in top (and not at bottom)
    • … make this function much faster?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ron Rennick

    @wpmuguru

    MultiSite Guru

    Turn off the remote login setting to eliminate the script.

    Is there a way to make the script more powerful?

    Using sessions?

    What do you think?

    The transition between a blog and the other takes 12 seconds

    I’m glad I found this thread. I noticed that everytime I had multiple domains on one WordPress installation, it would take forever for a site to load.

    Also, I have a blog on the same installation as my professional site, and I definitely want my blog to be unconnected to my professional identity, but because of this script, my professional domain loads in the status bar when my blog loads.

    Furthermore, the plugin will not save my settings when I change them. I am running 0.5.2 on WordPress 3.3.1, and I don’t know whether an upgrade would fix this problem, or even how to upgrade this plugin, as it does not show in the normal plugin list, even in network admin.

    Any advice would be greatly appreciated. Thanks.

    Plugin Author Ron Rennick

    @wpmuguru

    MultiSite Guru

    Is there a way to make the script more powerful?

    Using sessions?

    PHP sessions cannot be shared between domains.

    You have to chose between the convenience of single sign on and inconvenience of the delay. Personally I would never use the single sign on. Every browser has the option to store the saved username & password so logging in is only an extra click.

    Plugin Author Ron Rennick

    @wpmuguru

    MultiSite Guru

    @publicradio – turn off the remote login feature if you don’t want to be logged in everywhere at the same time.

    The settings issue is fixed in the latest version. The latest version only has bug & compatibility fixes from the previous version.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress MU Domain Mapping] Performance: MU-DM Javascript takes lots of time to get genera’ is closed to new replies.
Skip to toolbar