From: Evan Prodromou Date: Thu, 10 Feb 2011 14:39:40 +0000 (-0500) Subject: Try not to wipe out good data with empty values in Ostatus_profile::updateProfile() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8fa44e58f975ad6d59e0151f624de603a650352c;p=quix0rs-gnu-social.git 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 --- 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);