From 1c8e68dae53b8574b855426c2341177bb8db8be8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 26 Jun 2007 20:18:23 +0000 Subject: [PATCH] * (bug 10372) namespaceDupes.php no longer ignores namespace aliases --- RELEASE-NOTES | 2 ++ maintenance/namespaceDupes.php | 40 +++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c88f6b1342..348804d837 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index c5c1ec583a..80469317dd 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -1,5 +1,5 @@ +# Copyright (C) 2005-2007 Brion Vibber # 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 <<] [--help] --fix : attempt to automatically fix errors --suffix= : dupes will be renamed with correct namespace with appended after the article name. + --prefix= : 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' ); - } } -- 2.20.1