delete the Bookmark if Notice::saveNew() fails

This commit is contained in:
Evan Prodromou 2011-04-01 09:30:25 -04:00
parent d5a38c62f4
commit a84d584971
1 changed files with 14 additions and 5 deletions

View 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;
}