$data = Cache::get($url);
- if (is_null($data)) {
- $img_str = fetch_url($url, true, $redirects, 4);
+ // Unserialise to be able to check in the next step if the cached data is alright.
+ if (!is_null($data))
+ $data = unserialize($data);
+ if (is_null($data) OR !$data) {
+ $img_str = fetch_url($url, true, $redirects, 4);
$filesize = strlen($img_str);
if (function_exists("getimagesizefromstring"))
$data["size"] = $filesize;
Cache::set($url, serialize($data));
- } else
- $data = unserialize($data);
+ }
return $data;
}