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 <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
This commit is contained in:
Evan Prodromou 2011-02-10 09:39:40 -05:00
parent df19e88323
commit 8fa44e58f9

View File

@ -1354,7 +1354,17 @@ class Ostatus_profile extends Memcached_DataObject
{ {
$orig = clone($profile); $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)) { if (!empty($object->title)) {
$profile->fullname = $object->title; $profile->fullname = $object->title;
@ -1370,9 +1380,23 @@ class Ostatus_profile extends Memcached_DataObject
$profile->profileurl = $object->id; $profile->profileurl = $object->id;
} }
$profile->bio = self::getActivityObjectBio($object, $hints); $bio = self::getActivityObjectBio($object, $hints);
$profile->location = self::getActivityObjectLocation($object, $hints);
$profile->homepage = self::getActivityObjectHomepage($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)) { if (!empty($object->geopoint)) {
$location = ActivityContext::locationFromPoint($object->geopoint); $location = ActivityContext::locationFromPoint($object->geopoint);