Make WordPress Core

Ticket #27003: 27003.22.diff

File 27003.22.diff, 3.9 KB (added by jeremyfelt, 11 years ago)

Documents a dark area of ms-settings

  • src/wp-includes/ms-settings.php

     
    6767        } elseif ( ! is_subdomain_install() ) {
    6868                /*
    6969                 * A "subdomain" install can be re-interpreted to mean "can support any domain".
    70                  * If we're not dealing with one of these installs, then the important part is determing
     70                 * If we're not dealing with one of these installs, then the important part is determining
    7171                 * the network first, because we need the network's path to identify any sites.
    7272                 */
    7373                if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) {
     
    108108                $current_site = wp_get_network( $current_blog->site_id );
    109109        }
    110110
    111         // If we don't have a network by now, we have a problem.
     111        // If a site has not been found and we are installing multisite, use a temporary ID.
     112        if ( empty( $current_blog ) && defined( 'WP_INSTALLING' ) ) {
     113                $current_blog->blog_id = $blog_id = 1;
     114        }
     115
    112116        if ( empty( $current_site ) ) {
     117                // No network has been found. Without a network, no site can exist.
    113118                ms_not_installed();
     119        } elseif ( empty( $current_blog ) && ! defined( 'WP_INSTALLING' ) ) {
     120                // A network is available, but we have not found the requested site on the network. Redirect if possible.
     121                // @todo site_not_found action to provide custom redirect. see #21143
     122                if ( is_subdomain_install() ) {
     123                        // In a subdomain with closed registration, administrators are instructed to set
     124                        // NOBLOGREDIRECT to redirect visitors who visit an invalid subdomain. If this
     125                        // is not set, we assume a redirect to wp-signup.php is intentional.
     126                        if ( defined( 'NOBLOGREDIRECT' ) ) {
     127                                if ( '%siteurl%' === NOBLOGREDIRECT ) {
     128                                        // network_home_url() is not available to us yet.
     129                                        $destination = "http://" . $current_site->domain . $current_site->path;
     130                                } else {
     131                                        $destination = NOBLOGREDIRECT;
     132                                }
     133                        } else {
     134                                $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
     135                        }
     136                        header( 'Location: ' . $destination );
     137                        exit;
     138                } elseif ( 0 !== strcasecmp( $current_site->domain, $domain ) ) {
     139                        // If a subdomain was requested for a subdirectory configuration and could not be found,
     140                        // or if an unfound domain was requested for a subdirectory configuration and could not
     141                        // be found on the single network, redirect to the network's primary domain and path.
     142                        header( 'Location: http://' . $current_site->domain . $current_site->path );
     143                        exit;
     144                }
     145
     146                // Multiple networks exist in a subdirectory installation and the requested
     147                // domain does not match a site on any of them.
     148                ms_not_installed();
    114149        }
    115150
    116151        // @todo What if the domain of the network doesn't match the current site?
     
    130165                }
    131166        }
    132167
    133         // If we haven't figured out our site, give up.
    134         if ( empty( $current_blog ) ) {
    135                 if ( defined( 'WP_INSTALLING' ) ) {
    136                         $current_blog->blog_id = $blog_id = 1;
    137 
    138                 } elseif ( is_subdomain_install() ) {
    139                         // @todo This is only for an open registration subdomain network.
    140                         if ( defined( 'NOBLOGREDIRECT' ) ) {
    141                                 if ( '%siteurl%' === NOBLOGREDIRECT ) {
    142                                         $destination = "http://" . $current_site->domain . $current_site->path;
    143                                 } else {
    144                                         $destination = NOBLOGREDIRECT;
    145                                 }
    146                         } else {
    147                                 $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
    148                         }
    149                         header( 'Location: ' . $destination );
    150                         exit;
    151 
    152                 } else {
    153                         if ( 0 !== strcasecmp( $current_site->domain, $domain ) ) {
    154                                 header( 'Location: http://' . $current_site->domain . $current_site->path );
    155                                 exit;
    156                         }
    157                         ms_not_installed();
    158                 }
    159         }
    160 
    161168        $blog_id = $current_blog->blog_id;
    162169        $public  = $current_blog->public;
    163170