Make WordPress Core

Ticket #26407: patch.diff

File patch.diff, 1.9 KB (added by codix, 11 years ago)
  • wp-includes/ms-settings.php

    From 0dd06a24dacd1c765bdec0fb9a449301bb7d26a8 Mon Sep 17 00:00:00 2001
    From: S H Mohanjith <moha@mohanjith.net>
    Date: Wed, 4 Dec 2013 21:32:11 +0200
    Subject: [PATCH] What if the user got the path right but the domain wrong
    
    ---
     wp-includes/ms-settings.php | 13 ++++++++++++-
     1 file changed, 12 insertions(+), 1 deletion(-)
    
    diff --git a/wp-includes/ms-settings.php b/wp-includes/ms-settings.php
    index f740569..81732f3 100644
    a b if ( !isset( $current_site ) || !isset( $current_blog ) ) { 
    7878                        if ( $current_blog )
    7979                                wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' );
    8080                }
     81                // One last check with current site domain and given path
     82                $possible_current_blog = wp_cache_get( 'current_blog_' . $current_site->domain . $path, 'site-options' );
     83                if ( ! $possible_current_blog ) {
     84                        $possible_current_blog = get_blog_details( array( 'domain' => $current_site->domain, 'path' => $path ), false );
     85                        if ( $possible_current_blog )
     86                                wp_cache_set( 'current_blog_' . $current_site->domain . $path, $possible_current_blog, 'site-options' );
     87        }
    8188                unset($reserved_blognames);
    8289        }
    8390
    if ( !isset( $current_site ) || !isset( $current_blog ) ) { 
    96103        if ( ! defined( 'WP_INSTALLING' ) ) {
    97104                if ( $current_site && ! $current_blog ) {
    98105                        if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
    99                                 header( 'Location: http://' . $current_site->domain . $current_site->path );
     106                                if ( isset( $possible_current_blog ) && $possible_current_blog ) {
     107                    header( 'Location: http://' . $possible_current_blog->domain . $possible_current_blog->path );
     108                } else {
     109                                        header( 'Location: http://' . $current_site->domain . $current_site->path );
     110                                }
    100111                                exit;
    101112                        }
    102113                        $current_blog = get_blog_details( array( 'domain' => $current_site->domain, 'path' => $current_site->path ), false );