diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 32591c8..e5ab767 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.14 under development ------------------------ +- Bug #14811: Fixed `yii\filters\HttpCache` to work with PHP 7.2 (samdark) - Bug #8983: Only truncate the original log file for rotation (matthewyang, developeruz) - Bug #11401: Fixed `yii\web\DbSession` concurrency issues when writing and regenerating IDs (samdark, andreasanta, cebe) - Bug #13034: Fixed `normalizePath` for windows network shares that start with two backslashes (developeruz) diff --git a/framework/filters/HttpCache.php b/framework/filters/HttpCache.php index 5daf232..b69be0c 100644 --- a/framework/filters/HttpCache.php +++ b/framework/filters/HttpCache.php @@ -189,7 +189,8 @@ class HttpCache extends ActionFilter header_remove('Last-Modified'); header_remove('Pragma'); } - session_cache_limiter($this->sessionCacheLimiter); + + Yii::$app->getSession()->setCacheLimiter($this->sessionCacheLimiter); } $headers = Yii::$app->getResponse()->getHeaders(); diff --git a/framework/web/Session.php b/framework/web/Session.php index 39ac6e3..a3550b9 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -954,4 +954,28 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co $this->frozenSessionData = null; } } + + /** + * Set cache limiter + * + * @param string $cacheLimiter + * @since 2.0.14 + */ + public function setCacheLimiter($cacheLimiter) + { + $this->freeze(); + session_cache_limiter($cacheLimiter); + $this->unfreeze(); + } + + /** + * Returns current cache limiter + * + * @return string current cache limiter + * @since 2.0.14 + */ + public function getCacheLimiter() + { + return session_cache_limiter(); + } } diff --git a/tests/framework/web/CacheSessionTest.php b/tests/framework/web/session/CacheSessionTest.php similarity index 96% rename from tests/framework/web/CacheSessionTest.php rename to tests/framework/web/session/CacheSessionTest.php index c73a960..018d164 100644 --- a/tests/framework/web/CacheSessionTest.php +++ b/tests/framework/web/session/CacheSessionTest.php @@ -5,7 +5,7 @@ * @license http://www.yiiframework.com/license/ */ -namespace yiiunit\framework\web; +namespace yiiunit\framework\web\session; use Yii; use yii\caching\FileCache;