when in doubt, start throwing transactions around

darcs-hash:20080718043735-84dde-8c74ccaf2560716209b8518e77e6a0f357d881af.gz
This commit is contained in:
Evan Prodromou 2008-07-18 00:37:35 -04:00
parent 310d02ae40
commit 71dfc0d983
1 changed files with 7 additions and 0 deletions

View File

@ -45,6 +45,9 @@ class TwitapifriendshipsAction extends TwitterapiAction {
} }
$sub = new Subscription(); $sub = new Subscription();
$sub->query('BEGIN');
$sub->subscriber = $user->id; $sub->subscriber = $user->id;
$sub->subscribed = $other->id; $sub->subscribed = $other->id;
@ -56,6 +59,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
return; return;
} }
$sub->query('COMMIT');
mail_subscribe_notify($other, $user); mail_subscribe_notify($other, $user);
$type = $apidata['content-type']; $type = $apidata['content-type'];
@ -91,7 +96,9 @@ class TwitapifriendshipsAction extends TwitterapiAction {
$sub->subscribed = $other->id; $sub->subscribed = $other->id;
if ($sub->fetch(TRUE)) { if ($sub->fetch(TRUE)) {
$sub->query('BEGIN');
$sub->delete(); $sub->delete();
$sub->query('COMMIT');
} }
$type = $apidata['content-type']; $type = $apidata['content-type'];