$wgArticle is deprecated! Possible removal in 1.20 or 1.21!
[lhc/web/wiklou.git] / maintenance / rebuildFileCache.php
index 53d4c23..aa1bbbb 100644 (file)
@@ -31,9 +31,12 @@ class RebuildFileCache extends Maintenance {
                $this->setBatchSize( 100 );
        }
 
+       /**
+        * @todo MAKE $wgArticle GO AWAY! This is the absolute LAST use in core
+        */
        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 +57,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 +75,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 +101,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 +112,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 +125,4 @@ class RebuildFileCache extends Maintenance {
 }
 
 $maintClass = "RebuildFileCache";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );