From 612af2ad85d2e3da7a86d7d1b1c394e815839fe1 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 16 May 2013 16:52:06 -0400 Subject: [PATCH] Using anonymous function instead of eval for timestamp. --- yii/behaviors/AutoTimestamp.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yii/behaviors/AutoTimestamp.php b/yii/behaviors/AutoTimestamp.php index 3387cae..944ee05 100644 --- a/yii/behaviors/AutoTimestamp.php +++ b/yii/behaviors/AutoTimestamp.php @@ -47,8 +47,8 @@ class AutoTimestamp extends Behavior */ public $updateAttribute = 'update_time'; /** - * @var string|Expression The expression that will be used for generating the timestamp. - * This can be either a string representing a PHP expression (e.g. 'time()'), + * @var \Closure|Expression The expression that will be used for generating the timestamp. + * This can be either an anonymous function that returns the timestamp value, * or an [[Expression]] object representing a DB expression (e.g. `new Expression('NOW()')`). * If not set, it will use the value of `time()` to fill the attributes. */ @@ -97,7 +97,7 @@ class AutoTimestamp extends Behavior if ($this->timestamp instanceof Expression) { return $this->timestamp; } elseif ($this->timestamp !== null) { - return eval('return ' . $this->timestamp . ';'); + return call_user_func($this->timestamp); } else { return time(); }