Skip to content

Commit 10fa457

Browse files
committed
Fix "Trying to access array offset on null" warning, since the return value of error_get_last() can be null #17365
1 parent 49cfd3b commit 10fa457

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

framework/caching/FileCache.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,14 @@ protected function setValue($key, $value, $duration)
158158
return @touch($cacheFile, $duration + time());
159159
}
160160

161-
$error = error_get_last();
162-
Yii::warning("Unable to write cache file '{$cacheFile}': {$error['message']}", __METHOD__);
161+
$message = "Unable to write cache file '{$cacheFile}'";
162+
163+
if ($error = error_get_last()) {
164+
$message .= ": {$error['message']}";
165+
}
166+
167+
Yii::warning($message, __METHOD__);
168+
163169
return false;
164170
}
165171

0 commit comments

Comments
 (0)