Browse Source

repair duplicate nickname accounts caused by race condition

pull/1/head
Friendika 10 years ago
parent
commit
6bc5d6f17b
2 changed files with 19 additions and 1 deletions
  1. +1
    -1
      boot.php
  2. +18
    -0
      mod/register.php

+ 1
- 1
boot.php View File

@ -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 );


+ 18
- 0
mod/register.php View 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 ) ",


Loading…
Cancel
Save