Correctly handle incorrect namespace in cleanupTitles.php
authorAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Tue, 12 Aug 2014 18:46:31 +0000 (20:46 +0200)
committerAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Tue, 12 Aug 2014 18:46:31 +0000 (20:46 +0200)
If the namespace is not valid; Title::makeTitleSafe() will
return null, thus producing a fatal error. Work arround this
by setting the namespace to 0 in that case.

Bug: 68501
Change-Id: I0c22f9468ff2bf11d2bf4a9265fa454ece2c0fa3

maintenance/cleanupTitles.php

index 72b6aa5..eee1204 100644 (file)
@@ -148,6 +148,12 @@ class TitleCleanup extends TableCleanup {
                                $ns = 0;
                        }
 
+                       # Namespace which no longer exists. Put the page in the main namespace
+                       # since we don't have any idea of the old namespace name. See bug 68501.
+                       if ( !MWNamespace::exists( $ns ) ) {
+                               $ns = 0;
+                       }
+
                        $clean = 'Broken/' . $prior;
                        $verified = Title::makeTitleSafe( $ns, $clean );
                        if ( $verified->exists() ) {