Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
612af2ad
Commit
612af2ad
authored
May 16, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using anonymous function instead of eval for timestamp.
parent
be189fc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
AutoTimestamp.php
yii/behaviors/AutoTimestamp.php
+3
-3
No files found.
yii/behaviors/AutoTimestamp.php
View file @
612af2ad
...
@@ -47,8 +47,8 @@ class AutoTimestamp extends Behavior
...
@@ -47,8 +47,8 @@ class AutoTimestamp extends Behavior
*/
*/
public
$updateAttribute
=
'update_time'
;
public
$updateAttribute
=
'update_time'
;
/**
/**
* @var
string
|Expression The expression that will be used for generating the timestamp.
* @var
\Closure
|Expression The expression that will be used for generating the timestamp.
* This can be either a
string representing a PHP expression (e.g. 'time()')
,
* This can be either a
n anonymous function that returns the timestamp value
,
* or an [[Expression]] object representing a DB expression (e.g. `new Expression('NOW()')`).
* 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.
* If not set, it will use the value of `time()` to fill the attributes.
*/
*/
...
@@ -97,7 +97,7 @@ class AutoTimestamp extends Behavior
...
@@ -97,7 +97,7 @@ class AutoTimestamp extends Behavior
if
(
$this
->
timestamp
instanceof
Expression
)
{
if
(
$this
->
timestamp
instanceof
Expression
)
{
return
$this
->
timestamp
;
return
$this
->
timestamp
;
}
elseif
(
$this
->
timestamp
!==
null
)
{
}
elseif
(
$this
->
timestamp
!==
null
)
{
return
eval
(
'return '
.
$this
->
timestamp
.
';'
);
return
call_user_func
(
$this
->
timestamp
);
}
else
{
}
else
{
return
time
();
return
time
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment