Had a bash at cleaning up the horrendous-looking deletion log on the edit page:
[lhc/web/wiklou.git] / maintenance / importPhase2.php
index e53097b..a923b3d 100644 (file)
@@ -1,31 +1,30 @@
 <?php
 # MediaWiki 'phase 2' to current format import script
 # (import format current as of 1.2.0, March 2004)
-# 
+#
 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
 # Portions by Lee Daniel Crocker, 2002
 # http://www.mediawiki.org/
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or 
+# the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 # http://www.gnu.org/copyleft/gpl.html
 
 /**
  * @todo document
  * @deprecated
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  */
 
 /** */
@@ -61,29 +60,28 @@ require_once( "rebuildtextindex.inc" );
 
 /**
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  */
 class Phase2Importer {
        var $olddb, $titleCache;
-       
+
        function Phase2Importer( $database ) {
                $this->olddb = $database;
                $this->titleCache = new TitleCache;
        }
-       
+
        function importAll() {
                $this->importCurData();
                $this->fixCurTitles();
-               
+
                $this->importOldData();
                $this->fixOldTitles();
-               
+
                $this->importUserData();
                $this->fixUserOptions();
-               
+
                $this->importWatchlists();
-               
+
                $this->importLinkData();
 
                /*
@@ -91,21 +89,21 @@ class Phase2Importer {
                rebuildRecentChangesTablePass1();
                rebuildRecentChangesTablePass2();
                */
-               
+
                print "Rebuilding search index:\n";
                dropTextIndex();
                rebuildTextIndex();
                createTextIndex();
-               
+
                initialiseMessages();
        }
-       
+
        # Simple import functions; for the most part these are pretty straightforward.
        # MySQL copies everything over to the new database and tweaks a few things.
        function importCurData() {
                print "Clearing pages from default install, if any...\n";
                wfQuery( "DELETE FROM cur", DB_MASTER );
-               
+
                print "Importing current revision data...\n";
                wfQuery( "INSERT INTO cur (cur_id,cur_namespace,cur_title,cur_text,cur_comment,
                        cur_user,cur_user_text,cur_timestamp,cur_restrictions,cur_counter,
@@ -137,7 +135,7 @@ class Phase2Importer {
                wfQuery( "DELETE FROM user", DB_MASTER );
 
                print "Importing user data...\n";
-               wfQuery( "INSERT INTO $newdb.user (user_id,user_name,user_rights,
+               wfQuery( "INSERT INTO user (user_id,user_name,user_rights,
                        user_password,user_newpassword,user_email,user_options,user_touched)
                        SELECT user_id,user_name,REPLACE(user_rights,'is_',''),
                                MD5(CONCAT(user_id,'-',MD5(user_password))),'',user_email,user_options,NOW()+0
@@ -156,9 +154,9 @@ class Phase2Importer {
                $total = wfNumRows( $res );
                $n = 0;
                print " ($total total)\n";
-               
+
                while( $row = wfFetchObject( $res ) ) {
-                       $id = IntVal( $row->user_id );
+                       $id = intval( $row->user_id );
                        $list = explode( "\n", $row->user_watch );
                        foreach( $list as $page ) {
                                $title = $this->titleCache->fetch( $page );
@@ -176,7 +174,7 @@ class Phase2Importer {
                }
                wfFreeResult( $res );
        }
-       
+
        function importLinkData() {
                # MUST BE CALLED BEFORE! fixCurTitles()
                print "Clearing links from default install, if any...\n";
@@ -190,7 +188,7 @@ class Phase2Importer {
                                        WHERE linked_to=cur_title", DB_MASTER );
                $n = mysql_affected_rows();
                print "$n rows imported.\n";
-               
+
                print "Importing broken links...";
                wfQuery( "INSERT INTO brokenlinks (bl_from, bl_to)
                                        SELECT DISTINCT cur_id,unlinked_to
@@ -204,18 +202,18 @@ class Phase2Importer {
        function fixCurTitles() {
                $this->fixTitles( "cur" );
        }
-       
+
        function fixOldTitles() {
                $this->fixTitles( "old" );
        }
-       
+
        function fixTitles( $table ) {
                print "Fixing titles in $table...";
                $res = wfQuery( "SELECT DISTINCT {$table}_title AS title FROM $table", DB_MASTER );
                $total = wfNumRows( $res );
                $n = 0;
                print " ($total total)\n";
-               
+
                while( $row = wfFetchObject( $res ) ) {
                        $xt = wfStrencode( $row->title );
                        $title = $this->titleCache->fetch( $row->title );
@@ -238,19 +236,20 @@ class Phase2Importer {
        {
                $s = urldecode( $in );
                $a = explode( "\n", $s );
-       
+
                foreach ( $a as $l ) {
+                       $m = array();
                        if ( preg_match( "/^([A-Za-z0-9_]+)=(.*)/", $l, $m ) ) {
                                $ops[$m[1]] = $m[2];
                        }
                }
                $nops = array();
-       
+
                $q = strtolower( $ops["quickBar"] );
                if ( $q == "none" ) { $q = 0; }
                else { $q = 1; } # Default to left
                $nops["quickbar"] = $q;
-       
+
                if ( $ops["markupNewTopics"] == "inverse" ) {
                        $nops["highlightbroken"] = 1;
                }
@@ -260,15 +259,15 @@ class Phase2Importer {
                else if ( "colo" == $sk ) { $sk = 2; }
                else { $sk = 0; }
                $nops["skin"] = $sk;
-       
+
                $u = strtolower( $ops["underlineLinks"] );
                if ( "yes" == $u || "on" == $u ) { $nops["underline"] = 1; }
                else { $nops["underline"] = 0; }
-       
+
                $t = ( (int) ($ops["hourDiff"]) );
                if ( $t < -23 || $t > 23 ) { $t = 0; }
                if ( 0 != $t ) { $nops["timecorrection"] = $t; }
-       
+
                $j = strtolower( $ops["justify"] );
                if ( "yes" == $j || "on" == $j ) { $nops["justify"] = 1; }
                $n = strtolower( $ops["numberHeadings"] );
@@ -279,7 +278,7 @@ class Phase2Importer {
                if ( "yes" == $r || "on" == $r ) { $nops["rememberpassword"] = 1; }
                $s = strtolower( $ops["showHover"] );
                if ( "yes" == $s || "on" == $s ) { $nops["hover"] = 1; }
-       
+
                $c = $ops["cols"];
                if ( $c < 20 || $c > 200 ) { $nops["cols"] = 80; }
                else { $nops["cols"] = $c; }
@@ -293,7 +292,7 @@ class Phase2Importer {
                if ( $r < 10 || $r > 1000 ) { $nops["rclimit"] = 50; }
                else { $nops["rclimit"] = $r; }
                $nops["rcdays"] = 3;
-       
+
                $a = array();
                foreach ( $nops as $oname => $oval ) {
                        array_push( $a, "$oname=$oval" );
@@ -308,9 +307,9 @@ class Phase2Importer {
                $total = wfNumRows( $res );
                $n = 0;
                print " ($total total)\n";
-               
+
                while( $row = wfFetchObject( $res ) ) {
-                       $id = IntVal( $row->user_id );
+                       $id = intval( $row->user_id );
                        $option = wfStrencode( $this->rewriteUserOptions( $row->user_options ) );
                        wfQuery( "UPDATE user SET user_options='$option' WHERE user_id=$id LIMIT 1", DB_MASTER );
                        if( ++$n % 50 == 0 ) {
@@ -319,24 +318,23 @@ class Phase2Importer {
                }
                wfFreeResult( $res );
        }
-       
+
 }
 
 /**
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  */
 class TitleCache {
        var $hash = array();
-       
+
        function &fetch( $dbkey ) {
-               if( !isset( $hash[$dbkey] ) ) {
-                       $hash[$dbkey] = Title::newFromDBkey( $dbkey );
+               if( !isset( $this->hash[$dbkey] ) ) {
+                       $this->hash[$dbkey] = Title::newFromDBkey( $dbkey );
                }
-               return $hash[$dbkey];
+               return $this->hash[$dbkey];
        }
-       
+
 }
 
 #