Localisation updates from http://translatewiki.net.
[lhc/web/wiklou.git] / maintenance / rebuildrecentchanges.php
index 3a1b9e1..bfaaab5 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' );
+require_once( __DIR__ . '/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,7 +138,6 @@ 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(
@@ -214,24 +218,17 @@ class RebuildRecentchanges extends Maintenance {
         * DOCUMENT ME!
         */
        private function rebuildRecentChangesTablePass4() {
-               global $wgGroupPermissions, $wgUseRCPatrol;
+               global $wgUseRCPatrol;
 
                $dbw = wfGetDB( DB_MASTER );
 
                list( $recentchanges, $usergroups, $user ) = $dbw->tableNamesN( 'recentchanges', 'user_groups', 'user' );
 
-               $botgroups = $autopatrolgroups = array();
-               foreach ( $wgGroupPermissions as $group => $rights ) {
-                       if ( isset( $rights['bot'] ) && $rights['bot'] ) {
-                               $botgroups[] = $dbw->addQuotes( $group );
-                       }
-                       if ( $wgUseRCPatrol && isset( $rights['autopatrol'] ) && $rights['autopatrol'] ) {
-                               $autopatrolgroups[] = $dbw->addQuotes( $group );
-                       }
-               }
+               $botgroups = User::getGroupsWithPermission( 'bot' );
+               $autopatrolgroups = $wgUseRCPatrol ? User::getGroupsWithPermission( 'autopatrol' ) : array();
                # Flag our recent bot edits
                if ( !empty( $botgroups ) ) {
-                       $botwhere = implode( ',', $botgroups );
+                       $botwhere = $dbw->makeList( $botgroups );
                        $botusers = array();
 
                        $this->output( "Flagging bot account edits...\n" );
@@ -255,7 +252,7 @@ class RebuildRecentchanges extends Maintenance {
                global $wgMiserMode;
                # Flag our recent autopatrolled edits
                if ( !$wgMiserMode && !empty( $autopatrolgroups ) ) {
-                       $patrolwhere = implode( ',', $autopatrolgroups );
+                       $patrolwhere = $dbw->makeList( $autopatrolgroups );
                        $patrolusers = array();
 
                        $this->output( "Flagging auto-patrolled edits...\n" );
@@ -295,4 +292,4 @@ class RebuildRecentchanges extends Maintenance {
 }
 
 $maintClass = "RebuildRecentchanges";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );