WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/11/2007 03:34:50 AM (14 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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.