]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/File_oembed.php
- Update getrequesttoken test script to use 1.0a
[quix0rs-gnu-social.git] / classes / File_oembed.php
index 94de8e117eb00a04e52405dc4c221202f7232822..4813d5dda52e8709fde611ba7deb48726959ab8d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
  * along with this program.     If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 require_once INSTALLDIR.'/classes/File_redirection.php';
@@ -81,6 +81,12 @@ class File_oembed extends Memcached_DataObject
         }
     }
 
+    /**
+     * Save embedding info for a new file.
+     *
+     * @param object $data Services_oEmbed_Object_*
+     * @param int $file_id
+     */
     function saveNew($data, $file_id) {
         $file_oembed = new File_oembed;
         $file_oembed->file_id = $file_id;
@@ -115,8 +121,13 @@ class File_oembed extends Memcached_DataObject
         }
         $file_oembed->insert();
         if (!empty($data->thumbnail_url)) {
-            File_thumbnail::saveNew($data, $file_id);
+            $ft = File_thumbnail::staticGet('file_id', $file_id);
+            if (!empty($ft)) {
+                common_log(LOG_WARNING, "Strangely, a File_thumbnail object exists for new file $file_id",
+                           __FILE__);
+            } else {
+                File_thumbnail::saveNew($data, $file_id);
+            }
         }
     }
 }
-