X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2FPhoto.php;h=d87bce478704fccb6489097269e2e83163a4fd5f;hb=747dc934f73643933fb46a720dd0570069eaf36a;hp=3f1608d3ecb8099f3d814a5503eb4964bc6e2656;hpb=863d49ccd01aaf1a83510e613d82a9beb6a43c61;p=friendica.git diff --git a/include/Photo.php b/include/Photo.php index 3f1608d3ec..d87bce4787 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -726,10 +726,11 @@ function guess_image_type($filename, $fromcurl=false) { * @param string $avatar Link to avatar picture * @param int $uid User id of contact owner * @param int $cid Contact id + * @param bool $force force picture update * * @return array Returns array of the different avatar sizes */ -function update_contact_avatar($avatar,$uid,$cid) { +function update_contact_avatar($avatar,$uid,$cid, $force = false) { $r = q("SELECT `avatar`, `photo`, `thumb`, `micro` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid)); if (!$r) @@ -737,7 +738,7 @@ function update_contact_avatar($avatar,$uid,$cid) { else $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]); - if ($r[0]["avatar"] != $avatar) { + if (($r[0]["avatar"] != $avatar) OR $force) { $photos = import_profile_photo($avatar,$uid,$cid, true); if ($photos) { @@ -822,9 +823,12 @@ function get_photo_info($url) { $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")) @@ -845,8 +849,7 @@ function get_photo_info($url) { $data["size"] = $filesize; Cache::set($url, serialize($data)); - } else - $data = unserialize($data); + } return $data; }