]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/actions/bookmarkforurl.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Bookmark / actions / bookmarkforurl.php
index 5eac33b11b73b7f32530c06812386093694ca135..9fc0166b08b8661167c1f13be624d1e7d2a3e72e 100644 (file)
@@ -59,7 +59,7 @@ class BookmarkforurlAction extends Action
      *
      * @return boolean true
      */
-    function prepare($args)
+    function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -78,17 +78,19 @@ class BookmarkforurlAction extends Action
             throw new ClientException(_('Invalid URL.'), 400);
         }
 
-        $f = File::getKV('url', $this->url);
-
-        if (empty($url)) { 
-           $f = File::processNew($this->url);
+        try {
+            // processNew will first try to fetch a locally stored File entry
+            $f = File::processNew($this->url);
+        } catch (ServerException $e) {
+            $f = null;
         }
 
         // How about now?
 
-        if (!empty($f)) {
+        if ($f instanceof File) {
+            // FIXME: Use some File metadata Event instead
             $this->oembed    = File_oembed::getKV('file_id', $f->id);
-            if (!empty($this->oembed)) {
+            if ($this->oembed instanceof File_oembed) {
                 $this->title = $this->oembed->title;
             }
             $this->thumbnail = File_thumbnail::getKV('file_id', $f->id);
@@ -101,11 +103,9 @@ class BookmarkforurlAction extends Action
      * Handler method
      *
      * @param array $args is ignored since it's now passed in in prepare()
-     *
      * @return void
      */
-
-    function handle($args=null)
+    function handle(array $args=array())
     {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
@@ -124,11 +124,9 @@ class BookmarkforurlAction extends Action
      * MAY override
      *
      * @param array $args other arguments
-     *
      * @return boolean is read only action?
      */
-
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         return false;
     }