From 8fa44e58f975ad6d59e0151f624de603a650352c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Feb 2011 09:39:40 -0500 Subject: [PATCH] Try not to wipe out good data with empty values in Ostatus_profile::updateProfile() Output from 0.9.6 PuSH feeds seems to have a rump but no . 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 | 32 ++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 28f2dc0a97..c4d857f22c 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -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); -- 2.39.5