Ticket #23021: 23021.5.diff

File 23021.5.diff, 1.8 KB (added by slene, 5 months ago)

should be unset Last-Modified header when it empty.

Line 
1Index: wp-includes/functions.php
2===================================================================
3--- wp-includes/functions.php   (revision 23195)
4+++ wp-includes/functions.php   (working copy)
5@@ -902,7 +902,6 @@
6 function wp_get_nocache_headers() {
7        $headers = array(
8                'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
9-               'Last-Modified' => '',
10                'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
11                'Pragma' => 'no-cache',
12        );
13@@ -910,6 +909,10 @@
14        if ( function_exists('apply_filters') ) {
15                $headers = (array) apply_filters('nocache_headers', $headers);
16        }
17+
18+       if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) )
19+               unset( $headers['Last-Modified'] ); // The Last-Modified header should not be empty
20+
21        return $headers;
22 }
23 
24@@ -926,8 +929,6 @@
25        $headers = wp_get_nocache_headers();
26        foreach( $headers as $name => $field_value )
27                @header("{$name}: {$field_value}");
28-       if ( empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
29-               @header_remove( 'Last-Modified' );
30 }
31 
32 /**
33Index: wp-includes/class-wp.php
34===================================================================
35--- wp-includes/class-wp.php    (revision 23195)
36+++ wp-includes/class-wp.php    (working copy)
37@@ -376,14 +376,14 @@
38 
39                $headers = apply_filters('wp_headers', $headers, $this);
40 
41+               if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) )
42+                       unset( $headers['Last-Modified'] ); // The Last-Modified header should not be empty
43+
44                if ( ! empty( $status ) )
45                        status_header( $status );
46                foreach( (array) $headers as $name => $field_value )
47                        @header("{$name}: {$field_value}");
48 
49-               if ( isset( $headers['Last-Modified'] ) && empty( $headers['Last-Modified'] ) && function_exists( 'header_remove' ) )
50-                       @header_remove( 'Last-Modified' );
51-
52                if ( $exit_required )
53                        exit();
54