Ticket #23021: 23021.4.diff
| File 23021.4.diff, 3.4 KB (added by nacin, 5 months ago) |
|---|
-
wp-includes/functions.php
902 902 function wp_get_nocache_headers() { 903 903 $headers = array( 904 904 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 905 'Last-Modified' => '',906 905 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 907 906 'Pragma' => 'no-cache', 908 907 ); 909 908 910 909 if ( function_exists('apply_filters') ) { 911 910 $headers = (array) apply_filters('nocache_headers', $headers); 911 unset( $headers['Last-Modified'] ); 912 912 } 913 913 return $headers; 914 914 } … … 924 924 */ 925 925 function nocache_headers() { 926 926 $headers = wp_get_nocache_headers(); 927 928 // In PHP 5.3+, make sure we are not sending a Last-Modified header. 929 if ( function_exists( 'header_remove' ) ) { 930 @header_remove( 'Last-Modified' ); 931 } else { 932 // In PHP 5.2, send an empty Last-Modified header, but only as a 933 // last resort to override a header already sent. #WP23021 934 foreach ( headers_list() as $header ) { 935 if ( 0 === stripos( $header, 'Last-Modified' ) ) { 936 $headers['Last-Modified'] = ''; 937 break; 938 } 939 } 940 } 941 927 942 foreach( $headers as $name => $field_value ) 928 943 @header("{$name}: {$field_value}"); 929 if ( empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )930 @header_remove( 'Last-Modified' );931 944 } 932 945 933 946 /** -
wp-includes/class-wp.php
319 319 function send_headers() { 320 320 $headers = array('X-Pingback' => get_bloginfo('pingback_url')); 321 321 $status = null; 322 $exit_required = false;322 $exit_required = $nocache_headers = false; 323 323 324 if ( is_user_logged_in() ) 324 if ( is_user_logged_in() ) { 325 325 $headers = array_merge($headers, wp_get_nocache_headers()); 326 $nocache_headers = true; 327 } 326 328 if ( ! empty( $this->query_vars['error'] ) ) { 327 329 $status = (int) $this->query_vars['error']; 328 330 if ( 404 === $status ) { 329 if ( ! is_user_logged_in() ) 331 if ( ! is_user_logged_in() ) { 330 332 $headers = array_merge($headers, wp_get_nocache_headers()); 333 $nocache_headers = true; 334 } 331 335 $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); 332 336 } elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) { 333 337 $exit_required = true; … … 378 382 379 383 if ( ! empty( $status ) ) 380 384 status_header( $status ); 385 386 if ( $nocache_headers || empty( $headers['Last-Modified'] ) ) { 387 unset( $headers['Last-Modified'] ); 388 389 // In PHP 5.3+, make sure we are not sending a Last-Modified header. 390 if ( function_exists( 'header_remove' ) ) { 391 @header_remove( 'Last-Modified' ); 392 } else { 393 // In PHP 5.2, send an empty Last-Modified header, but only as a 394 // last resort to override a header already sent. #WP23021 395 foreach ( headers_list() as $header ) { 396 if ( 0 === stripos( $header, 'Last-Modified' ) ) { 397 $headers['Last-Modified'] = ''; 398 break; 399 } 400 } 401 } 402 } 403 381 404 foreach( (array) $headers as $name => $field_value ) 382 405 @header("{$name}: {$field_value}"); 383 406 384 if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )385 @header_remove( 'Last-Modified' );386 387 407 if ( $exit_required ) 388 408 exit(); 389 409
