From 97debbab68ea6bc42ebd0d00e51500019bbcd1c0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 30 May 2011 09:57:11 -0400 Subject: [PATCH 1/3] use integer iterator for childNodes in ActivityUtils::getLinks() --- lib/activityutils.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/activityutils.php b/lib/activityutils.php index 3aa09deb4e..59f7cdcf3a 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -104,8 +104,9 @@ class ActivityUtils { $els = $element->childNodes; $out = array(); - - foreach ($els as $link) { + + for ($i = 0; $i < $els->length; $i++) { + $link = $els->item($i); if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { $linkRel = $link->getAttribute(self::REL); $linkType = $link->getAttribute(self::TYPE); From 9167ba8d2d889ad3e8b51e02e93102b2b2dde7dc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 30 May 2011 09:57:49 -0400 Subject: [PATCH 2/3] ActivityImporter catches thrown exceptions by plugins and marks entry done --- lib/activityimporter.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/activityimporter.php b/lib/activityimporter.php index b1f30fa4bf..b5c83516ec 100644 --- a/lib/activityimporter.php +++ b/lib/activityimporter.php @@ -63,9 +63,9 @@ class ActivityImporter extends QueueHandler $done = null; - if (Event::handle('StartImportActivity', - array($user, $author, $activity, $trusted, &$done))) { - try { + try { + if (Event::handle('StartImportActivity', + array($user, $author, $activity, $trusted, &$done))) { switch ($activity->verb) { case ActivityVerb::FOLLOW: $this->subscribeProfile($user, $author, $activity); @@ -83,10 +83,10 @@ class ActivityImporter extends QueueHandler Event::handle('EndImportActivity', array($user, $author, $activity, $trusted)); $done = true; - } catch (Exception $e) { - common_log(LOG_ERR, $e->getMessage()); - $done = true; } + } catch (Exception $e) { + common_log(LOG_ERR, $e->getMessage()); + $done = true; } return $done; } From cb4f27100267ed6dd6d7619a8a583196932d3e5d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 30 May 2011 10:04:25 -0400 Subject: [PATCH 3/3] test to check that Bookmark related links are appearing correctly --- tests/ActivityParseTests.php | 109 +++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/tests/ActivityParseTests.php b/tests/ActivityParseTests.php index c2817a4602..6423eaaf03 100644 --- a/tests/ActivityParseTests.php +++ b/tests/ActivityParseTests.php @@ -405,6 +405,28 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase $act = new Activity($entry, $feed); $this->assertEquals($act->actor->id, $expected); } + + public function testBookmarkRelated() + { + global $_example11; + $dom = new DOMDocument(); + $dom->loadXML($_example11); + + $feed = $dom->documentElement; + $entry = $dom->getElementsByTagName('entry')->item(0); + + $expected = 'http://blog.teambox.com/open-source-companies'; + + $links = ActivityUtils::getLinks($entry, 'related'); + + $this->assertFalse(empty($links)); + $this->assertTrue(is_array($links)); + $this->assertEquals(count($links), 1); + + $url = $links[0]->getAttribute('href'); + + $this->assertEquals($url, $expected); + } } $_example1 = << EXAMPLE10; + +$_example11 = << + + StatusNet + http://freelish.us/api/statuses/user_timeline/1.atom + demon timeline + Updates from demon on freelish.us! + http://avatar.status.net/f/freelishus/1-96-20110331163048.jpeg + 2011-05-30T09:36:03-04:00 + + http://activitystrea.ms/schema/1.0/person + http://freelishus.status.net/user/1 + demon + + + + + + 45.50884 -73.58781 + demon + Evan Prodromou + Montreal hacker and entrepreneur. + + Montreal, Quebec + + + + homepage + http://evan.status.net/ + true + + + + + + http://activitystrea.ms/schema/1.0/person + http://freelishus.status.net/user/1 + Evan Prodromou + + + + + + 45.50884 -73.58781 + demon + Evan Prodromou + Montreal hacker and entrepreneur. + + Montreal, Quebec + + + + homepage + http://evan.status.net/ + true + + + + + + + + + + + + + + http://activitystrea.ms/schema/1.0/bookmark + http://freelish.us/bookmark/9e930c3e-7ed9-47de-aba5-df6c60cec542 + Why you should build an open-source startup | Teambox Blog + + + http://activitystrea.ms/schema/1.0/post + 2011-05-26T20:36:25+00:00 + 2011-05-26T20:36:25+00:00 + + + + + + + + + +EXAMPLE11;