add some transaction voodoo to the insert for rememberme cookies

darcs-hash:20081209185424-84dde-d439346477811043ae471c5e68644b326b016713.gz
This commit is contained in:
Evan Prodromou 2008-12-09 13:54:24 -05:00
parent 3909544f9e
commit 44a683bfab
1 changed files with 8 additions and 0 deletions

View File

@ -614,8 +614,14 @@ function common_rememberme($user=NULL) {
}
$rm = new Remember_me();
$rm->code = common_good_rand(16);
$rm->user_id = $user->id;
# Wrap the insert in some good ol' fashioned transaction code
$rm->query('BEGIN');
$result = $rm->insert();
if (!$result) {
@ -624,6 +630,8 @@ function common_rememberme($user=NULL) {
return false;
}
$rm->query('COMMIT');
common_debug('Inserted rememberme record (' . $rm->code . ', ' . $rm->user_id . '); result = ' . $result . '.', __FILE__);
$cookieval = $rm->user_id . ':' . $rm->code;