+ foreach ( array_chunk( $rcids, $this->mBatchSize ) as $rcidBatch ) {
+ $dbw->delete( 'recentchanges', [ 'rc_id' => $rcidBatch ], __METHOD__ );
+ wfGetLBFactory()->waitForReplication();
+ }
+
+ $this->output( "Loading from page and revision tables...\n" );
+
+ $commentQuery = $revCommentStore->getJoin();
+ $res = $dbw->select(
+ [ 'revision', 'page' ] + $commentQuery['tables'],
+ [
+ 'rev_timestamp',
+ 'rev_user',
+ 'rev_user_text',
+ 'rev_minor_edit',
+ 'rev_id',
+ 'rev_deleted',
+ 'page_namespace',
+ 'page_title',
+ 'page_is_new',
+ 'page_id'
+ ] + $commentQuery['fields'],
+ [
+ 'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $this->cutoffFrom ) ),
+ 'rev_timestamp < ' . $dbw->addQuotes( $dbw->timestamp( $this->cutoffTo ) )
+ ],
+ __METHOD__,
+ [ 'ORDER BY' => 'rev_timestamp DESC' ],
+ [
+ 'page' => [ 'JOIN', 'rev_page=page_id' ],
+ ] + $commentQuery['joins']
+ );
+
+ $this->output( "Inserting from page and revision tables...\n" );
+ $inserted = 0;
+ foreach ( $res as $row ) {
+ $comment = $revCommentStore->getComment( $row );
+ $dbw->insert(
+ 'recentchanges',
+ [
+ 'rc_timestamp' => $row->rev_timestamp,
+ 'rc_user' => $row->rev_user,
+ 'rc_user_text' => $row->rev_user_text,
+ 'rc_namespace' => $row->page_namespace,
+ 'rc_title' => $row->page_title,
+ 'rc_minor' => $row->rev_minor_edit,
+ 'rc_bot' => 0,
+ 'rc_new' => $row->page_is_new,
+ 'rc_cur_id' => $row->page_id,
+ 'rc_this_oldid' => $row->rev_id,
+ 'rc_last_oldid' => 0, // is this ok?
+ 'rc_type' => $row->page_is_new ? RC_NEW : RC_EDIT,
+ 'rc_source' => $row->page_is_new ? RecentChange::SRC_NEW : RecentChange::SRC_EDIT,
+ 'rc_deleted' => $row->rev_deleted
+ ] + $rcCommentStore->insert( $dbw, $comment ),
+ __METHOD__
+ );
+ if ( ( ++$inserted % $this->mBatchSize ) == 0 ) {
+ wfGetLBFactory()->waitForReplication();
+ }
+ }