Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions advanced-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,14 @@ function ob($output) {
}

if ( !empty( $this->cache['headers'] ) && !empty( $this->uncached_headers ) ) {
foreach ( $this->uncached_headers as $header )
unset( $this->cache['headers'][$header] );
foreach ( $this->uncached_headers as $h ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we can't use the full descriptive variable name? $h may be quicker to type but it hides the purpose of the variable and makes the rest of the code less readable

foreach ( array_keys( $this->cache['headers'] ) as $k ) {
if ( strcasecmp( $k, $h ) === 0 ) {
unset( $this->cache['headers'][ $k ] );
break;
}
}
}
Comment on lines +261 to +268
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we can reduce the nested for loops with array_map/filter/walk?

}

foreach ( $this->cache['headers'] as $header => $values ) {
Expand Down Expand Up @@ -591,7 +597,7 @@ function set_query( $query_string ) {

// Respect ETags served with feeds.
$three04 = false;
if ( isset( $SERVER['HTTP_IF_NONE_MATCH'] ) && isset( $batcache->cache['headers']['ETag'][0] ) && $_SERVER['HTTP_IF_NONE_MATCH'] == $batcache->cache['headers']['ETag'][0] )
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && isset( $batcache->cache['headers']['ETag'][0] ) && $_SERVER['HTTP_IF_NONE_MATCH'] === $batcache->cache['headers']['ETag'][0] )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

$three04 = true;

// Respect If-Modified-Since.
Expand Down