]> git.mxchange.org Git - friendica.git/commitdiff
repair duplicate nickname accounts caused by race condition
authorFriendika <info@friendika.com>
Thu, 24 Mar 2011 22:45:27 +0000 (15:45 -0700)
committerFriendika <info@friendika.com>
Thu, 24 Mar 2011 22:45:27 +0000 (15:45 -0700)
boot.php
mod/register.php

index 72ec81c1111f666d309035b53e075992e81bf35d..e05166609517105cf4feb9f1fa10f75fd83a3a8a 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
 
 set_time_limit(0);
 
-define ( 'FRIENDIKA_VERSION',      '2.1.927' );
+define ( 'FRIENDIKA_VERSION',      '2.1.928' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.1'  );
 define ( 'DB_UPDATE_VERSION',      1045   );
 
index 95e9d581f1c9806e19d1818ed3da73f972252d9f..06ed1e0f18fb4bb936bd3fd627f8d9077e97e7eb 100644 (file)
@@ -199,6 +199,24 @@ function register_post(&$a) {
                return;
        }               
 
+       /**
+        * if somebody clicked submit twice very quickly, they could end up with two accounts 
+        * due to race condition. Remove this one.
+        */
+
+       $r = q("SELECT `uid` FROM `user`
+                       WHERE `nickname` = '%s' ",
+                       dbesc($nickname)
+       );
+       if((count($r) > 1) && $newuid) {
+               $err .= t('Nickname is already registered. Please choose another.') . EOL;
+               q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
+                       intval($newuid)
+               );
+               notice ($err);
+               return;
+       }
+
        if(x($newuid) !== false) {
                $r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` )
                        VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ",