WordPress.org

Make WordPress Core

Changeset 14342


Ignore:
Timestamp:
05/02/2010 09:34:11 PM (10 years ago)
Author:
wpmuguru
Message:

strip www from subdomains in blog lookup, see #13104

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-blogs.php

    r14076 r14342  
    9090            if ( false !== $blog )
    9191                return $blog;
    92             $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
     92            if ( substr( $domain, 0, 4 ) == 'www.' ) {
     93                $nowww = substr( $domain, 4 );
     94                $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'] ) );
     95            } else {
     96                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
     97            }
    9398            if ( $blog ) {
    9499                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
     
    102107            if ( false !== $blog )
    103108                return $blog;
    104             $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
     109            if ( substr( $domain, 0, 4 ) == 'www.' ) {
     110                $nowww = substr( $domain, 4 );
     111                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
     112            } else {
     113                $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
     114            }
    105115            if ( $blog ) {
    106116                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
Note: See TracChangeset for help on using the changeset viewer.