You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/DOFileCache.php
+43-11Lines changed: 43 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,16 @@ public function get($key)
115
115
returnfalse;
116
116
}
117
117
118
+
// Check cache object format
119
+
if (!isset($cacheObj->content) || !isset($cacheObj->expiryTimestamp)) {
120
+
returnfalse;
121
+
}
122
+
123
+
// Check cache content is serialized
124
+
if (!$this->isSerialized($cacheObj->content)) {
125
+
returnfalse;
126
+
}
127
+
118
128
if (!function_exists('sys_getloadavg') && $this->config['unixLoadUpperThreshold'] !== -1) {
119
129
thrownewException('Your PHP installation does not support `sys_getloadavg` (Windows?). Please set `unixLoadUpperThreshold` to `-1` in your DOFileCache config.');
120
130
}
@@ -127,23 +137,45 @@ public function get($key)
127
137
128
138
if ($cacheObj->expiryTimestamp > time() || $unixLoad[0] >= $this->config['unixLoadUpperThreshold']) {
129
139
// Cache item has not yet expired or system load is too high
130
-
$content = $cacheObj->content;
131
-
132
-
if (($unserializedContent = unserialize($content)) !== false) {
133
-
// Normal unserialization
134
-
$content = $unserializedContent;
135
-
} elseif ($content == serialize(false)) {
136
-
// Edge case to handle boolean false being stored
137
-
$content = false;
138
-
}
139
-
140
-
return$content;
140
+
returnunserialize($cacheObj->content);
141
141
} else {
142
142
// Cache item has expired
143
143
returnfalse;
144
144
}
145
145
}
146
146
147
+
/**
148
+
* Check if the string contains serialized data
149
+
*
150
+
* @param string $string
151
+
*
152
+
* @return bool
153
+
*/
154
+
publicfunctionisSerialized($string)
155
+
{
156
+
if (!is_string($string)) {
157
+
returnfalse;
158
+
}
159
+
160
+
if ($string === 'N;') {
161
+
returntrue;
162
+
}
163
+
164
+
if (strlen($string) < 4) {
165
+
returnfalse;
166
+
}
167
+
168
+
if ($string[1] !== ':') {
169
+
returnfalse;
170
+
}
171
+
172
+
if (!in_array($string[0], ['s', 'a', 'O', 'b', 'i', 'd'])) {
0 commit comments