function upgradeUser() { // Apply unique index, if necessary: $duper = new UserDupes($this->dbw, array($this, 'userDupeCallback')); if ($duper->hasUniqueIndex()) { $this->log("Already have unique user_name index."); } else { $this->log("Clearing user duplicates..."); if (!$duper->clearDupes()) { $this->log("WARNING: Duplicate user accounts, may explode!"); } } $tabledef = <<<END CREATE TABLE \$1 ( user_id int(5) unsigned NOT NULL auto_increment, user_name varchar(255) binary NOT NULL default '', user_real_name varchar(255) binary NOT NULL default '', user_password tinyblob NOT NULL default '', user_newpassword tinyblob NOT NULL default '', user_email tinytext NOT NULL default '', user_options blob NOT NULL default '', user_touched char(14) binary NOT NULL default '', user_token char(32) binary NOT NULL default '', user_email_authenticated CHAR(14) BINARY, user_email_token CHAR(32) BINARY, user_email_token_expires CHAR(14) BINARY, PRIMARY KEY user_id (user_id), UNIQUE INDEX user_name (user_name), INDEX (user_email_token) ) TYPE=InnoDB END; $fields = array('user_id' => MW_UPGRADE_COPY, 'user_name' => MW_UPGRADE_ENCODE, 'user_real_name' => MW_UPGRADE_ENCODE, 'user_password' => MW_UPGRADE_COPY, 'user_newpassword' => MW_UPGRADE_COPY, 'user_email' => MW_UPGRADE_ENCODE, 'user_options' => MW_UPGRADE_ENCODE, 'user_touched' => MW_UPGRADE_CALLBACK, 'user_token' => MW_UPGRADE_COPY, 'user_email_authenticated' => MW_UPGRADE_CALLBACK, 'user_email_token' => MW_UPGRADE_NULL, 'user_email_token_expires' => MW_UPGRADE_NULL); $this->copyTable('user', $tabledef, $fields, array(&$this, 'userCallback')); }
protected function doUserUniqueUpdate() { $duper = new UserDupes($this->db, array($this, 'output')); if ($duper->hasUniqueIndex()) { $this->output("...already have unique user_name index.\n"); return; } if (!$duper->clearDupes()) { $this->output("WARNING: This next step will probably fail due to unfixed duplicates...\n"); } $this->output("Adding unique index on user_name... "); $this->applyPatch('patch-user_nameindex.sql'); $this->output("done.\n"); }
protected function doUserUniqueUpdate() { if (!$this->doTable('user')) { return true; } $duper = new UserDupes($this->db, [$this, 'output']); if ($duper->hasUniqueIndex()) { $this->output("...already have unique user_name index.\n"); return; } if (!$duper->clearDupes()) { $this->output("WARNING: This next step will probably fail due to unfixed duplicates...\n"); } $this->applyPatch('patch-user_nameindex.sql', false, "Adding unique index on user_name"); }