Make WordPress Core

Changeset 5446


Ignore:
Timestamp:
05/11/2007 03:34:50 AM (19 years ago)
Author:
rob1n
Message:

New status_header code, and WP-DB bail() errors send a 503 Service Unavailable. see #2409

Also, the new header code to text array has 302 as Found. fixes #4183

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r5428 r5446  
    917917}
    918918
     919function get_status_header_desc( $code ) {
     920        global $wp_header_to_desc;
     921       
     922        $code = (int) $code;
     923       
     924        if ( isset( $wp_header_to_desc[$code] ) ) {
     925                return $wp_header_to_desc[$code];
     926        } else {
     927                return '';
     928        }
     929}
     930
    919931function status_header( $header ) {
    920         if ( 200 == $header )
    921                 $text = 'OK';
    922         elseif ( 301 == $header )
    923                 $text = 'Moved Permanently';
    924         elseif ( 302 == $header )
    925                 $text = 'Moved Temporarily';
    926         elseif ( 304 == $header )
    927                 $text = 'Not Modified';
    928         elseif ( 404 == $header )
    929                 $text = 'Not Found';
    930         elseif ( 410 == $header )
    931                 $text = 'Gone';
    932 
    933         if ( version_compare(phpversion(), '4.3.0', '>=') )
    934                 @header("HTTP/1.1 $header $text", true, $header);
    935         else
    936                 @header("HTTP/1.1 $header $text");
     932        $text = get_status_header( $header );
     933       
     934        if ( empty( $text ) ) {
     935                return false;
     936        } else {
     937                if ( version_compare( phpversion(), '4.3.0', '>=' ) ) {
     938                        return @header( "HTTP/1.1 $header $text", true, $header );
     939                } else {
     940                        return @header( "HTTP/1.1 $header $text" );
     941                }
     942        }
    937943}
    938944
  • trunk/wp-includes/vars.php

    r5063 r5446  
    3636$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;
    3737
     38$wp_header_to_desc = apply_filters( 'wp_header_to_desc_array', array(
     39        100 => 'Continue',
     40        101 => 'Switching Protocols',
     41       
     42        200 => 'OK',
     43        201 => 'Created',
     44        202 => 'Accepted',
     45        203 => 'Non-Authoritative Information',
     46        204 => 'No Content',
     47        205 => 'Reset Content',
     48        206 => 'Partial Content',
     49       
     50        300 => 'Multiple Choices',
     51        301 => 'Moved Permanently',
     52        302 => 'Found',
     53        303 => 'See Other',
     54        304 => 'Not Modified',
     55        305 => 'Use Proxy',
     56        307 => 'Temporary Redirect',
     57       
     58        400 => 'Bad Request',
     59        401 => 'Unauthorized',
     60        403 => 'Forbidden',
     61        404 => 'Not Found',
     62        405 => 'Method Not Allowed',
     63        406 => 'Not Acceptable',
     64        407 => 'Proxy Authentication Required',
     65        408 => 'Request Timeout',
     66        409 => 'Conflict',
     67        410 => 'Gone',
     68        411 => 'Length Required',
     69        412 => 'Precondition Failed',
     70        413 => 'Request Entity Too Large',
     71        414 => 'Request-URI Too Long',
     72        415 => 'Unsupported Media Type',
     73        416 => 'Requested Range Not Satisfiable',
     74        417 => 'Expectation Failed',
     75       
     76        500 => 'Internal Server Error',
     77        501 => 'Not Implemented',
     78        502 => 'Bad Gateway',
     79        503 => 'Service Unavailable',
     80        504 => 'Gateway Timeout',
     81        505 => 'HTTP Version Not Supported'
     82) );
     83
    3884?>
  • trunk/wp-includes/wp-db.php

    r5195 r5446  
    370370                if ( !$this->show_errors )
    371371                        return false;
    372 
     372               
     373                status_header( 503 );
    373374                header('Content-Type: text/html; charset=utf-8');
    374375
Note: See TracChangeset for help on using the changeset viewer.