[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:
https://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: https://tools.pingdom.com/fpt/ (try https://blog.ruhrmobil-e.de). I get this line at https://blog.ruhrmobil-e.de/, my main site is https://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://' : 'https://'; 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!
- The topic ‘[Plugin: WordPress MU Domain Mapping] Performance: MU-DM Javascript takes lots of time to get genera’ is closed to new replies.