From a84d584971dd1eedab20094da60d31fa93659c84 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 1 Apr 2011 09:30:25 -0400 Subject: [PATCH] delete the Bookmark if Notice::saveNew() fails --- plugins/Bookmark/Bookmark.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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; }