X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivityutils.php;h=dcccbb8d878dae2e8960e75b854e711d832286ac;hb=7bef2ad4ccb10a319dde1e62460d34f7ebf3242c;hp=ef2e23224374b6a9ddd9629ef366e7f19ed0bdb7;hpb=238d2a387623743fd98c84783ce360bf1d2db6ee;p=quix0rs-gnu-social.git diff --git a/lib/activityutils.php b/lib/activityutils.php index ef2e232243..dcccbb8d87 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -301,7 +301,7 @@ class ActivityUtils return false; } - static function getFeedAuthor($feedEl) + static function getFeedAuthor(DOMDocument $feedEl) { // Try old and deprecated activity:subject @@ -350,7 +350,7 @@ class ActivityUtils static function compareTypes($type, $objects) { - $type = self::resolveUri($type); + $type = self::resolveUri($type, false); foreach ((array)$objects as $object) { if ($type === self::resolveUri($object)) { return true; @@ -380,32 +380,33 @@ 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'; } } - foreach (array_unique($uris) as $uri) { + $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 (Exception $e) { - common_debug('Could not find local activity object from uri: '.$uri); + } catch (UnknownUriException $e) { + common_debug('Could not find local activity object from uri: '.$e->object_uri); } } - if (!empty($object)) { - Event::handle('EndFindLocalActivityObject', array($object->getUri(), $type, $object)); - } else { - throw new ServerException('Could not find any activityobject stored locally with given URI'); + if (!$object instanceof Managed_DataObject) { + throw new ServerException('Could not find any activityobject stored locally with given URIs: '.var_export($uris,true)); } + Event::handle('EndFindLocalActivityObject', array($object->getUri(), $object->getObjectType(), $object)); return $object; }