From 607f3a59873167f18e8f9fb74455982c899d6dd0 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 2 Jun 2013 07:11:27 -0400 Subject: [PATCH] Fixes issue #476 --- framework/yii/caching/FileCache.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/framework/yii/caching/FileCache.php b/framework/yii/caching/FileCache.php index 0c6d119..1dbcb09 100644 --- a/framework/yii/caching/FileCache.php +++ b/framework/yii/caching/FileCache.php @@ -25,8 +25,9 @@ class FileCache extends Cache { /** * @var string the directory to store cache files. You may use path alias here. + * If not set, it will use the "cache" subdirectory under the application runtime path. */ - public $cachePath = '@app/runtime/cache'; + public $cachePath; /** * @var string cache file suffix. Defaults to '.bin'. */ @@ -51,7 +52,11 @@ class FileCache extends Cache public function init() { parent::init(); - $this->cachePath = Yii::getAlias($this->cachePath); + if ($this->cachePath === null) { + $this->cachePath = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'cache'; + } else { + $this->cachePath = Yii::getAlias($this->cachePath); + } if (!is_dir($this->cachePath)) { mkdir($this->cachePath, 0777, true); }