(bug 23375) Added ogv, oga, spx as extensions for ogg files. Patch by Derk-Jan Hartman.
[lhc/web/wiklou.git] / maintenance / rebuildFileCache.php
index 4eac576..78b5ce8 100644 (file)
@@ -26,17 +26,23 @@ class RebuildFileCache extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Build file cache for content pages";
-               $this->addArgs( array( 'start', 'overwrite' ) );
+               $this->addArg( 'start', 'Page_id to start from', true );
+               $this->addArg( 'overwrite', 'Refresh page cache', false );
                $this->setBatchSize( 100 );
        }
 
        public function execute() {
-               global $wgUseFileCache, $wgContentNamespaces, $wgDisableCounters, $wgTitle, $wgArticle, $wgOut;
+               global $wgUseFileCache, $wgDisableCounters, $wgContentNamespaces, $wgRequestTime;
+               global $wgTitle, $wgArticle, $wgOut, $wgUser;
                if( !$wgUseFileCache ) {
                        $this->error( "Nothing to do -- \$wgUseFileCache is disabled.", true );
                }
                $wgDisableCounters = false;
-               $start = intval( $this->getArg( 0, 0 ) );
+               $start = $this->getArg( 0, "0" );
+               if( !ctype_digit($start) ) {
+                       $this->error( "Invalid value for start parameter.", true );
+               }
+               $start = intval($start);
                $overwrite = $this->hasArg(1) && $this->getArg(1) === 'overwrite';
                $this->output( "Building content page file cache from page {$start}!\n" );
 
@@ -64,13 +70,16 @@ class RebuildFileCache extends Maintenance {
                                        "page_id BETWEEN $blockStart AND $blockEnd" ),
                                array('ORDER BY' => 'page_id ASC','USE INDEX' => 'PRIMARY')
                        );
-                       while( $row = $dbr->fetchObject( $res ) ) {
+                       foreach( $res as $row ) {
                                $rebuilt = false;
+                               $wgRequestTime = wfTime(); # bug 22852
                                $wgTitle = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
                                if( null == $wgTitle ) {
-                                       $this->output( "Page {$row->page_id} bad title\n" );
+                                       $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
                                $wgArticle = new Article( $wgTitle );
                                // If the article is cacheable, then load it
                                if( $wgArticle->isFileCacheable() ) {
@@ -83,7 +92,7 @@ class RebuildFileCache extends Maintenance {
                                                        continue; // done already!
                                                }
                                        }
-                                       ob_start( array(&$cache, 'saveToFileCache' ) ); // save on ob_end_clean()
+                                       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