+ /**
+ * Rebuild pass 4
+ * DOCUMENT ME!
+ */
+ private function rebuildRecentChangesTablePass4() {
+ global $wgGroupPermissions, $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'] == true ) {
+ $botgroups[] = $dbw->addQuotes( $group );
+ }
+ if( $wgUseRCPatrol && isset( $rights['autopatrol'] ) && $rights['autopatrol'] == true ) {
+ $autopatrolgroups[] = $dbw->addQuotes( $group );
+ }
+ }
+ # Flag our recent bot edits
+ if( !empty($botgroups) ) {
+ $botwhere = implode(',',$botgroups);
+ $botusers = array();
+
+ $this->output( "Flagging bot account edits...\n" );
+
+ # Find all users that are bots
+ $sql = "SELECT DISTINCT user_name FROM $usergroups, $user " .
+ "WHERE ug_group IN($botwhere) AND user_id = ug_user";
+ $res = $dbw->query( $sql, DB_MASTER );
+
+ foreach( $res as $obj ) {
+ $botusers[] = $dbw->addQuotes( $obj->user_name );
+ }
+ # Fill in the rc_bot field
+ if( !empty($botusers) ) {
+ $botwhere = implode(',',$botusers);
+ $sql2 = "UPDATE $recentchanges SET rc_bot=1 " .
+ "WHERE rc_user_text IN($botwhere)";
+ $dbw->query( $sql2 );
+ }
+ }
+ global $wgMiserMode;
+ # Flag our recent autopatrolled edits
+ if( !$wgMiserMode && !empty($autopatrolgroups) ) {
+ $patrolwhere = implode(',',$autopatrolgroups);
+ $patrolusers = array();
+
+ $this->output( "Flagging auto-patrolled edits...\n" );
+
+ # Find all users in RC with autopatrol rights
+ $sql = "SELECT DISTINCT user_name FROM $usergroups, $user " .
+ "WHERE ug_group IN($patrolwhere) AND user_id = ug_user";
+ $res = $dbw->query( $sql, DB_MASTER );
+
+ foreach( $res as $obj ) {
+ $patrolusers[] = $dbw->addQuotes( $obj->user_name );
+ }
+
+ # Fill in the rc_patrolled field
+ if( !empty($patrolusers) ) {
+ $patrolwhere = implode(',',$patrolusers);
+ $sql2 = "UPDATE $recentchanges SET rc_patrolled=1 " .
+ "WHERE rc_user_text IN($patrolwhere)";
+ $dbw->query( $sql2 );
+ }
+ }
+
+ $dbw->freeResult( $res );
+ }