-// Go through each page and save the output
-while( $blockEnd <= $end ) {
- // Get the pages
- $res = $dbr->select( 'page', array('page_namespace','page_title','page_id'),
- array('page_namespace' => $wgContentNamespaces,
- "page_id BETWEEN $blockStart AND $blockEnd" ),
- array('ORDER BY' => 'page_id ASC','USE INDEX' => 'PRIMARY')
- );
- while( $row = $dbr->fetchObject( $res ) ) {
- $rebuilt = false;
- $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if( null == $wgTitle ) {
- echo "Page {$row->page_id} bad title\n";
- continue; // broken title?
- }
- $wgArticle = new Article( $wgTitle );
- // If the article is cacheable, then load it
- if( $wgArticle->isFileCacheable() ) {
- $cache = new HTMLFileCache( $wgTitle );
- if( $cache->isFileCacheGood() ) {
- if( $overwrite ) {
- $rebuilt = true;
+ # Do remaining chunk
+ $end += $this->mBatchSize - 1;
+ $blockStart = $start;
+ $blockEnd = $start + $this->mBatchSize - 1;
+
+ $dbw = wfGetDB( DB_MASTER );
+ // Go through each page and save the output
+ while ( $blockEnd <= $end ) {
+ // Get the pages
+ $res = $dbr->select( 'page', array( 'page_namespace', 'page_title', 'page_id' ),
+ array( 'page_namespace' => $wgContentNamespaces,
+ "page_id BETWEEN $blockStart AND $blockEnd" ),
+ array( 'ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY' )
+ );
+ foreach ( $res as $row ) {
+ $rebuilt = false;
+ $wgRequestTime = wfTime(); # bug 22852
+ $context = new RequestContext;
+ $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
+ $context->setTitle( $wgTitle );
+ if ( null == $wgTitle ) {
+ $this->output( "Page {$row->page_id} has bad title\n" );
+ continue; // broken title?
+ }
+ $wgOut = $context->output; // set display title
+ $wgArticle = new Article( $wgTitle );
+ // If the article is cacheable, then load it
+ if ( $wgArticle->isFileCacheable() ) {
+ $cache = new HTMLFileCache( $wgTitle );
+ if ( $cache->isFileCacheGood() ) {
+ if ( $overwrite ) {
+ $rebuilt = true;
+ } else {
+ $this->output( "Page {$row->page_id} already cached\n" );
+ continue; // done already!
+ }
+ }
+ ob_start( array( &$cache, 'saveToFileCache' ) ); // save on ob_end_clean()
+ $wgUseFileCache = false; // hack, we don't want $wgArticle fiddling with filecache
+ $wgArticle->view();
+ @$wgOut->output(); // header notices
+ $wgUseFileCache = true;
+ ob_end_clean(); // clear buffer
+ if ( $rebuilt )
+ $this->output( "Re-cached page {$row->page_id}\n" );
+ else
+ $this->output( "Cached page {$row->page_id}\n" );