From 04b7194511ec503eb40ffc3a9d468863ab1e0a42 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 10 May 2014 13:06:18 +0200 Subject: [PATCH] Notice->getUrl() for shares would throw exception in some feeds --- classes/Notice.php | 7 ++++++- plugins/Oembed/OembedPlugin.php | 33 +++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 7311a257a6..b83af67563 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1493,7 +1493,12 @@ class Notice extends Managed_DataObject $act->id = $this->uri; $act->time = strtotime($this->created); - $act->link = $this->getUrl(); + try { + $act->link = $this->getUrl(); + } catch (InvalidUrlException $e) { + // The notice is probably a share or similar, which don't + // have a representational URL of their own. + } $act->content = common_xml_safe_str($this->rendered); $profile = $this->getProfile(); diff --git a/plugins/Oembed/OembedPlugin.php b/plugins/Oembed/OembedPlugin.php index 8820b3c505..27f299b5eb 100644 --- a/plugins/Oembed/OembedPlugin.php +++ b/plugins/Oembed/OembedPlugin.php @@ -38,20 +38,25 @@ class OembedPlugin extends Plugin 'title'=>'oEmbed'),null); break; case 'shownotice': - $action->element('link',array('rel'=>'alternate', - 'type'=>'application/json+oembed', - 'href'=>common_local_url( - 'oembed', - array(), - array('format'=>'json','url'=>$action->notice->getUrl())), - 'title'=>'oEmbed'),null); - $action->element('link',array('rel'=>'alternate', - 'type'=>'text/xml+oembed', - 'href'=>common_local_url( - 'oembed', - array(), - array('format'=>'xml','url'=>$action->notice->getUrl())), - 'title'=>'oEmbed'),null); + try { + $action->element('link',array('rel'=>'alternate', + 'type'=>'application/json+oembed', + 'href'=>common_local_url( + 'oembed', + array(), + array('format'=>'json','url'=>$action->notice->getUrl())), + 'title'=>'oEmbed'),null); + $action->element('link',array('rel'=>'alternate', + 'type'=>'text/xml+oembed', + 'href'=>common_local_url( + 'oembed', + array(), + array('format'=>'xml','url'=>$action->notice->getUrl())), + 'title'=>'oEmbed'),null); + } catch (InvalidUrlException $e) { + // The notice is probably a share or similar, which don't + // have a representational URL of their own. + } break; } -- 2.39.2