script to move "custom messages" to the Template namespace
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 23 Mar 2004 10:29:30 +0000 (10:29 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 23 Mar 2004 10:29:30 +0000 (10:29 +0000)
maintenance/archives/moveCustomMessages.php [new file with mode: 0644]

diff --git a/maintenance/archives/moveCustomMessages.php b/maintenance/archives/moveCustomMessages.php
new file mode 100644 (file)
index 0000000..02c2421
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+# Move "custom messages" from the MediaWiki namespace to the Template namespace
+
+chdir( ".." );
+include_once( "commandLine.inc" );
+
+# Compose DB key array
+global $wgAllMessagesEn;
+$dbkeys = array();
+
+foreach ( $wgAllMessagesEn as $key => $enValue )
+{
+       $title = Title::newFromText( $key );
+       $dbkeys[$title->getDBkey()] = 1;
+}
+
+$sql = "SELECT cur_id, cur_title FROM cur WHERE cur_namespace= " . NS_MEDIAWIKI;
+$res = wfQuery( $sql, DB_READ );
+$first = true;
+while ( $row = wfFetchObject( $res ) ) {
+       $partial = $row->cur_title;
+       print "$partial...";
+       if ( !array_key_exists( $partial, $dbkeys ) ) {
+               $ot = Title::makeTitle( NS_MEDIAWIKI, $partial );
+               $nt = Title::makeTitle( NS_TEMPLATE, $partial );
+               if ( $ot->moveNoAuth( $nt ) === true ) {
+                       print "moved\n";
+               } else {
+                       print "not moved\n";
+               }
+               # Clear deferred updates
+               while ( count( $wgDeferredUpdateList ) ) {
+                       $up = array_pop( $wgDeferredUpdateList );
+                       $up->doUpdate();
+               }
+               $first = false;
+       } else {
+               print "internal\n";
+       }
+}
+if ( $first ) {
+       print "Nothing to move\n";
+}
+
+?>