Example #1
0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# http://www.gnu.org/copyleft/gpl.html
$options = array('fix');
/** */
require_once 'commandLine.inc';
require_once 'maintenance/userDupes.inc';
$wgTitle = Title::newFromText('Dupe user entry cleanup script');
$fix = isset($options['fix']);
$dbw =& wfGetDB(DB_MASTER);
$duper = new UserDupes($dbw);
$retval = $duper->checkDupes($fix);
if ($retval) {
    echo "\nLooks good!\n";
    exit(0);
} else {
    echo "\nOh noeees\n";
    exit(-1);
}
Example #2
0
    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'));
    }
Example #3
0
 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");
 }
Example #4
0
 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");
 }