Commit 9a68678d by Qiang Xue

Additional fix to #4728.

parent 45dbbc39
...@@ -152,9 +152,9 @@ class HttpCache extends ActionFilter ...@@ -152,9 +152,9 @@ class HttpCache extends ActionFilter
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
// HTTP_IF_NONE_MATCH takes precedence over HTTP_IF_MODIFIED_SINCE // HTTP_IF_NONE_MATCH takes precedence over HTTP_IF_MODIFIED_SINCE
// http://tools.ietf.org/html/rfc7232#section-3.3 // http://tools.ietf.org/html/rfc7232#section-3.3
return $etag === null || in_array($etag, Yii::$app->request->getEtags(), true); return $etag !== null && in_array($etag, Yii::$app->request->getEtags(), true);
} elseif (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { } elseif (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
return $lastModified === null || @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified; return $lastModified !== null && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModified;
} else { } else {
return $etag === null && $lastModified === null; return $etag === null && $lastModified === null;
} }
......
...@@ -51,7 +51,7 @@ class HttpCacheTest extends \yiiunit\TestCase ...@@ -51,7 +51,7 @@ class HttpCacheTest extends \yiiunit\TestCase
$this->assertFalse($method->invoke($httpCache, 0, '"foos"')); $this->assertFalse($method->invoke($httpCache, 0, '"foos"'));
$this->assertTrue($method->invoke($httpCache, 1, '"foo"')); $this->assertTrue($method->invoke($httpCache, 1, '"foo"'));
$this->assertFalse($method->invoke($httpCache, 1, '"foos"')); $this->assertFalse($method->invoke($httpCache, 1, '"foos"'));
$this->assertTrue($method->invoke($httpCache, null, null)); $this->assertFalse($method->invoke($httpCache, null, null));
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment