Fixed bug in edit conflict merge feature -- didn't decompress old_text
[lhc/web/wiklou.git] / maintenance / rebuildlinks.inc
index cf532cc..3aba4d0 100644 (file)
@@ -1,4 +1,6 @@
-<?
+<?php
+
+die( "rebuildLinks.inc needs to be updated for the new schema\n" );
 
 # Functions for rebuilding the link tracking tables; must
 # be included within a script that also includes the Setup.
@@ -27,11 +29,18 @@ function rebuildLinkTables()
        print "Setting AUTOCOMMIT=1\n";
        wfQuery("SET SESSION AUTOCOMMIT=1", DB_WRITE);
 
+       print "Extracting often used data from cur (may take a few minutes)\n";
+       $sql = "CREATE TEMPORARY TABLE cur_fast SELECT cur_namespace, cur_title, cur_id FROM cur";
+       wfQuery( $sql, DB_WRITE );
+       $sql = "ALTER TABLE cur_fast ADD INDEX(cur_namespace, cur_title)";
+       wfQuery( $sql, DB_WRITE );
+
        print "Locking tables\n";
-       $sql = "LOCK TABLES cur READ, interwiki READ, user_newtalk READ, " .
+       $sql = "LOCK TABLES cur READ, cur_fast READ, interwiki READ, user_newtalk READ, " .
                "links WRITE, brokenlinks WRITE, imagelinks WRITE";
        wfQuery( $sql, DB_WRITE );
 
+
        print "Deleting old data in links table.\n";
        $sql = "DELETE FROM links";
        wfQuery( $sql, DB_WRITE );
@@ -120,7 +129,7 @@ function rebuildLinkTables()
                        } else {
                                $nt = Title::newFromText( $link );
                                if (! $nt) {
-                                       print "\nInvalid link in page '{$from_full_title}': '$link'\n";
+                                       // Invalid link, probably something like "[[  ]]"
                                        continue;
                                }
                                
@@ -158,7 +167,8 @@ function rebuildLinkTables()
                                $parts[] = " (cur_namespace = " . $nt->getNamespace() . " AND " .
                                        "cur_title='" . wfStrencode( $nt->getDBkey() ) . "')";
                        }
-                       $sql = "SELECT cur_namespace, cur_title, cur_id FROM cur WHERE " . implode(" OR ", $parts);
+                       $sql = "SELECT cur_namespace, cur_title, cur_id FROM cur_fast WHERE " . 
+                               implode(" OR ", $parts);
                        $res = wfQuery( $sql, DB_WRITE );
                        while($row = wfFetchObject( $res ) ){
                                $pos = $titles_needing_curdata_pos[$row->cur_title . $row->cur_namespace];