Merge capitallinks message fixes from REL1_4
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 22 Dec 2004 07:28:11 +0000 (07:28 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 22 Dec 2004 07:28:11 +0000 (07:28 +0000)
includes/MessageCache.php
maintenance/InitialiseMessages.inc
maintenance/archives/moveCustomMessages.inc
maintenance/cleanupDupes.php

index 0476622..b464ae0 100755 (executable)
@@ -165,8 +165,7 @@ class MessageCache
                if ( !$this->mKeys ) {
                        $this->mKeys = array();
                        foreach ( $wgAllMessagesEn as $key => $value ) {
-                               global $wgCapitalLinks;
-                               $title = $wgCapitalLinks ? $wgContLang->ucfirst( $key ) : $key;
+                               $title = $wgContLang->ucfirst( $key );
                                array_push( $this->mKeys, $title );
                        }
                }
@@ -238,8 +237,7 @@ class MessageCache
 
                $message = false;
                if( !$this->mDisable && $useDB ) {
-                       global $wgCapitalLinks;
-                       $title = $wgCapitalLinks ? $lang->ucfirst( $key ) : $key;
+                       $title = $lang->ucfirst( $key );
                        if( $langcode != $wgContLanguageCode ) {
                                $title .= '/' . $langcode;
                        }
index 02eb932..9815770 100755 (executable)
@@ -140,7 +140,7 @@ function initialiseMessagesReal( $overwrite = false, $messageArray = false ) {
                } else {
                        $sql .= ',';
                }
-               $titleObj = Title::newFromText( $key );
+               $titleObj = Title::newFromText( $wgContLang->ucfirst( $key ) );
                $enctitle = $dbr->strencode($titleObj->getDBkey());
                $sql .= "'$enctitle'";
        }
@@ -178,7 +178,7 @@ function initialiseMessagesReal( $overwrite = false, $messageArray = false ) {
                } else {
                        $message = wfMsgNoDBForContent( $key );
                }
-               $titleObj = Title::newFromText( $key );
+               $titleObj = Title::newFromText( $wgContLang->ucfirst( $key ) );
                $title = $titleObj->getDBkey();
 
                # Update messages which already exist
index 2aa6dd2..5fb0d7c 100644 (file)
@@ -16,7 +16,7 @@ function isTemplateInitialised() {
 }
 
 function moveCustomMessages( $phase ) {
-       global $wgUser, $wgAllMessagesEn, $wgDeferredUpdateList, $wgLang;
+       global $wgUser, $wgAllMessagesEn, $wgDeferredUpdateList, $wgLang, $wgContLang;
        global $targets, $template, $replaceCount;
 
        $wgUser = new User;
@@ -32,7 +32,7 @@ function moveCustomMessages( $phase ) {
        $dbkeys = array();
 
        foreach ( $wgAllMessagesEn as $key => $enValue ) {
-               $title = Title::newFromText( $key );
+               $title = Title::newFromText( $wgContLang->ucfirst( $key ) );
                $dbkeys[$title->getDBkey()] = 1;
        }
 
index af85e7b..c4e41fa 100644 (file)
  * @subpackage Maintenance
  */
 
+$options = array( 'fix' );
+
 require_once( "commandLine.inc" );
-require_once( "rebuildtextindex.inc" );
-$wgTitle = Title::newFromText( "Rebuild text index script" );
+$wgTitle = Title::newFromText( "Dupe cur entry cleanup script" );
 
-checkDupes();
+checkDupes( isset( $options['fix'] ) );
 
-function fixDupes() {
+function fixDupes( $fixthem = false) {
        $dbw =& wfGetDB( DB_MASTER );
        $cur = $dbw->tableName( 'cur' );
        $dbw->query( "LOCK TABLES $cur WRITE" );
        echo "Checking for duplicate cur table entries... (this may take a while on a large wiki)\n";
        $res = $dbw->query( <<<END
-SELECT cur_namespace,cur_title,count(*) as c,max(cur_id) as id
+SELECT cur_namespace,cur_title,count(*) as c,min(cur_id) as id
   FROM $cur
  GROUP BY cur_namespace,cur_title
 HAVING c > 1
@@ -46,33 +47,44 @@ END
        $n = $dbw->numRows( $res );
        echo "Found $n titles with duplicate entries.\n";
        if( $n > 0 ) {
-               echo "Correcting...\n";
+               if( $fixthem ) {
+                       echo "Correcting...\n";
+               } else {
+                       echo "Just a demo...\n";
+               }
                while( $row = $dbw->fetchObject( $res ) ) {
                        $ns = IntVal( $row->cur_namespace );
                        $title = $dbw->addQuotes( $row->cur_title );
                        $id = IntVal( $row->id );
-                       $dbw->query( <<<END
+                       echo "$ns:$row->cur_title (canonical ID $id)\n";
+                       if( $fixthem ) {
+                               $dbw->query( <<<END
 DELETE
   FROM $cur
  WHERE cur_namespace=$ns
    AND cur_title=$title
-   AND cur_id<$id
+   AND cur_id>$id
 END
-                       );
+                               );
+                       }
                }
        }
        $dbw->query( 'UNLOCK TABLES' );
-       echo "Done.\n";
+       if( $fixthem ) {
+               echo "Done.\n";
+       } else {
+               echo "Run again with --fix option to delete the duplicates.\n";
+       }
 }
 
-function checkDupes() {
+function checkDupes( $fixthem = false ) {
        $dbw =& wfGetDB( DB_MASTER );
        if( $dbw->indexExists( 'cur', 'name_title' ) &&
            $dbw->indexUnique( 'cur', 'name_title' ) ) {
                echo "Your cur table has the current unique index; no duplicate entries.\n";
        } else {
                echo "Your cur table has the old non-unique index and may have duplicate entries.\n";
-               fixDupes();
+               fixDupes( $fixthem );
        }
 }