forked from GNUsocial/gnu-social
delete the Bookmark if Notice::saveNew() fails
This commit is contained in:
parent
d5a38c62f4
commit
a84d584971
@ -329,11 +329,20 @@ class Bookmark extends Memcached_DataObject
|
|||||||
$options['uri'] = $nb->uri;
|
$options['uri'] = $nb->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
$saved = Notice::saveNew($profile->id,
|
try {
|
||||||
$content,
|
$saved = Notice::saveNew($profile->id,
|
||||||
array_key_exists('source', $options) ?
|
$content,
|
||||||
$options['source'] : 'web',
|
array_key_exists('source', $options) ?
|
||||||
$options);
|
$options['source'] : 'web',
|
||||||
|
$options);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$nb->delete();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($saved)) {
|
||||||
|
$nb->delete();
|
||||||
|
}
|
||||||
|
|
||||||
return $saved;
|
return $saved;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user