Fix subscription to promotion list during registration.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 28 Dec 2010 20:57:51 +0000 (21:57 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 28 Dec 2010 20:57:51 +0000 (21:57 +0100)
The actual bug seems to be a synchronisation issue while querying the db
from the RPC: the registration of the user does not seem to be seen by the
RPC. The fix add an explicit transaction around some queries. It also
fixes the name of the list...

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/register.php

index c70a365..331f618 100644 (file)
@@ -328,6 +328,7 @@ class RegisterModule extends PLModule
         //
         // Create the user account.
         //
+        XDB::startTransaction();
         XDB::execute("UPDATE  accounts
                          SET  password = {?}, state = 'active',
                               registration_date = NOW(), email = NULL
@@ -343,6 +344,7 @@ class RegisterModule extends PLModule
             XDB::execute("INSERT INTO  aliases (uid, alias, type)
                                VALUES  ({?}, {?}, 'alias')", $uid, $emailXorg2);
         }
+        XDB::commit();
 
         // Add the registration email address as first and only redirection.
         require_once 'emails.inc.php';
@@ -373,7 +375,7 @@ class RegisterModule extends PLModule
                                                   VALUES  ({?}, {?})',
                                      $uid, $asso_id);
                         $mmlist = new MMList($user);
-                        $mmlist->subscribe("promo" . S::v('promo'));
+                        $mmlist->subscribe("promo" . $yearpromo);
                     }
                     break;
                 case 'nl':