From: Evan Prodromou Date: Fri, 1 Apr 2011 13:30:25 +0000 (-0400) Subject: delete the Bookmark if Notice::saveNew() fails X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a84d584971dd1eedab20094da60d31fa93659c84;p=quix0rs-gnu-social.git delete the Bookmark if Notice::saveNew() fails --- diff --git a/plugins/Bookmark/Bookmark.php b/plugins/Bookmark/Bookmark.php index 48709d1387..b83aca62df 100644 --- a/plugins/Bookmark/Bookmark.php +++ b/plugins/Bookmark/Bookmark.php @@ -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; }