Go to the documentation of this file.
24 require_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' );
54 ->setReason(
'Building cache' );
62 if ( !$this->enabled ) {
63 $this->
error(
"Nothing to do -- \$wgUseFileCache is disabled.",
true );
66 $start = $this->
getOption(
'start',
"0" );
67 if ( !ctype_digit( $start ) ) {
68 $this->
error(
"Invalid value for start parameter.",
true );
70 $start = intval( $start );
73 if ( !ctype_digit( $end ) ) {
74 $this->
error(
"Invalid value for end parameter.",
true );
76 $end = intval( $end );
78 $this->
output(
"Building content page file cache from page {$start}!\n" );
81 $overwrite = $this->
hasOption(
'overwrite' );
82 $start = ( $start > 0 )
84 :
$dbr->selectField(
'page',
'MIN(page_id)',
false, __METHOD__ );
87 :
$dbr->selectField(
'page',
'MAX(page_id)',
false, __METHOD__ );
89 $this->
error(
"Nothing to do.",
true );
92 $_SERVER[
'HTTP_ACCEPT_ENCODING'] =
'bgzip';
95 $end += $this->mBatchSize - 1;
97 $blockEnd = $start + $this->mBatchSize - 1;
101 while ( $blockEnd <= $end ) {
104 [
'page_namespace',
'page_title',
'page_id' ],
106 "page_id BETWEEN $blockStart AND $blockEnd" ],
108 [
'ORDER BY' =>
'page_id ASC',
'USE INDEX' =>
'PRIMARY' ]
112 foreach (
$res as $row ) {
117 $this->
output(
"Page {$row->page_id} has bad title\n" );
133 if ( $viewCache->isCacheGood() && $historyCache->isCacheGood() ) {
137 $this->
output(
"Page '$title' (id {$row->page_id}) already cached\n" );
142 MediaWiki\suppressWarnings();
149 $viewHtml = ob_get_clean();
150 $viewCache->saveToFileCache( $viewHtml );
157 $historyHtml = ob_get_clean();
158 $historyCache->saveToFileCache( $historyHtml );
159 MediaWiki\restoreWarnings();
162 $this->
output(
"Re-cached page '$title' (id {$row->page_id})..." );
164 $this->
output(
"Cached page '$title' (id {$row->page_id})..." );
166 $this->
output(
"[view: " . strlen( $viewHtml ) .
" bytes; " .
167 "history: " . strlen( $historyHtml ) .
" bytes]\n" );
169 $this->
output(
"Page '$title' (id {$row->page_id}) not cacheable\n" );
177 $this->
output(
"Done!\n" );
int $mBatchSize
Batch size.
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
Page view caching in the file system.
addDescription( $text)
Set the description text.
require_once RUN_MAINTENANCE_IF_MAIN
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Maintenance script that builds file cache for content pages.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
__construct()
Default constructor.
namespace and then decline to actually register it file or subcat img or subcat $title
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
when a variable name is used in a it is silently declared as a new masking the global
Group all the pieces relevant to the context of a request into one instance.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
static getMain()
Static methods.
getOption( $name, $default=null)
Get an option, or return the default.
float $wgRequestTime
Request start time as fractional seconds since epoch.
execute()
Do the actual work.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
$wgDebugToolbar
Display the new debugging toolbar.
hasOption( $name)
Checks to see if a particular param exists.
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
setBatchSize( $s=0)
Set the batch size.
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
finalSetup()
Handle some last-minute setup here.