X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrebuildFileCache.php;h=d484392d7e4beb5e26d2761bc987bb3ef604b8b3;hb=e65f8ac5110804067366f9f239c13f4f29b66c3d;hp=ecdec29a9585cb18da281c55b8a2de5a69c6f109;hpb=0c2687f44eb0e8c7f480b7303f89056682ba0bfb;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index ecdec29a95..d484392d7e 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -21,6 +21,8 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/Maintenance.php'; /** @@ -41,24 +43,22 @@ class RebuildFileCache extends Maintenance { } public function finalSetup() { - global $wgDebugToolbar, $wgUseFileCache; + global $wgUseFileCache; $this->enabled = $wgUseFileCache; // Script will handle capturing output and saving it itself $wgUseFileCache = false; - // Debug toolbar makes content uncacheable so we disable it. - // Has to be done before Setup.php initialize MWDebug - $wgDebugToolbar = false; // Avoid DB writes (like enotif/counters) MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode() ->setReason( 'Building cache' ); + // Ensure no debug-specific logic ends up in the cache (must be after Setup.php) + MWDebug::deinit(); + parent::finalSetup(); } public function execute() { - global $wgRequestTime; - if ( !$this->enabled ) { $this->fatalError( "Nothing to do -- \$wgUseFileCache is disabled." ); } @@ -90,7 +90,8 @@ class RebuildFileCache extends Maintenance { $this->fatalError( "Nothing to do." ); } - $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; // hack, no real client + // Mock request (hack, no real client) + $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; # Do remaining chunk $end += $batchSize - 1; @@ -103,7 +104,8 @@ class RebuildFileCache extends Maintenance { // Get the pages $res = $dbr->select( 'page', [ 'page_namespace', 'page_title', 'page_id' ], - [ 'page_namespace' => MWNamespace::getContentNamespaces(), + [ 'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()-> + getContentNamespaces(), "page_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd ], __METHOD__, [ 'ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY' ] @@ -114,7 +116,7 @@ class RebuildFileCache extends Maintenance { $rebuilt = false; $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); - if ( null == $title ) { + if ( $title === null ) { $this->output( "Page {$row->page_id} has bad title\n" ); continue; // broken title? } @@ -141,22 +143,27 @@ class RebuildFileCache extends Maintenance { } Wikimedia\suppressWarnings(); // header notices - // Cache ?action=view - $wgRequestTime = microtime( true ); # T24852 + + // 1. Cache ?action=view + // Be sure to reset the mocked request time (T24852) + $_SERVER['REQUEST_TIME_FLOAT'] = microtime( true ); ob_start(); $article->view(); $context->getOutput()->output(); $context->getOutput()->clearHTML(); $viewHtml = ob_get_clean(); $viewCache->saveToFileCache( $viewHtml ); - // Cache ?action=history - $wgRequestTime = microtime( true ); # T24852 + + // 2. Cache ?action=history + // Be sure to reset the mocked request time (T24852) + $_SERVER['REQUEST_TIME_FLOAT'] = microtime( true ); ob_start(); Action::factory( 'history', $article, $context )->show(); $context->getOutput()->output(); $context->getOutput()->clearHTML(); $historyHtml = ob_get_clean(); $historyCache->saveToFileCache( $historyHtml ); + Wikimedia\restoreWarnings(); if ( $rebuilt ) {