24require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
37 $this->
addOption(
'start',
'Page_id to start from',
false,
true );
38 $this->
addOption(
'end',
'Page_id to end on',
false,
true );
39 $this->
addOption(
'overwrite',
'Refresh page cache' );
53 MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()
54 ->setReason(
'Building cache' );
60 if ( !$this->enabled ) {
61 $this->
fatalError(
"Nothing to do -- \$wgUseFileCache is disabled." );
64 $start = $this->
getOption(
'start',
"0" );
65 if ( !ctype_digit( $start ) ) {
66 $this->
fatalError(
"Invalid value for start parameter." );
68 $start = intval( $start );
71 if ( !ctype_digit( $end ) ) {
72 $this->
fatalError(
"Invalid value for end parameter." );
74 $end = intval( $end );
76 $this->
output(
"Building content page file cache from page {$start}!\n" );
80 $overwrite = $this->
hasOption(
'overwrite' );
81 $start = ( $start > 0 )
83 :
$dbr->selectField(
'page',
'MIN(page_id)',
'', __METHOD__ );
86 :
$dbr->selectField(
'page',
'MAX(page_id)',
'', __METHOD__ );
92 $_SERVER[
'HTTP_ACCEPT_ENCODING'] =
'bgzip';
95 $end += $batchSize - 1;
97 $blockEnd = $start + $batchSize - 1;
101 while ( $blockEnd <= $end ) {
104 [
'page_namespace',
'page_title',
'page_id' ],
105 [
'page_namespace' => MWNamespace::getContentNamespaces(),
106 "page_id BETWEEN " . (
int)$blockStart .
" AND " . (
int)$blockEnd ],
108 [
'ORDER BY' =>
'page_id ASC',
'USE INDEX' =>
'PRIMARY' ]
112 foreach (
$res as $row ) {
115 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
116 if (
null == $title ) {
117 $this->
output(
"Page {$row->page_id} has bad title\n" );
124 $context->setWikiPage( $article->getPage() );
133 if ( $viewCache->isCacheGood() && $historyCache->isCacheGood() ) {
137 $this->
output(
"Page '$title' (id {$row->page_id}) already cached\n" );
142 Wikimedia\suppressWarnings();
146 $_SERVER[
'REQUEST_TIME_FLOAT'] = microtime(
true );
151 $viewHtml = ob_get_clean();
152 $viewCache->saveToFileCache( $viewHtml );
156 $_SERVER[
'REQUEST_TIME_FLOAT'] = microtime(
true );
161 $historyHtml = ob_get_clean();
162 $historyCache->saveToFileCache( $historyHtml );
164 Wikimedia\restoreWarnings();
167 $this->
output(
"Re-cached page '$title' (id {$row->page_id})..." );
169 $this->
output(
"Cached page '$title' (id {$row->page_id})..." );
171 $this->
output(
"[view: " . strlen( $viewHtml ) .
" bytes; " .
172 "history: " . strlen( $historyHtml ) .
" bytes]\n" );
174 $this->
output(
"Page '$title' (id {$row->page_id}) not cacheable\n" );
179 $blockStart += $batchSize;
180 $blockEnd += $batchSize;
182 $this->
output(
"Done!\n" );
$wgDebugToolbar
Display the new debugging toolbar.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Page view caching in the file system.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
hasOption( $name)
Checks to see if a particular param exists.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
setBatchSize( $s=0)
Set the batch size.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Maintenance script that builds file cache for content pages.
execute()
Do the actual work.
__construct()
Default constructor.
finalSetup()
Handle some last-minute setup here.
Group all the pieces relevant to the context of a request into one instance.
static getMain()
Get the RequestContext object associated with the main request.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
require_once RUN_MAINTENANCE_IF_MAIN