From 4fe13c937f139a7537893ccccb0ed7ebe76032c8 Mon Sep 17 00:00:00 2001 From: resurtm Date: Wed, 3 Apr 2013 23:10:54 +0600 Subject: [PATCH 1/3] ChainedDependency typo fix. --- framework/caching/ChainedDependency.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/caching/ChainedDependency.php b/framework/caching/ChainedDependency.php index 9c4e547..af34e9d 100644 --- a/framework/caching/ChainedDependency.php +++ b/framework/caching/ChainedDependency.php @@ -57,7 +57,7 @@ class ChainedDependency extends Dependency if (!$dependency instanceof Dependency) { $dependency = \Yii::createObject($dependency); } - $dependency->evalulateDependency(); + $dependency->evaluateDependency(); } } From aad6e6c8ce17cf2ea239d556b34312aab5886c76 Mon Sep 17 00:00:00 2001 From: resurtm Date: Thu, 4 Apr 2013 00:01:09 +0600 Subject: [PATCH 2/3] Unused `use` has been removed. --- framework/widgets/FragmentCache.php | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/widgets/FragmentCache.php b/framework/widgets/FragmentCache.php index dae538a..637d115 100644 --- a/framework/widgets/FragmentCache.php +++ b/framework/widgets/FragmentCache.php @@ -8,7 +8,6 @@ namespace yii\widgets; use Yii; -use yii\base\InvalidConfigException; use yii\base\Widget; use yii\caching\Cache; use yii\caching\Dependency; From b9a835518a581ccf517d163ad662d322e13e7fc3 Mon Sep 17 00:00:00 2001 From: resurtm Date: Thu, 4 Apr 2013 00:05:09 +0600 Subject: [PATCH 3/3] Fixes issue related to the cache dependencies constructor parameters. (Discussed via Skype with Qiang.) --- framework/caching/DbDependency.php | 18 ++++++++---------- framework/caching/ExpressionDependency.php | 13 +------------ framework/caching/FileDependency.php | 16 +++++++++------- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/framework/caching/DbDependency.php b/framework/caching/DbDependency.php index cbe0ae1..4308dc1 100644 --- a/framework/caching/DbDependency.php +++ b/framework/caching/DbDependency.php @@ -28,25 +28,23 @@ class DbDependency extends Dependency public $db = 'db'; /** * @var string the SQL query whose result is used to determine if the dependency has been changed. - * Only the first row of the query result will be used. + * Only the first row of the query result will be used. This property must be always set, otherwise + * an exception would be raised. */ public $sql; /** * @var array the parameters (name=>value) to be bound to the SQL statement specified by [[sql]]. */ - public $params; + public $params = array(); /** - * Constructor. - * @param string $sql the SQL query whose result is used to determine if the dependency has been changed. - * @param array $params the parameters (name=>value) to be bound to the SQL statement specified by [[sql]]. - * @param array $config name-value pairs that will be used to initialize the object properties + * Initializes the database dependency object. */ - public function __construct($sql, $params = array(), $config = array()) + public function init() { - $this->sql = $sql; - $this->params = $params; - parent::__construct($config); + if ($this->sql === null) { + throw new InvalidConfigException('DbDependency::sql must be set.'); + } } /** diff --git a/framework/caching/ExpressionDependency.php b/framework/caching/ExpressionDependency.php index e13c962..bf70291 100644 --- a/framework/caching/ExpressionDependency.php +++ b/framework/caching/ExpressionDependency.php @@ -22,18 +22,7 @@ class ExpressionDependency extends Dependency /** * @var string the PHP expression whose result is used to determine the dependency. */ - public $expression; - - /** - * Constructor. - * @param string $expression the PHP expression whose result is used to determine the dependency. - * @param array $config name-value pairs that will be used to initialize the object properties - */ - public function __construct($expression = 'true', $config = array()) - { - $this->expression = $expression; - parent::__construct($config); - } + public $expression = 'true'; /** * Generates the data needed to determine if dependency has been changed. diff --git a/framework/caching/FileDependency.php b/framework/caching/FileDependency.php index 3797dde..8d858ec 100644 --- a/framework/caching/FileDependency.php +++ b/framework/caching/FileDependency.php @@ -7,6 +7,8 @@ namespace yii\caching; +use yii\base\InvalidConfigException; + /** * FileDependency represents a dependency based on a file's last modification time. * @@ -20,19 +22,19 @@ class FileDependency extends Dependency { /** * @var string the name of the file whose last modification time is used to - * check if the dependency has been changed. + * check if the dependency has been changed. This property must be always set, + * otherwise an exception would be raised. */ public $fileName; /** - * Constructor. - * @param string $fileName name of the file whose change is to be checked. - * @param array $config name-value pairs that will be used to initialize the object properties + * Initializes the database dependency object. */ - public function __construct($fileName = null, $config = array()) + public function init() { - $this->fileName = $fileName; - parent::__construct($config); + if ($this->file === null) { + throw new InvalidConfigException('FileDependency::fileName must be set.'); + } } /**