]> git.mxchange.org Git - friendica.git/commitdiff
Do not cache Contact::getDetailsByURL result if it doesn't come from the DB
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 29 Feb 2020 16:41:33 +0000 (11:41 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 29 Feb 2020 16:41:33 +0000 (11:41 -0500)
- Address https://github.com/friendica/friendica/issues/8000#issuecomment-592169621

src/Model/Contact.php

index f86d3f378c448710eaf37dfee9ab01712a3528a5..68bd0986a663e144011bb4060a2139ff4ad14876 100644 (file)
@@ -1037,6 +1037,7 @@ class Contact
                }
 
                if (DBA::isResult($r)) {
+                       $authoritativeResult = true;
                        // If there is more than one entry we filter out the connector networks
                        if (count($r) > 1) {
                                foreach ($r as $id => $result) {
@@ -1070,6 +1071,7 @@ class Contact
                                $profile["bd"] = DBA::NULL_DATE;
                        }
                } else {
+                       $authoritativeResult = false;
                        $profile = $default;
                }
 
@@ -1106,7 +1108,11 @@ class Contact
                        $profile["birthday"] = DBA::NULL_DATE;
                }
 
-               $cache[$url][$uid] = $profile;
+               // Only cache the result if it came from the DB since this method is used in widely different contexts
+               // @see display_fetch_author for an example of $default parameter diverging from the DB result
+               if ($authoritativeResult) {
+                       $cache[$url][$uid] = $profile;
+               }
 
                return $profile;
        }