Code cleanup in lib/activityutils.php
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 4 Jan 2016 00:58:45 +0000 (01:58 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 4 Jan 2016 00:58:45 +0000 (01:58 +0100)
lib/activityutils.php

index da543b2069d5c9783f06bdae8e28c75ca4df6d17..c8e580825173693aa617a010ab35c27ff1914c95 100644 (file)
@@ -392,7 +392,8 @@ class ActivityUtils
                 $object = new Notice();
             }
         }
-        foreach (array_unique($uris) as $uri) {
+        $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);
@@ -401,11 +402,10 @@ class ActivityUtils
                 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;
     }