* (bug 10372) namespaceDupes.php no longer ignores namespace aliases
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 26 Jun 2007 20:18:23 +0000 (20:18 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 26 Jun 2007 20:18:23 +0000 (20:18 +0000)
RELEASE-NOTES
maintenance/namespaceDupes.php

index c88f6b1..348804d 100644 (file)
@@ -212,6 +212,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   Special:Prefixindex; making forms prettier for RTL wikis.
 * (bug 10334) Replace normal spaces before percent (%) signs with non-breaking
   spaces
+* (bug 10372) namespaceDupes.php no longer ignores namespace aliases
+
 
 == API changes since 1.10 ==
 
index c5c1ec5..8046931 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-# Copyright (C) 2005 Brion Vibber <brion@pobox.com>
+# Copyright (C) 2005-2007 Brion Vibber <brion@pobox.com>
 # http://www.mediawiki.org/
 #
 # This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,6 @@ $options = array( 'fix', 'suffix', 'help' );
 
 /** */
 require_once( 'commandLine.inc' );
-#require_once( 'maintenance/userDupes.inc' );
 
 if(isset( $options['help'] ) ) {
 print <<<END
@@ -30,21 +29,38 @@ usage: namespaceDupes.php [--fix] [--suffix=<text>] [--help]
     --fix           : attempt to automatically fix errors
     --suffix=<text> : dupes will be renamed with correct namespace with <text>
                       appended after the article name.
+    --prefix=<text> : Do an explicit check for the given title prefix
+                      in place of the standard namespace list.
 
 END;
 die;
 }
 
 class NamespaceConflictChecker {
-       function NamespaceConflictChecker( &$db ) {
-               $this->db =& $db;
+       function NamespaceConflictChecker( $db ) {
+               $this->db = $db;
        }
 
        function checkAll( $fix, $suffix = '' ) {
-               global $wgContLang;
-               $spaces = $wgContLang->getNamespaces();
+               global $wgContLang, $wgNamespaceAliases, $wgCanonicalNamespaceNames;
+               
+               $spaces = array();
+               foreach( $wgContLang->getNamespaces() as $ns => $name ) {
+                       $spaces[$name] = $ns;
+               }
+               foreach( $wgCanonicalNamespaceNames as $ns => $name ) {
+                       $spaces[$name] = $ns;
+               }
+               foreach( $wgNamespaceAliases as $name => $ns ) {
+                       $spaces[$name] = $ns;
+               }
+               foreach( $wgContLang->namespaceAliases as $name => $ns ) {
+                       $spaces[$name] = $ns;
+               }
+               asort( $spaces );
+               
                $ok = true;
-               foreach( $spaces as $ns => $name ) {
+               foreach( $spaces as $name => $ns ) {
                        $ok = $this->checkNamespace( $ns, $name, $fix, $suffix ) && $ok;
                }
                return $ok;
@@ -85,7 +101,7 @@ class NamespaceConflictChecker {
        }
 
        function getConflicts( $ns, $name ) {
-               $page  = $this->newSchema() ? 'page' : 'cur';
+               $page  = 'page';
                $table = $this->db->tableName( $page );
 
                $prefix     = $this->db->strencode( $name );
@@ -134,9 +150,7 @@ class NamespaceConflictChecker {
                        $title = Title::makeTitleSafe( $row->namespace, $row->title );
                        echo "...  *** using suffixed form [[" . $title->getPrefixedText() . "]] ***\n";
                }
-               $tables = $this->newSchema()
-                       ? array( 'page' )
-                       : array( 'cur', 'old' );
+               $tables = array( 'page' );
                foreach( $tables as $table ) {
                        $this->resolveConflictOn( $row, $table );
                }
@@ -160,10 +174,6 @@ class NamespaceConflictChecker {
                echo "ok.\n";
                return true;
        }
-
-       function newSchema() {
-               return class_exists( 'Revision' );
-       }
 }