]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notice->getUrl() for shares would throw exception in some feeds
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 10 May 2014 11:06:18 +0000 (13:06 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 10 May 2014 11:06:18 +0000 (13:06 +0200)
classes/Notice.php
plugins/Oembed/OembedPlugin.php

index 7311a257a618180d3cdb688fbf8f7d73ea996784..b83af67563980ee9fbbe0de47a9b6ed959c1355d 100644 (file)
@@ -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();
index 8820b3c505ebf3616d0919ba50981a881e28a46e..27f299b5ebf454f44a0b766ba945a179a1c6b46b 100644 (file)
@@ -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;
         }