From 44a683bfab0df9780e9a095f6f935c5d3eb3dff4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 9 Dec 2008 13:54:24 -0500 Subject: add some transaction voodoo to the insert for rememberme cookies darcs-hash:20081209185424-84dde-d439346477811043ae471c5e68644b326b016713.gz --- lib/util.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') 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; -- cgit v1.2.3-54-g00ecf