From 2821be2bceb097b44086c81bbaddd547ae846b18 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Thu, 12 Mar 2015 22:17:08 +0100 Subject: [PATCH] Notice properties set in bad order on activityobject saving --- classes/Notice.php | 12 ++++++------ plugins/Favorite/FavoritePlugin.php | 2 ++ plugins/Share/SharePlugin.php | 10 ++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 1b2b631b04..541a72fb09 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -902,6 +902,12 @@ class Notice extends Managed_DataObject $stored->insert(); // throws exception on error $orig = clone($stored); // for updating later in this try clause + $object = null; + Event::handle('StoreActivityObject', array($act, $stored, $options, &$object)); + if (empty($object)) { + throw new ServerException('Unsuccessful call to StoreActivityObject '.$stored->uri . ': '.$act->asString()); + } + // If it's not part of a conversation, it's // the beginning of a new conversation. if (empty($stored->conversation)) { @@ -910,12 +916,6 @@ class Notice extends Managed_DataObject $stored->conversation = $conv->id; } - $object = null; - Event::handle('StoreActivityObject', array($act, $stored, $options, &$object)); - if (empty($object)) { - throw new ServerException('Unsuccessful call to StoreActivityObject '.$stored->uri . ': '.$act->asString()); - } - $stored->object_type = ActivityUtils::resolveUri($object->getObjectType(), true); $stored->update($orig); } catch (Exception $e) { if (empty($stored->id)) { diff --git a/plugins/Favorite/FavoritePlugin.php b/plugins/Favorite/FavoritePlugin.php index 55716016bd..eb73bbe43c 100644 --- a/plugins/Favorite/FavoritePlugin.php +++ b/plugins/Favorite/FavoritePlugin.php @@ -194,6 +194,8 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin $actobj = $act->objects[0]; $object = Fave::saveActivityObject($actobj, $stored); + $stored->object_type = ActivityUtils::resolveUri($object->getObjectType(), true); + return $object; } diff --git a/plugins/Share/SharePlugin.php b/plugins/Share/SharePlugin.php index bfcf931a8e..671214b1d6 100644 --- a/plugins/Share/SharePlugin.php +++ b/plugins/Share/SharePlugin.php @@ -40,6 +40,14 @@ class SharePlugin extends ActivityVerbHandlerPlugin return array(ActivityVerb::SHARE); } + // Share is a bit special and $act->objects[0] should be an Activity + // instead of ActivityObject! Therefore also $act->objects[0]->type is not set. + public function isMyActivity(Activity $act) { + return (count($act->objects) == 1 + && ($act->objects[0] instanceof Activity) + && $this->isMyVerb($act->verb)); + } + public function onRouterInitialized(URLMapper $m) { // Web UI actions @@ -125,6 +133,8 @@ class SharePlugin extends ActivityVerbHandlerPlugin // Setting this here because when the algorithm gets back to // Notice::saveActivity it will update the Notice object. $stored->repeat_of = $sharedNotice->getID(); + $stored->conversation = $sharedNotice->conversation; + $stored->object_type = ActivityUtils::resolveUri(ActivityObject::ACTIVITY, true); // We don't have to save a repeat in a separate table, we can // find repeats by just looking at the notice.repeat_of field. -- 2.39.5