From 5580c0d70857551d2e548c9c9e350f43ca8e11a4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 10:59:06 +0200 Subject: [PATCH] Bugfix: Sometimes uploaded pictures weren't posted correctly to other networks --- include/Photo.php | 10 ++++++---- include/plaintext.php | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/Photo.php b/include/Photo.php index 91fce55a86..d87bce4787 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -823,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")) @@ -846,8 +849,7 @@ function get_photo_info($url) { $data["size"] = $filesize; Cache::set($url, serialize($data)); - } else - $data = unserialize($data); + } return $data; } diff --git a/include/plaintext.php b/include/plaintext.php index e18604334b..793f9935a7 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -189,6 +189,13 @@ function get_attached_data($body) { if (count($pictures) == 1) { // Checking, if the link goes to a picture $data = parseurl_getsiteinfo_cached($pictures[0][1], true); + + // Workaround: + // Sometimes photo posts to the own album are not detected at the start. + // So we seem to cannot use the cache for these cases. That's strange. + if (($data["type"] != "photo") AND strstr($pictures[0][1], "/photos/")) + $data = parseurl_getsiteinfo($pictures[0][1], true); + if ($data["type"] == "photo") { $post["type"] = "photo"; if (isset($data["images"][0])) {