2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
21 * If on the old non-unique indexes, check the cur table for duplicate
22 * entries and remove them...
25 * @subpackage Maintenance
28 require_once( "commandLine.inc" );
29 require_once( "rebuildtextindex.inc" );
30 $wgTitle = Title
::newFromText( "Rebuild text index script" );
35 $dbw =& wfGetDB( DB_MASTER
);
36 $cur = $dbw->tableName( 'cur' );
37 $dbw->query( "LOCK TABLES $cur WRITE" );
38 echo "Checking for duplicate cur table entries... (this may take a while on a large wiki)\n";
39 $res = $dbw->query( <<<END
40 SELECT cur_namespace,cur_title,count(*) as c,max(cur_id) as id
42 GROUP BY cur_namespace,cur_title
46 $n = $dbw->numRows( $res );
47 echo "Found $n titles with duplicate entries.\n";
49 echo "Correcting...\n";
50 while( $row = $dbw->fetchObject( $res ) ) {
51 $ns = IntVal( $row->cur_namespace
);
52 $title = $dbw->addQuotes( $row->cur_title
);
53 $id = IntVal( $row->id
);
57 WHERE cur_namespace=$ns
64 $dbw->query( 'UNLOCK TABLES' );
68 function checkDupes() {
69 $dbw =& wfGetDB( DB_MASTER
);
70 if( $dbw->indexExists( 'cur', 'name_title' ) &&
71 $dbw->indexUnique( 'cur', 'name_title' ) ) {
72 echo "Your cur table has the current unique index; no duplicate entries.\n";
74 echo "Your cur table has the old non-unique index and may have duplicate entries.\n";