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
df52510f
Commit
df52510f
authored
Jan 27, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed potential problem about using unset variables.
CS fix.
parent
505cb7d6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
14 deletions
+12
-14
Cache.php
framework/caching/Cache.php
+12
-14
No files found.
framework/caching/Cache.php
View file @
df52510f
...
@@ -232,14 +232,14 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -232,14 +232,14 @@ abstract class Cache extends Component implements \ArrayAccess
$data
=
[];
$data
=
[];
foreach
(
$items
as
$key
=>
$value
)
{
foreach
(
$items
as
$key
=>
$value
)
{
$itemKey
=
$this
->
buildKey
(
$key
);
if
(
$this
->
serializer
===
null
)
{
if
(
$this
->
serializer
===
null
)
{
$
itemV
alue
=
serialize
([
$value
,
$dependency
]);
$
v
alue
=
serialize
([
$value
,
$dependency
]);
}
elseif
(
$this
->
serializer
!==
false
)
{
}
elseif
(
$this
->
serializer
!==
false
)
{
$
itemV
alue
=
call_user_func
(
$this
->
serializer
[
0
],
[
$value
,
$dependency
]);
$
v
alue
=
call_user_func
(
$this
->
serializer
[
0
],
[
$value
,
$dependency
]);
}
}
$data
[
$itemKey
]
=
$itemValue
;
$key
=
$this
->
buildKey
(
$key
);
$data
[
$key
]
=
$value
;
}
}
return
$this
->
setValues
(
$data
,
$expire
);
return
$this
->
setValues
(
$data
,
$expire
);
}
}
...
@@ -263,14 +263,14 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -263,14 +263,14 @@ abstract class Cache extends Component implements \ArrayAccess
$data
=
[];
$data
=
[];
foreach
(
$items
as
$key
=>
$value
)
{
foreach
(
$items
as
$key
=>
$value
)
{
$itemKey
=
$this
->
buildKey
(
$key
);
if
(
$this
->
serializer
===
null
)
{
if
(
$this
->
serializer
===
null
)
{
$
itemV
alue
=
serialize
([
$value
,
$dependency
]);
$
v
alue
=
serialize
([
$value
,
$dependency
]);
}
elseif
(
$this
->
serializer
!==
false
)
{
}
elseif
(
$this
->
serializer
!==
false
)
{
$
itemV
alue
=
call_user_func
(
$this
->
serializer
[
0
],
[
$value
,
$dependency
]);
$
v
alue
=
call_user_func
(
$this
->
serializer
[
0
],
[
$value
,
$dependency
]);
}
}
$data
[
$itemKey
]
=
$itemValue
;
$key
=
$this
->
buildKey
(
$key
);
$data
[
$key
]
=
$value
;
}
}
return
$this
->
addValues
(
$data
,
$expire
);
return
$this
->
addValues
(
$data
,
$expire
);
}
}
...
@@ -389,7 +389,7 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -389,7 +389,7 @@ abstract class Cache extends Component implements \ArrayAccess
/**
/**
* Stores multiple key-value pairs in cache.
* Stores multiple key-value pairs in cache.
* The default implementation calls [[setValue()]] multiple times store values one by one. If the underlying cache
* The default implementation calls [[setValue()]] multiple times store values one by one. If the underlying cache
* storage supports multiset, this method should be overridden to exploit that feature.
* storage supports multi
-
set, this method should be overridden to exploit that feature.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $expire the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $expire the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
* @return array array of failed keys
...
@@ -397,8 +397,7 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -397,8 +397,7 @@ abstract class Cache extends Component implements \ArrayAccess
protected
function
setValues
(
$data
,
$expire
)
protected
function
setValues
(
$data
,
$expire
)
{
{
$failedKeys
=
[];
$failedKeys
=
[];
foreach
(
$data
as
$key
=>
$value
)
foreach
(
$data
as
$key
=>
$value
)
{
{
if
(
$this
->
setValue
(
$key
,
$value
,
$expire
)
===
false
)
{
if
(
$this
->
setValue
(
$key
,
$value
,
$expire
)
===
false
)
{
$failedKeys
[]
=
$key
;
$failedKeys
[]
=
$key
;
}
}
...
@@ -409,7 +408,7 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -409,7 +408,7 @@ abstract class Cache extends Component implements \ArrayAccess
/**
/**
* Adds multiple key-value pairs to cache.
* Adds multiple key-value pairs to cache.
* The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache
* The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache
* storage supports multiadd, this method should be overridden to exploit that feature.
* storage supports multi
-
add, this method should be overridden to exploit that feature.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $expire the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $expire the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
* @return array array of failed keys
...
@@ -417,8 +416,7 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -417,8 +416,7 @@ abstract class Cache extends Component implements \ArrayAccess
protected
function
addValues
(
$data
,
$expire
)
protected
function
addValues
(
$data
,
$expire
)
{
{
$failedKeys
=
[];
$failedKeys
=
[];
foreach
(
$data
as
$key
=>
$value
)
foreach
(
$data
as
$key
=>
$value
)
{
{
if
(
$this
->
addValue
(
$key
,
$value
,
$expire
)
===
false
)
{
if
(
$this
->
addValue
(
$key
,
$value
,
$expire
)
===
false
)
{
$failedKeys
[]
=
$key
;
$failedKeys
[]
=
$key
;
}
}
...
...
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