]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Try not to wipe out good data with empty values in Ostatus_profile::updateProfile()
authorEvan Prodromou <evan@status.net>
Thu, 10 Feb 2011 14:39:40 +0000 (09:39 -0500)
committerEvan Prodromou <evan@status.net>
Thu, 10 Feb 2011 14:39:40 +0000 (09:39 -0500)
Output from 0.9.6 PuSH feeds seems to have a rump <author> but no
<activity:actor>. It was overwriting valid and useful data set up at
subscribe time.

This fix tries to avoid overwriting data. However, it may prevent
updates that delete data.

Bug: 3028

plugins/OStatus/classes/Ostatus_profile.php

index 28f2dc0a9774327a9875d35fb2df93e7cc18f398..c4d857f22cdb57a4baac1825519d7b48ac246fd9 100644 (file)
@@ -1354,7 +1354,17 @@ class Ostatus_profile extends Memcached_DataObject
     {
         $orig = clone($profile);
 
-        $profile->nickname = self::getActivityObjectNickname($object, $hints);
+        // Existing nickname is better than nothing.
+
+        if (!array_key_exists('nickname', $hints)) {
+            $hints['nickname'] = $profile->nickname;
+        }
+
+        $nickname = self::getActivityObjectNickname($object, $hints);
+
+        if (!empty($nickname)) {
+            $profile->nickname = $nickname;
+        }
 
         if (!empty($object->title)) {
             $profile->fullname = $object->title;
@@ -1370,9 +1380,23 @@ class Ostatus_profile extends Memcached_DataObject
             $profile->profileurl = $object->id;
         }
 
-        $profile->bio      = self::getActivityObjectBio($object, $hints);
-        $profile->location = self::getActivityObjectLocation($object, $hints);
-        $profile->homepage = self::getActivityObjectHomepage($object, $hints);
+        $bio = self::getActivityObjectBio($object, $hints);
+
+        if (!empty($bio)) {
+            $profile->bio = $bio;
+        }
+
+        $location = self::getActivityObjectLocation($object, $hints);
+
+        if (!empty($location)) {
+            $profile->location = $location;
+        }
+
+        $homepage = self::getActivityObjectHomepage($object, $hints);
+
+        if (!empty($homepage)) {
+            $profile->homepage = $homepage;
+        }
 
         if (!empty($object->geopoint)) {
             $location = ActivityContext::locationFromPoint($object->geopoint);