WordPress.org

Make WordPress Core

Ticket #21837: 21837.diff

File 21837.diff, 1.6 KB (added by georgestephanis, 5 years ago)
  • src/wp-includes/ms-blogs.php

     
    124124                                $nowww = substr( $fields['domain'], 4 );
    125125                                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
    126126                        } else {
    127                                 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
     127                                $www = "www.{$fields['domain']}";
     128                                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) ASC", $fields['domain'], $www, $fields['path'] ) );
    128129                        }
    129130                        if ( $blog ) {
    130131                                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
     
    141142                                $nowww = substr( $fields['domain'], 4 );
    142143                                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
    143144                        } else {
    144                                 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
     145                                $www = "www.{$fields['domain']}";
     146                                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) ASC", $fields['domain'], $www ) );
    145147                        }
    146148                        if ( $blog ) {
    147149                                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');