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
// If file does not exist
if ( ! $file->isFile())
{
// Return default value
return $default;
}
else
{
// Open the file and extract the json
$json = $file->openFile()->current();
// Decode the json into PHP object
$data = json_decode($json);
// Test the expiry
if ($data->expiry < time())
{
// Delete the file
$this->_delete_file($file, NULL, TRUE);
// Return default value
return $default;
}
else
{
return ($data->type === 'string') ? $data->payload : unserialize($data->payload);
}
}
There is a chance to read the file contents while another thread is writing to a file.
I've caught that just once for 2 years, and this is how the exception looked like:
Kohana_Cache_Exception [ 0 ]: Kohana_Cache_File::get failed to unserialize cached object with message : Trying to get property of non-object ~ MODPATH/cache/classes/kohana/cache/file.php [ 170 ]
So I think that the file was written only partially and $json contained malformed json, what leaded to a NULL in $data.
Proposed solution - add if (!$data) return $default; after decoding
The text was updated successfully, but these errors were encountered:
There is a chance to read the file contents while another thread is writing to a file.
I've caught that just once for 2 years, and this is how the exception looked like:
So I think that the file was written only partially and $json contained malformed json, what leaded to a
NULL
in$data
.Proposed solution - add
if (!$data) return $default;
after decodingThe text was updated successfully, but these errors were encountered: