Quick hacky script to initialize site_stats row where missing.
[lhc/web/wiklou.git] / maintenance / rebuildrecentchanges.inc
index 13a8da0..b7c54b7 100644 (file)
@@ -34,7 +34,7 @@ function rebuildRecentChangesTablePass1()
                        'rc_this_oldid' => 0,
                        'rc_last_oldid' => 0,
                        'rc_type' => $dbw->conditional( 'cur_is_new != 0', RC_NEW, RC_EDIT ),
-               ), '*', $fname, array( 'ORDER BY' => 'inverse_timestamp', 'LIMIT' => 5000 )
+               ), '*', $fname, array( 'ORDER BY' => 'cur_timestamp DESC', 'LIMIT' => 5000 )
        );
        
        print( "Loading from OLD table...\n" );
@@ -44,12 +44,13 @@ function rebuildRecentChangesTablePass1()
       "rc_cur_id,rc_this_oldid,rc_last_oldid,rc_type) SELECT old_timestamp,cur_timestamp," .
          "old_user,old_user_text,old_namespace,old_title,old_comment," .
          "old_minor_edit,0,0,cur_id,old_id,0,0 FROM $old,$cur " .
-         "WHERE old_namespace=cur_namespace AND old_title=cur_title ORDER BY $old.inverse_timestamp " .
+         "WHERE old_namespace=cur_namespace AND old_title=cur_title ORDER BY old_timestamp DESC " .
          "LIMIT 5000";
        $dbw->query( $sql );
 
        $sql = "SELECT rc_timestamp FROM $recentchanges " .
-         "ORDER BY rc_timestamp DESC" . $dbw->limitResult( 1, 5000 );
+         "ORDER BY rc_timestamp DESC";
+       $sql = $dbw->limitResult($sql, 1, 5000 );
        $res = $dbw->query( $sql );
        $obj = $dbw->fetchObject( $res );
        if( $obj ) {
@@ -82,14 +83,14 @@ function rebuildRecentChangesTablePass2()
                $new = 0;
                if( $obj->rc_cur_id != $lastCurId ) {
                        # Switch! Look up the previous last edit, if any
-                       $lastCurId = IntVal( $obj->rc_cur_id );
-                       $emit = wfInvertTimestamp( $obj->rc_timestamp );
+                       $lastCurId = intval( $obj->rc_cur_id );
+                       $emit = $obj->rc_timestamp;
                        $sql2 = "SELECT old_id FROM $old,$cur " .
                                "WHERE old_namespace=cur_namespace AND old_title=cur_title AND cur_id={$lastCurId} ".
-                               "AND $old.inverse_timestamp>'{$emit}' ORDER BY $old.inverse_timestamp LIMIT 1";
+                               "AND old_timestamp<'{$emit}' ORDER BY old_timestamp DESC LIMIT 1";
                        $res2 = $dbw->query( $sql2 );
                        if( $row = $dbw->fetchObject( $res2 ) ) {
-                               $lastOldId = IntVal( $row->old_id );
+                               $lastOldId = intval( $row->old_id );
                        } else {
                                # No previous edit
                                $lastOldId = 0;
@@ -103,7 +104,7 @@ function rebuildRecentChangesTablePass2()
                        $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new " .
                                "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}";
                        $dbw->query( $sql3 );
-                       $lastOldId = IntVal( $obj->rc_this_oldid );
+                       $lastOldId = intval( $obj->rc_this_oldid );
                }
        }
        $dbw->freeResult( $res );