summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-12-09 13:54:24 -0500
committerEvan Prodromou <evan@prodromou.name>2008-12-09 13:54:24 -0500
commit44a683bfab0df9780e9a095f6f935c5d3eb3dff4 (patch)
tree6a359058ba9314ec66e43c32ccbae20a1bd26879
parent3909544f9efa9f12d8525f321f6b8aa62325c857 (diff)
add some transaction voodoo to the insert for rememberme cookies
darcs-hash:20081209185424-84dde-d439346477811043ae471c5e68644b326b016713.gz
-rw-r--r--lib/util.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php
index 87a6a42c5..5fec73552 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -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;