From 03b4e1f0aa4367fd5a005481b185a1c7e248332c Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sat, 7 Mar 2015 05:34:47 +0000 Subject: [PATCH] Return HTTP status code 500 by default in ms_not_installed() In admin views, specify a response code of 500 when using `wp_die()` to show an expanded message for a broken or missing multisite installation. On front end views, use `dead_db()` rather than `die()` to generate the generic "Error establishing a database connection" message. `dead_db()` sets a status code of 500 by default and allows for the override of this generic error with a `db-error.php` template. Props craig-ralston, jeremyfelt. Fixes #30002. git-svn-id: https://develop.svn.wordpress.org/trunk@31657 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-load.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/ms-load.php b/src/wp-includes/ms-load.php index 6e3344e391..64f6b2f784 100644 --- a/src/wp-includes/ms-load.php +++ b/src/wp-includes/ms-load.php @@ -395,13 +395,15 @@ function get_site_by_path( $domain, $path, $segments = null ) { function ms_not_installed() { global $wpdb, $domain, $path; + if ( ! is_admin() ) { + dead_db(); + } + wp_load_translations_early(); $title = __( 'Error establishing a database connection' ); + $msg = '

' . $title . '

'; - if ( ! is_admin() ) { - die( $msg ); - } $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.' ) . '

'; $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) ); @@ -420,7 +422,7 @@ function ms_not_installed() { } $msg .= ''; - wp_die( $msg, $title ); + wp_die( $msg, $title, array( 'response' => 500 ) ); } /**