MDL-53206 caching: Ensure get_many and set_many dereference objects.

This commit is contained in:
Russell Smith
2016-02-29 15:59:21 +11:00
parent e50cd7c14f
commit a8ee2c885d
3 changed files with 42 additions and 3 deletions
+2 -2
View File
@@ -190,9 +190,9 @@ class cachestore_dummy extends cache_store {
foreach ($keyvaluearray as $pair) {
$this->store[$pair['key']] = $pair['value'];
}
return count($keyvaluearray);
}
return 0;
return count($keyvaluearray);
}
/**
+13
View File
@@ -450,6 +450,13 @@ class cache implements cache_loader {
// Create an array with the original keys and the found values. This will be what we return.
$fullresult = array();
foreach ($result as $key => $value) {
if (!is_scalar($value)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
// Call the function to unreference it (in the best way possible).
$value = $this->unref($value);
}
$fullresult[$parsedkeys[$key]] = $value;
}
unset($result);
@@ -1922,6 +1929,12 @@ class cache_session extends cache {
if ($value instanceof cache_cached_object) {
/* @var cache_cached_object $value */
$value = $value->restore_object();
} else if (!is_scalar($value)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
// Call the function to unreference it (in the best way possible).
$value = $this->unref($value);
}
$return[$key] = $value;
if ($value === false) {