From 3f4d4cb7a07a36440e9e3c10e9950c6522c58be4 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 12 Oct 2015 18:28:32 +0200 Subject: [PATCH] Better error handling in Bookmark --- lib/activityhandlerplugin.php | 6 +++++- plugins/Bookmark/BookmarkPlugin.php | 30 +++++++++-------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/activityhandlerplugin.php b/lib/activityhandlerplugin.php index 2544179c5e..8b2a458454 100644 --- a/lib/activityhandlerplugin.php +++ b/lib/activityhandlerplugin.php @@ -625,7 +625,11 @@ abstract class ActivityHandlerPlugin extends Plugin return true; } - $this->showNoticeContent($stored, $out, $scoped); + try { + $this->showNoticeContent($stored, $out, $scoped); + } catch (Exception $e) { + $out->element('div', 'error', $e->getMessage()); + } return false; } diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index 1b2f461855..8b4abd2b42 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -379,20 +379,10 @@ class BookmarkPlugin extends MicroAppPlugin return true; } - protected function showNoticeItemNotice(NoticeListItem $nli) - { - $nli->out->elementStart('div', 'entry-title'); - $nli->showAuthor(); - $nli->showContent(); - $nli->out->elementEnd('div'); - } - protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null) { $nb = Bookmark::fromStored($stored); - $profile = $stored->getProfile(); - // Whether to nofollow $attrs = array('href' => $nb->getUrl(), 'class' => 'bookmark-title'); @@ -405,7 +395,7 @@ class BookmarkPlugin extends MicroAppPlugin } $out->elementStart('h3'); - $out->element('a', $attrs, $nb->title); + $out->element('a', $attrs, $nb->getTitle()); $out->elementEnd('h3'); // Replies look like "for:" tags @@ -423,16 +413,14 @@ class BookmarkPlugin extends MicroAppPlugin $out->elementStart('ul', array('class' => 'bookmark-tags')); foreach ($replies as $reply) { - $other = Profile::getKV('id', $reply); - if (!empty($other)) { - $out->elementStart('li'); - $out->element('a', array('rel' => 'tag', - 'href' => $other->profileurl, - 'title' => $other->getBestName()), - sprintf('for:%s', $other->nickname)); - $out->elementEnd('li'); - $out->text(' '); - } + $other = Profile::getByPK($reply); + $out->elementStart('li'); + $out->element('a', array('rel' => 'tag', + 'href' => $other->getUrl(), + 'title' => $other->getBestName()), + sprintf('for:%s', $other->getNickname())); + $out->elementEnd('li'); + $out->text(' '); } foreach ($tags as $tag) { -- 2.39.5