updated for 1.5
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 24 Jun 2005 22:27:58 +0000 (22:27 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 24 Jun 2005 22:27:58 +0000 (22:27 +0000)
maintenance/rebuildInterwiki.inc

index e102bb0..76ef6ff 100644 (file)
@@ -9,10 +9,6 @@
  */
 
 /** */
-$oldCwd = getcwd();
-
-$optionsWithArgs = array( "o" );
-include_once( "commandLine.inc" );
 
 /**
  * @todo document
@@ -34,14 +30,15 @@ class Site {
 }
 
 function getRebuildInterwikiSQL() {
-       global $langlist, $languageAliases;
+       global $langlist, $languageAliases, $wgDBname;
 
        # Initialise lists of wikis
        $sites = array( 
                'wiki' => new Site( 'wiki', 'w', 'wikipedia.org' ),
                'wiktionary' => new Site( 'wiktionary', 'wikt', 'wiktionary.org' ),
                'wikiquote' => new Site( 'wikiquote', 'q', 'wikiquote.org' ),
-               'wikibooks' => new Site( 'wikibooks', 'b', 'wikibooks.org' )
+               'wikibooks' => new Site( 'wikibooks', 'b', 'wikibooks.org' ),
+               'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ),
        );
        $langlist = array_map( "trim", file( "/home/wikipedia/common/langlist" ) );
        $dblist = array_map( "trim", file( "/home/wikipedia/common/all.dblist" ) );
@@ -64,6 +61,7 @@ function getRebuildInterwikiSQL() {
                'zh-cn' => 'zh',
                'zh-tw' => 'zh',
                'dk' => 'da',
+               'nb' => 'no',
        );
 
        # Construct a list of reserved prefixes
@@ -79,15 +77,12 @@ function getRebuildInterwikiSQL() {
        }
 
        # Extract the intermap from meta
-       $dbr =& wfGetDB( DB_WRITE );
-       $row = $dbr->selectRow( "metawiki.cur", array( "cur_text" ), 
-               array( "cur_namespace" => 0, "cur_title" => "Interwiki_map" ) );
+       $lines = file( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw' );
 
-       if ( !$row ) {
+       if ( !$lines ) {
                die( "m:Interwiki_map not found" );
        }
 
-       $lines = explode( "\n", $row->cur_text );
        $iwArray = array();
 
        foreach ( $lines as $line ) {
@@ -101,7 +96,7 @@ function getRebuildInterwikiSQL() {
                        }
                        
                        if ( empty( $reserved[$prefix] ) ) {
-                               $iwArray[] = array( "iw_prefix" => $prefix, "iw_url" => $url, "iw_local" => $local );
+                               $iwArray[$prefix] = array( "iw_prefix" => $prefix, "iw_url" => $url, "iw_local" => $local );
                        }
                }
        }
@@ -229,7 +224,8 @@ function makeLink( $entry, &$first ) {
        } else {
                $sql .= ",\n";
        }
-       $sql .= "(" . Database::makeList( $entry ) . ")";
+       $dbr =& wfGetDB( DB_SLAVE );
+       $sql .= "(" . $dbr->makeList( $entry ) . ")";
        return $sql;
 }