X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/41578db67d72562346e4dbb2a14889b23d522813..e0feb3b2e5b436a06bbb04fbc838d1cd6ec95399:/wp-includes/ms-load.php?ds=sidebyside
diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php
index ee99398d..e067193f 100644
--- a/wp-includes/ms-load.php
+++ b/wp-includes/ms-load.php
@@ -19,22 +19,19 @@ function is_subdomain_install() {
if ( defined('SUBDOMAIN_INSTALL') )
return SUBDOMAIN_INSTALL;
- if ( defined('VHOST') && VHOST == 'yes' )
- return true;
-
- return false;
+ return ( defined( 'VHOST' ) && VHOST == 'yes' );
}
/**
* Returns array of network plugin files to be included in global scope.
*
* The default directory is wp-content/plugins. To change the default directory
- * manually, define WP_PLUGIN_DIR
and WP_PLUGIN_URL
- * in wp-config.php.
+ * manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` in `wp-config.php`.
*
* @access private
* @since 3.1.0
- * @return array Files to include
+ *
+ * @return array Files to include.
*/
function wp_get_active_network_plugins() {
$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
@@ -68,7 +65,7 @@ function wp_get_active_network_plugins() {
*
* @since 3.0.0
*
- * @return bool|string Returns true on success, or drop-in file to include.
+ * @return true|string Returns true on success, or drop-in file to include.
*/
function ms_site_check() {
$blog = get_blog_details();
@@ -92,7 +89,7 @@ function ms_site_check() {
if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
return WP_CONTENT_DIR . '/blog-deleted.php';
else
- wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ), '', array( 'response' => 410 ) );
+ wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
}
if ( '2' == $blog->deleted ) {
@@ -117,15 +114,17 @@ function ms_site_check() {
*
* @since 3.9.0
*
+ * @global wpdb $wpdb
+ *
* @param string $domain Domain to check.
* @param string $path Path to check.
* @param int|null $segments Path segments to use. Defaults to null, or the full path.
- * @return object|bool Network object if successful. False when no network is found.
+ * @return object|false Network object if successful. False when no network is found.
*/
function get_network_by_path( $domain, $path, $segments = null ) {
global $wpdb;
- $domains = $exact_domains = array( $domain );
+ $domains = array( $domain );
$pieces = explode( '.', $domain );
/*
@@ -260,8 +259,10 @@ function get_network_by_path( $domain, $path, $segments = null ) {
*
* @since 3.9.0
*
+ * @global wpdb $wpdb
+ *
* @param object|int $network The network's database row or ID.
- * @return object|bool Object containing network information if found, false if not.
+ * @return object|false Object containing network information if found, false if not.
*/
function wp_get_network( $network ) {
global $wpdb;
@@ -281,10 +282,12 @@ function wp_get_network( $network ) {
*
* @since 3.9.0
*
+ * @global wpdb $wpdb
+ *
* @param string $domain Domain to check.
* @param string $path Path to check.
* @param int|null $segments Path segments to use. Defaults to null, or the full path.
- * @return object|bool Site object if successful. False when no site is found.
+ * @return object|false Site object if successful. False when no site is found.
*/
function get_site_by_path( $domain, $path, $segments = null ) {
global $wpdb;
@@ -308,6 +311,8 @@ function get_site_by_path( $domain, $path, $segments = null ) {
$path_segments = array_slice( $path_segments, 0, $segments );
}
+ $paths = array();
+
while ( count( $path_segments ) ) {
$paths[] = '/' . implode( '/', $path_segments ) . '/';
array_pop( $path_segments );
@@ -348,13 +353,30 @@ function get_site_by_path( $domain, $path, $segments = null ) {
* then cache whether we can just always ignore paths.
*/
+ // Either www or non-www is supported, not both. If a www domain is requested,
+ // query for both to provide the proper redirect.
+ $domains = array( $domain );
+ if ( 'www.' === substr( $domain, 0, 4 ) ) {
+ $domains[] = substr( $domain, 4 );
+ $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'";
+ }
+
if ( count( $paths ) > 1 ) {
- $paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'";
- $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain );
- $sql .= " AND path IN ($paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1";
+ $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'";
+ }
+
+ if ( count( $domains ) > 1 && count( $paths ) > 1 ) {
+ $site = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE domain IN ($search_domains) AND path IN ($search_paths) ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC LIMIT 1" );
+ } elseif ( count( $domains ) > 1 ) {
+ $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE path = %s", $paths[0] );
+ $sql .= " AND domain IN ($search_domains) ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1";
+ $site = $wpdb->get_row( $sql );
+ } elseif ( count( $paths ) > 1 ) {
+ $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domains[0] );
+ $sql .= " AND path IN ($search_paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1";
$site = $wpdb->get_row( $sql );
} else {
- $site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s and path = %s", $domain, $paths[0] ) );
+ $site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domains[0], $paths[0] ) );
}
if ( $site ) {
@@ -372,24 +394,43 @@ function get_site_by_path( $domain, $path, $segments = null ) {
*
* @access private
* @since 3.0.0
+ *
+ * @global wpdb $wpdb
+ * @global string $domain
+ * @global string $path
*/
function ms_not_installed() {
global $wpdb, $domain, $path;
+ if ( ! is_admin() ) {
+ dead_db();
+ }
+
wp_load_translations_early();
$title = __( 'Error establishing a database connection' );
+
$msg = '
' . __( 'If your site does not display, please contact the owner of this network.' ) . ''; $msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '
'; - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ) - $msg .= '' . sprintf( __( 'Database tables are missing. This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s
. You really should look at your database now.' ), $wpdb->site ) . '
' . sprintf( __( 'Could not find site %1$s
. Searched for table %2$s
in database %3$s
. Is that right?' ), rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '
' . sprintf(
+ /* translators: %s: table name */
+ __( 'Database tables are missing. This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.' ),
+ '' . $wpdb->site . '
'
+ ) . '
' . sprintf(
+ /* translators: 1: site url, 2: table name, 3: database name */
+ __( 'Could not find site %1$s. Searched for table %2$s in database %3$s. Is that right?' ),
+ '' . rtrim( $domain . $path, '/' ) . '
',
+ '' . $wpdb->blogs . '
',
+ '' . DB_NAME . '
'
+ ) . '
' . __( 'What do I do now?' ) . ' '; - $msg .= __( 'Read the bug report page. Some of the guidelines there may help you figure out what went wrong.' ); + $msg .= __( 'Read the bug report page. Some of the guidelines there may help you figure out what went wrong.' ); $msg .= ' ' . __( 'If you’re still stuck with this message, then check that your database contains the following tables:' ) . '