From bedc4295338e467b383e76464785ce8fdd1be0c9 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 30 Oct 2010 09:27:37 +0200 Subject: [PATCH] Avoid double transaction. Signed-off-by: Florent Bruneau --- classes/profile.php | 10 +++++++--- include/name.func.inc.php | 2 +- modules/admin.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index 8eb66bb..9b2e4b0 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -1011,7 +1011,7 @@ class Profile } } - public static function rebuildSearchTokens($pids) + public static function rebuildSearchTokens($pids, $transaction = true) { if (!is_array($pids)) { $pids = array($pids); @@ -1053,7 +1053,9 @@ class Profile $eltScore, $key['public']); } } - XDB::startTransaction(); + if ($transaction) { + XDB::startTransaction(); + } XDB::execute('DELETE FROM search_name WHERE pid IN {?}', $pids); @@ -1061,7 +1063,9 @@ class Profile XDB::rawExecute('INSERT INTO search_name (token, pid, soundex, score, flags) VALUES ' . implode(', ', $names)); } - XDB::commit(); + if ($transaction) { + XDB::commit(); + } } /** The school identifier consists of 6 digits. The first 3 represent the diff --git a/include/name.func.inc.php b/include/name.func.inc.php index d954263..b23fdff 100644 --- a/include/name.func.inc.php +++ b/include/name.func.inc.php @@ -308,7 +308,7 @@ function set_alias_names(&$sn_new, $sn_old, $pid, $uid, $update_new = false, $ne VALUES ({?}, 'alias', 'usage', {?})", $new_alias, $uid); } - Profile::rebuildSearchTokens($pid); + Profile::rebuildSearchTokens($pid, false); return $has_new; } diff --git a/modules/admin.php b/modules/admin.php index 567895a..6b5fc43 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -876,7 +876,7 @@ class AdminModule extends PLModule XDB::execute('INSERT INTO account_profiles (uid, pid, perms) VALUES ({?}, {?}, {?})', $uid, $pid, 'owner'); - Profile::rebuildSearchTokens($pid); + Profile::rebuildSearchTokens($pid, false); } } } -- 2.1.4