]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
delete the Bookmark if Notice::saveNew() fails
authorEvan Prodromou <evan@status.net>
Fri, 1 Apr 2011 13:30:25 +0000 (09:30 -0400)
committerEvan Prodromou <evan@status.net>
Fri, 1 Apr 2011 13:30:25 +0000 (09:30 -0400)
plugins/Bookmark/Bookmark.php

index 48709d1387c4208c8e5454249f605bf877c0552d..b83aca62df5894b35dc779f5a54cd69c9fa5d337 100644 (file)
@@ -329,11 +329,20 @@ class Bookmark extends Memcached_DataObject
             $options['uri'] = $nb->uri;
         }
 
-        $saved = Notice::saveNew($profile->id,
-                                 $content,
-                                 array_key_exists('source', $options) ?
-                                 $options['source'] : 'web',
-                                 $options);
+        try {
+            $saved = Notice::saveNew($profile->id,
+                                     $content,
+                                     array_key_exists('source', $options) ?
+                                     $options['source'] : 'web',
+                                     $options);
+        } catch (Exception $e) {
+            $nb->delete();
+            throw $e;
+        }
+
+        if (empty($saved)) {
+            $nb->delete();
+        }
 
         return $saved;
     }