Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443915
Commits
3ee31d17
Commit
3ee31d17
authored
10 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2265977
by olli: fixed php backend serialization.
parent
f03e93cb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lib/Drupal/Core/Cache/PhpBackend.php
+2
-17
2 additions, 17 deletions
core/lib/Drupal/Core/Cache/PhpBackend.php
core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
+6
-0
6 additions, 0 deletions
...al/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
with
8 additions
and
17 deletions
core/lib/Drupal/Core/Cache/PhpBackend.php
+
2
−
17
View file @
3ee31d17
...
...
@@ -254,23 +254,8 @@ public function removeBin() {
* The cache item to store.
*/
protected
function
writeItem
(
$cid
,
\stdClass
$item
)
{
$data
=
str_replace
(
'\\'
,
'\\\\'
,
serialize
(
$item
));
// Data can contain 'EOF' or 'EOF;', either of which cause a fatal PHP
// error when the cache item is read back from disk. To guard against this,
// dynamically generate a heredoc EOF string that is not contained in $data.
$suffix
=
''
;
do
{
$EOF
=
'EOF'
.
$suffix
;
}
while
(
$suffix
++
<
1000
&&
(
$unsafe_eof_in_data
=
preg_match
(
'/^'
.
$EOF
.
';?$/m'
,
$data
)));
if
(
!
$unsafe_eof_in_data
)
{
$content
=
"<?php return unserialize(<<<
$EOF
$data
$EOF
);"
;
$this
->
storage
()
->
save
(
$cid
,
$content
);
}
$content
=
'<?php return unserialize('
.
var_export
(
serialize
(
$item
),
TRUE
)
.
');'
;
$this
->
storage
()
->
save
(
$cid
,
$content
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
+
6
−
0
View file @
3ee31d17
...
...
@@ -181,6 +181,12 @@ public function testSetGet() {
$this
->
assertTrue
(
$cached
->
valid
,
'Item is marked as valid.'
);
$this
->
assertEqual
(
$cached
->
created
,
REQUEST_TIME
,
'Created time is correct.'
);
$this
->
assertEqual
(
$cached
->
expire
,
Cache
::
PERMANENT
,
'Expire time is correct.'
);
$with_variable
=
array
(
'foo'
=>
'$bar'
);
$backend
->
set
(
'test6'
,
$with_variable
);
$cached
=
$backend
->
get
(
'test6'
);
$this
->
assert
(
is_object
(
$cached
),
"Backend returned an object for cache id test6."
);
$this
->
assertIdentical
(
$with_variable
,
$cached
->
data
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment