Merge remote branch 'origin/platal-1.0.1'
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 30 Oct 2010 13:16:30 +0000 (15:16 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 30 Oct 2010 13:16:30 +0000 (15:16 +0200)
bin/cron/profile_modification.php
classes/profile.php
include/name.func.inc.php
modules/admin.php

index 6e856e5..8d4b4d0 100755 (executable)
@@ -33,7 +33,7 @@ $res = XDB::iterator('SELECT  p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText
                   INNER JOIN  aliases               AS al ON (ap.uid = al.uid AND FIND_IN_SET(\'bestalias\', al.flags))
                     ORDER BY  pm.pid, pm.field');
 
-if ($res-total() > 0) {
+if ($res->total() > 0) {
     $date = time();
     $values = $res->next();
 
index 8eb66bb..9b2e4b0 100644 (file)
@@ -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
index d954263..b23fdff 100644 (file)
@@ -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;
 }
 
index 567895a..6b5fc43 100644 (file)
@@ -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);
                         }
                     }
                 }