merging latest master
[lhc/web/wiklou.git] / maintenance / rebuildrecentchanges.php
index f627892..5caa0a8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
- * Rebuild link tracking tables from scratch.  This takes several
- * hours, depending on the database size and server configuration.
+ * Rebuild recent changes from scratch.  This takes several hours,
+ * depending on the database size and server configuration.
  *
  * 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
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @ingroup Maintenance
  * @todo Document
  */
 
 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
+/**
+ * Maintenance script that rebuilds recent changes from scratch.
+ *
+ * @ingroup Maintenance
+ */
 class RebuildRecentchanges extends Maintenance {
        public function __construct() {
                parent::__construct();
@@ -43,8 +49,7 @@ class RebuildRecentchanges extends Maintenance {
         * Rebuild pass 1
         * DOCUMENT ME!
         */
-       function rebuildRecentChangesTablePass1()
-       {
+       private function rebuildRecentChangesTablePass1() {
                $dbw = wfGetDB( DB_MASTER );
 
                $dbw->delete( 'recentchanges', '*' );
@@ -120,11 +125,11 @@ class RebuildRecentchanges extends Maintenance {
                                if ( $row ) {
                                        $lastOldId = intval( $row->rev_id );
                                        # Grab the last text size if available
-                                       $lastSize = !is_null( $row->rev_len ) ? intval( $row->rev_len ) : 'NULL';
+                                       $lastSize = !is_null( $row->rev_len ) ? intval( $row->rev_len ) : null;
                                } else {
                                        # No previous edit
                                        $lastOldId = 0;
-                                       $lastSize = 'NULL';
+                                       $lastSize = null;
                                        $new = 1; // probably true
                                }
                        }
@@ -133,14 +138,16 @@ class RebuildRecentchanges extends Maintenance {
                        } else {
                                # Grab the entry's text size
                                $size = $dbw->selectField( 'revision', 'rev_len', array( 'rev_id' => $obj->rc_this_oldid ) );
-                               $size = !is_null( $size ) ? intval( $size ) : 'NULL';
 
                                $dbw->update( 'recentchanges',
                                        array(
-                                               'rc_old_len' => $lastSize,
-                                               'rc_new_len' => $size,
+                                               'rc_last_oldid' => $lastOldId,
+                                               'rc_new'        => $new,
+                                               'rc_type'       => $new,
+                                               'rc_old_len'    => $lastSize,
+                                               'rc_new_len'    => $size,
                                        ), array(
-                                               'rc_cur_id' => $lastCurId,
+                                               'rc_cur_id'     => $lastCurId,
                                                'rc_this_oldid' => $obj->rc_this_oldid,
                                        ),
                                        __METHOD__
@@ -292,4 +299,4 @@ class RebuildRecentchanges extends Maintenance {
 }
 
 $maintClass = "RebuildRecentchanges";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );