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!
This commit is contained in:
Mikael Nordfeldth 2016-01-04 02:04:18 +01:00
parent 065e23b1c4
commit fb537fb7f4

View File

@ -380,23 +380,24 @@ class ActivityUtils
} }
static function findLocalObject(array $uris, $type=ActivityObject::NOTE) { static function findLocalObject(array $uris, $type=ActivityObject::NOTE) {
$object = null; $obj_class = null;
// TODO: Extend this in plugins etc. // TODO: Extend this in plugins etc. and describe in EVENTS.txt
if (Event::handle('StartFindLocalActivityObject', array($uris, $type, &$object))) { if (Event::handle('StartFindLocalActivityObject', array($uris, $type, &$obj_class))) {
switch (self::resolveUri($type)) { switch (self::resolveUri($type)) {
case ActivityObject::PERSON: case ActivityObject::PERSON:
// GROUP will also be here in due time... // GROUP will also be here in due time...
$object = new Profile(); $obj_class = 'Profile';
break; break;
default: default:
$object = new Notice(); $obj_class = 'Notice';
} }
} }
$object = null;
$uris = array_unique($uris); $uris = array_unique($uris);
foreach ($uris as $uri) { foreach ($uris as $uri) {
try { try {
// the exception thrown will cancel before reaching $object // 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; break;
} catch (UnknownUriException $e) { } catch (UnknownUriException $e) {
common_debug('Could not find local activity object from uri: '.$e->object_uri); common_debug('Could not find local activity object from uri: '.$e->object_uri);