From fb537fb7f455cde9c4ccd9f6e54e734467d4f4b3 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 4 Jan 2016 02:04:18 +0100 Subject: [PATCH] We would end up with a Managed_DataObject if now match was found meaning we'd return for example a Notice with empty id (translated into 0) and thus Faves coming in from remote instances where the fave'd notice was not found would result in faving the first Notice in a table-wide search, i.e. often the first post on the instance. Whoopie! --- lib/activityutils.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/activityutils.php b/lib/activityutils.php index c8e5808251..8a2be35022 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -380,23 +380,24 @@ class ActivityUtils } static function findLocalObject(array $uris, $type=ActivityObject::NOTE) { - $object = null; - // TODO: Extend this in plugins etc. - if (Event::handle('StartFindLocalActivityObject', array($uris, $type, &$object))) { + $obj_class = null; + // TODO: Extend this in plugins etc. and describe in EVENTS.txt + if (Event::handle('StartFindLocalActivityObject', array($uris, $type, &$obj_class))) { switch (self::resolveUri($type)) { case ActivityObject::PERSON: // GROUP will also be here in due time... - $object = new Profile(); + $obj_class = 'Profile'; break; default: - $object = new Notice(); + $obj_class = 'Notice'; } } + $object = null; $uris = array_unique($uris); foreach ($uris as $uri) { try { // the exception thrown will cancel before reaching $object - $object = call_user_func(array($object, 'fromUri'), $uri); + $object = call_user_func("{$obj_class}::fromUri", $uri); break; } catch (UnknownUriException $e) { common_debug('Could not find local activity object from uri: '.$e->object_uri); -- 2.39.2