]> git.mxchange.org Git - friendica.git/commitdiff
Bugfix: Sometimes uploaded pictures weren't posted correctly to other networks
authorMichael Vogel <icarus@dabo.de>
Sun, 29 May 2016 08:59:06 +0000 (10:59 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 29 May 2016 08:59:06 +0000 (10:59 +0200)
include/Photo.php
include/plaintext.php

index 91fce55a86f868c4959291618fa4b8af77c4bba6..d87bce478704fccb6489097269e2e83163a4fd5f 100644 (file)
@@ -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;
 }
index e18604334b2041f3c0b5fe6f62f28978ae66fd2f..793f9935a74ba061ce1b5b5ba4c8af7e90838dbf 100644 (file)
@@ -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])) {