Make WordPress Core

Ticket #2409: 500_error_when_database_fubar.diff

File 500_error_when_database_fubar.diff, 1.8 KB (added by markjaquith, 19 years ago)
  • wp-includes/wp-db.php

     
    305305        function bail($message) { // Just wraps errors in a nice header and footer
    306306        if ( !$this->show_errors )
    307307                return false;
     308        status_header( 500 );
    308309        header( 'Content-Type: text/html; charset=utf-8');             
    309310        echo <<<HEAD
    310311        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    360361}
    361362
    362363$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    363 ?>
    364  No newline at end of file
     364?>
  • wp-includes/functions.php

     
    21832183        $wp->main($query_vars);
    21842184}
    21852185
    2186 function status_header( $header ) {
    2187         if ( 200 == $header )
    2188                 $text = 'OK';
    2189         elseif ( 301 == $header )
    2190                 $text = 'Moved Permanently';
    2191         elseif ( 302 == $header )
    2192                 $text = 'Moved Temporarily';
    2193         elseif ( 304 == $header )
    2194                 $text = 'Not Modified';
    2195         elseif ( 404 == $header )
    2196                 $text = 'Not Found';
    2197         elseif ( 410 == $header )
    2198                 $text = 'Gone';
    2199 
     2186function status_header( $header, $text='' ) {
     2187        if ( '' == $text) {
     2188                if ( 200 == $header )
     2189                        $text = 'OK';
     2190                elseif ( 301 == $header )
     2191                        $text = 'Moved Permanently';
     2192                elseif ( 302 == $header )
     2193                        $text = 'Moved Temporarily';
     2194                elseif ( 304 == $header )
     2195                        $text = 'Not Modified';
     2196                elseif ( 404 == $header )
     2197                        $text = 'Not Found';
     2198                elseif ( 410 == $header )
     2199                        $text = 'Gone';
     2200                elseif ( 500 == $header )
     2201                        $text = 'Database Not Available';
     2202        }
    22002203        @header("HTTP/1.1 $header $text");
    22012204        @header("Status: $header $text");
    22022205}