Revert r81542 for now, too lazy to fix this properly
[lhc/web/wiklou.git] / maintenance / rebuildFileCache.php
index 53d4c23..4bf6462 100644 (file)
@@ -33,7 +33,7 @@ class RebuildFileCache extends Maintenance {
 
        public function execute() {
                global $wgUseFileCache, $wgDisableCounters, $wgContentNamespaces, $wgRequestTime;
-               global $wgTitle, $wgArticle, $wgOut, $wgUser;
+               global $wgTitle, $wgArticle, $wgOut;
                if ( !$wgUseFileCache ) {
                        $this->error( "Nothing to do -- \$wgUseFileCache is disabled.", true );
                }
@@ -54,13 +54,12 @@ class RebuildFileCache extends Maintenance {
                }
 
                $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; // hack, no real client
-               OutputPage::setEncodings(); # Not really used yet
 
                # 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 ) {
@@ -73,13 +72,14 @@ class RebuildFileCache extends Maintenance {
                        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->setTitle( $wgTitle ); // set display title
-                               $wgUser->getSkin( $wgTitle ); // set skin title
+                               $wgOut = $context->output; // set display title
                                $wgArticle = new Article( $wgTitle );
                                // If the article is cacheable, then load it
                                if ( $wgArticle->isFileCacheable() ) {
@@ -98,7 +98,6 @@ class RebuildFileCache extends Maintenance {
                                        @$wgOut->output(); // header notices
                                        $wgUseFileCache = true;
                                        ob_end_clean(); // clear buffer
-                                       $wgOut = new OutputPage(); // empty out any output page garbage
                                        if ( $rebuilt )
                                                $this->output( "Re-cached page {$row->page_id}\n" );
                                        else
@@ -110,10 +109,10 @@ class RebuildFileCache extends Maintenance {
                        }
                        $blockStart += $this->mBatchSize;
                        $blockEnd += $this->mBatchSize;
-                       wfWaitForSlaves( 5 );
+                       wfWaitForSlaves();
                }
                $this->output( "Done!\n" );
-       
+
                // Remove these to be safe
                if ( isset( $wgTitle ) )
                        unset( $wgTitle );
@@ -123,4 +122,4 @@ class RebuildFileCache extends Maintenance {
 }
 
 $maintClass = "RebuildFileCache";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );