22require_once __DIR__ .
'/Maintenance.php';
29 parent::__construct();
30 $this->
addDescription(
'Parse random pages and compare output to cache.' );
31 $this->
addOption(
'namespace',
'Page namespace number',
true,
true );
32 $this->
addOption(
'maxpages',
'Number of pages to try',
true,
true );
44 while ( $pages-- > 0 ) {
45 $row =
$dbr->selectRow(
'page',
'*',
47 'page_namespace' => $this->
getOption(
'namespace' ),
48 'page_is_redirect' => 0,
53 'ORDER BY' =>
'page_random',
62 $title = Title::newFromRow( $row );
64 $revision =
$page->getRevision();
67 $parserOptions =
$page->makeParserOptions(
'canonical' );
71 if ( $parserOutputOld ) {
72 $t1 = microtime(
true );
73 $parserOutputNew =
$content->getParserOutput(
74 $title, $revision->getId(), $parserOptions,
false );
75 $sec = microtime(
true ) - $t1;
78 $this->
output(
"Parsed '{$title->getPrefixedText()}' in $sec seconds.\n" );
80 $this->
output(
"Found cache entry found for '{$title->getPrefixedText()}'..." );
81 $oldHtml = trim( preg_replace(
'#<!-- .+-->#Us',
'', $parserOutputOld->getText() ) );
82 $newHtml = trim( preg_replace(
'#<!-- .+-->#Us',
'', $parserOutputNew->getText() ) );
83 $diff =
wfDiff( $oldHtml, $newHtml );
84 if ( strlen( $diff ) ) {
85 $this->
output(
"differences found:\n\n$diff\n\n" );
88 $this->
output(
"No differences found.\n" );
92 $this->
output(
"No parser cache entry found for '{$title->getPrefixedText()}'.\n" );
96 $ave = $totalsec ? $totalsec / $scanned : 0;
97 $this->
output(
"Checked $scanned pages; $withcache had prior cache entries.\n" );
98 $this->
output(
"Pages with differences found: $withdiff\n" );
99 $this->
output(
"Average parse time: $ave sec\n" );
wfRandom()
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any real...
wfDiff( $before, $after, $params='-u')
Returns unified plain-text diff of two texts.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
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.
static singleton()
Get an instance of this object.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
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
require_once RUN_MAINTENANCE_IF_MAIN