cleanupTitles: Don't add 'Broken/' prefix if the title is valid without it
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 26 Jan 2018 03:17:01 +0000 (19:17 -0800)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 26 Jan 2018 03:17:01 +0000 (19:17 -0800)
In some cases, e.g. changes in Unicode normalization rules or
MediaWiki banning some invisible characters that were previously
allowed in titles, it's enough to just run the title through
normalization and update the database entry.

Change-Id: I786f31510bbd58c2ec02fc91918de5241c9050d6

maintenance/cleanupTitles.php

index 8c782d9..5b441f9 100644 (file)
@@ -137,7 +137,8 @@ class TitleCleanup extends TableCleanup {
                        || $title->getInterwiki()
                        || !$title->canExist()
                ) {
-                       if ( $title->getInterwiki() || !$title->canExist() ) {
+                       $titleImpossible = $title->getInterwiki() || !$title->canExist();
+                       if ( $titleImpossible ) {
                                $prior = $title->getPrefixedDBkey();
                        } else {
                                $prior = $title->getDBkey();
@@ -155,7 +156,12 @@ class TitleCleanup extends TableCleanup {
                                $ns = 0;
                        }
 
-                       $clean = 'Broken/' . $prior;
+                       if ( !$titleImpossible && !$title->exists() ) {
+                               // Looks like the current title, after cleaning it up, is valid and available
+                               $clean = $prior;
+                       } else {
+                               $clean = 'Broken/' . $prior;
+                       }
                        $verified = Title::makeTitleSafe( $ns, $clean );
                        if ( !$verified || $verified->exists() ) {
                                $blah = "Broken/id:" . $row->page_id;