diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 8f66d98929..ce88c102cf 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -505,8 +505,8 @@ class WP { } $wp_last_modified .= ' GMT'; + $wp_etag = '"' . md5( $wp_last_modified ) . '"'; - $wp_etag = '"' . md5( $wp_last_modified ) . '"'; $headers['Last-Modified'] = $wp_last_modified; $headers['ETag'] = $wp_etag; @@ -514,19 +514,24 @@ class WP { if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); } else { - $client_etag = false; + $client_etag = ''; + } + + if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { + $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); + } else { + $client_last_modified = ''; } - $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); // If string is empty, return 0. If not, attempt to parse into a timestamp. $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; - // Make a timestamp for our most recent modification.. + // Make a timestamp for our most recent modification. $wp_modified_timestamp = strtotime( $wp_last_modified ); - if ( ( $client_last_modified && $client_etag ) ? - ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag === $wp_etag ) ) : - ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) ) + if ( ( $client_last_modified && $client_etag ) + ? ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag === $wp_etag ) ) + : ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) ) ) { $status = 304; $exit_required = true; diff --git a/wp-includes/ms-files.php b/wp-includes/ms-files.php index 6026a71db6..c909a32407 100644 --- a/wp-includes/ms-files.php +++ b/wp-includes/ms-files.php @@ -54,30 +54,36 @@ if ( WPMU_ACCEL_REDIRECT ) { exit; } -$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) ); -$etag = '"' . md5( $last_modified ) . '"'; -header( "Last-Modified: $last_modified GMT" ); -header( 'ETag: ' . $etag ); +$wp_last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) ); +$wp_etag = '"' . md5( $wp_last_modified ) . '"'; + +header( "Last-Modified: $wp_last_modified GMT" ); +header( 'ETag: ' . $wp_etag ); header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); // Support for conditional GET - use stripslashes() to avoid formatting.php dependency. -$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; - -if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { - $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false; +if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { + $client_etag = stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ); +} else { + $client_etag = ''; +} + +if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { + $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); +} else { + $client_last_modified = ''; } -$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); // If string is empty, return 0. If not, attempt to parse into a timestamp. $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; -// Make a timestamp for our most recent modification... -$modified_timestamp = strtotime( $last_modified ); +// Make a timestamp for our most recent modification. +$wp_modified_timestamp = strtotime( $wp_last_modified ); if ( ( $client_last_modified && $client_etag ) - ? ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) - : ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) - ) { + ? ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag === $wp_etag ) ) + : ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) ) +) { status_header( 304 ); exit; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 625993eb23..edb84c6356 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56394'; +$wp_version = '6.4-alpha-56395'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.