MDL-78466 cache: Perform strict test on static cache values

If a statically accelerated cache returns an empty array then the value
was still fetched from the non-static cache store.

The check of the `$result` should be strictly checked against `false`,
which is the value used if no value was found.
This commit is contained in:
Andrew Nicols
2023-06-14 09:28:53 +08:00
parent 71c36d2de1
commit 5c6ebcd5f5
2 changed files with 160 additions and 3 deletions
+3 -3
View File
@@ -470,7 +470,7 @@ class cache implements cache_loader {
}
} else {
// If there's no result, obviously it doesn't meet the required version.
if (!$result) {
if ($result === false) {
return false;
}
if (!($result instanceof \core_cache\version_wrapper)) {
@@ -503,7 +503,7 @@ class cache implements cache_loader {
if ($usesstaticacceleration) {
$result = $this->static_acceleration_get($key);
if ($result && self::check_version($result, $requiredversion)) {
if ($result !== false && self::check_version($result, $requiredversion)) {
if ($requiredversion === self::VERSION_NONE) {
return $result;
} else {
@@ -518,7 +518,7 @@ class cache implements cache_loader {
// 3. Get it from the store. Obviously wasn't in the static acceleration array.
$result = $this->store->get($parsedkey);
if ($result) {
if ($result !== false) {
// Check the result has at least the required version.
try {
$validversion = self::check_version($result, $requiredversion);