# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# http://www.gnu.org/copyleft/gpl.html
+/**
+ * @file
+ * @ingroup Maintenance
+ */
+
$options = array( 'fix', 'suffix', 'help' );
/** */
require_once( 'commandLine.inc' );
if(isset( $options['help'] ) ) {
-print <<<END
+print <<<ENDS
usage: namespaceDupes.php [--fix] [--suffix=<text>] [--help]
--help : this help message
--fix : attempt to automatically fix errors
in place of the standard namespace list.
--verbose : Display output for checked namespaces without conflicts
-END;
+ENDS;
die;
}
$spaces[$name] = $ns;
}
- if( !$wgCapitalLinks ) {
- // We'll need to check for lowercase keys as well,
- // since we're doing case-sensitive searches in the db.
- foreach( $spaces as $name => $ns ) {
- $lcname = $wgContLang->lcfirst( $name );
- $spaces[$lcname] = $ns;
+ // We'll need to check for lowercase keys as well,
+ // since we're doing case-sensitive searches in the db.
+ foreach( $spaces as $name => $ns ) {
+ $moreNames = array();
+ $moreNames[] = $wgContLang->uc( $name );
+ $moreNames[] = $wgContLang->ucfirst( $wgContLang->lc( $name ) );
+ $moreNames[] = $wgContLang->ucwords( $name );
+ $moreNames[] = $wgContLang->ucwords( $wgContLang->lc( $name ) );
+ $moreNames[] = $wgContLang->ucwordbreaks( $name );
+ $moreNames[] = $wgContLang->ucwordbreaks( $wgContLang->lc( $name ) );
+ if( !$wgCapitalLinks ) {
+ foreach( $moreNames as $altName ) {
+ $moreNames[] = $wgContLang->lcfirst( $altName );
+ }
+ $moreNames[] = $wgContLang->lcfirst( $name );
+ }
+ foreach( array_unique( $moreNames ) as $altName ) {
+ if( $altName !== $name ) {
+ $spaces[$altName] = $ns;
+ }
}
}
+
ksort( $spaces );
asort( $spaces );
$row->id,
$row->oldtitle,
$newTitle->getNamespace(),
- $newTitle->getDbKey(),
+ $newTitle->getDBkey(),
$newTitle->getPrefixedText() );
$id = $newTitle->getArticleId();
function resolveConflict( $row, $resolvable, $suffix ) {
if( !$resolvable ) {
+ echo "... *** old title {$row->title}\n";
$row->title .= $suffix;
+ echo "... *** new title {$row->title}\n";
$title = Title::makeTitleSafe( $row->namespace, $row->title );
+ if ( ! $title ) {
+ echo "... !!! invalid title\n";
+ return false;
+ }
echo "... *** using suffixed form [[" . $title->getPrefixedText() . "]] ***\n";
}
$tables = array( 'page' );
$this->db->update( $table,
array(
"{$table}_namespace" => $newTitle->getNamespace(),
- "{$table}_title" => $newTitle->getDbKey(),
+ "{$table}_title" => $newTitle->getDBkey(),
),
array(
"{$table}_namespace" => 0,