]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/ms-load.php
WordPress 4.3
[autoinstalls/wordpress.git] / wp-includes / ms-load.php
index 66047bcc0dd748edf9062dc76117cb67bdbd3f8b..e067193f46c5389f0aa16f1d9d827fd8cdfcd3b0 100644 (file)
@@ -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 <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
- * 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 );
@@ -389,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  = '<h1>' . $title . '</h1>';
-       if ( ! is_admin() )
-               die( $msg );
        $msg .= '<p>' . __( '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.' ) . '</p>';
-       if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
-               $msg .= '<p>' . sprintf( __( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted <code>%s</code>. You really should look at your database now.' ), $wpdb->site ) . '</p>';
-       else
-               $msg .= '<p>' . sprintf( __( '<strong>Could not find site <code>%1$s</code>.</strong> Searched for table <code>%2$s</code> in database <code>%3$s</code>. Is that right?' ), rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '</p>';
+       $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
+       if ( ! $wpdb->get_var( $query ) ) {
+               $msg .= '<p>' . sprintf(
+                       /* translators: %s: table name */
+                       __( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.' ),
+                       '<code>' . $wpdb->site . '</code>'
+               ) . '</p>';
+       } else {
+               $msg .= '<p>' . sprintf(
+                       /* translators: 1: site url, 2: table name, 3: database name */
+                       __( '<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?' ),
+                       '<code>' . rtrim( $domain . $path, '/' ) . '</code>',
+                       '<code>' . $wpdb->blogs . '</code>',
+                       '<code>' . DB_NAME . '</code>'
+               ) . '</p>';
+       }
        $msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> ';
-       $msg .= __( 'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_a_WordPress_Network">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' );
+       $msg .= __( 'Read the <a target="_blank" href="https://codex.wordpress.org/Debugging_a_WordPress_Network">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' );
        $msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>';
        foreach ( $wpdb->tables('global') as $t => $table ) {
                if ( 'sitecategories' == $t )
@@ -415,7 +439,7 @@ function ms_not_installed() {
        }
        $msg .= '</ul>';
 
-       wp_die( $msg, $title );
+       wp_die( $msg, $title, array( 'response' => 500 ) );
 }
 
 /**
@@ -426,13 +450,13 @@ function ms_not_installed() {
  *
  * @access private
  * @since 3.0.0
- * @deprecated 3.9.0
+ * @deprecated 3.9.0 Use get_current_site() instead.
  *
  * @param object $current_site
  * @return object
  */
 function get_current_site_name( $current_site ) {
-       _deprecated_function( __FUNCTION__, '3.9' );
+       _deprecated_function( __FUNCTION__, '3.9', 'get_current_site()' );
        return $current_site;
 }
 
@@ -446,6 +470,8 @@ function get_current_site_name( $current_site ) {
  * @since 3.0.0
  * @deprecated 3.9.0
  *
+ * @global object $current_site
+ *
  * @return object
  */
 function wpmu_current_site() {