25require __DIR__ .
'/../Maintenance.php';
50 parent::__construct();
52 $this->
addArg(
'title',
'The name of the page to parse' );
53 $this->
addOption(
'warmup',
'Repeat the parse operation this number of times to warm the cache',
55 $this->
addOption(
'loops',
'Number of times to repeat parse operation post-warmup',
58 'Use the version of the page which was current at the given time',
61 'Use templates which were current at the given time (except that moves and ' .
62 'deletes are not handled properly)',
64 $this->
addOption(
'reset-linkcache',
'Reset the LinkCache after every parse.',
71 Hooks::register(
'BeforeParserFetchTemplateAndtitle', [ $this,
'onFetchTemplate' ] );
74 $this->clearLinkCache = $this->
hasOption(
'reset-linkcache' );
76 $this->linkCache = MediaWikiServices::getInstance()->getLinkCache();
78 $title = Title::newFromText( $this->
getArg() );
80 $this->
error(
"Invalid title" );
88 $this->
error(
"The page did not exist at that time" );
92 $revision = Revision::newFromId( $id );
94 $revision = Revision::newFromTitle( $title );
98 $this->
error(
"Unable to load revision, incorrect title?" );
102 $warmup = $this->
getOption(
'warmup', 1 );
103 for ( $i = 0; $i < $warmup; $i++ ) {
109 $this->
fatalError(
'Invalid number of loops specified' );
111 $startUsage = getrusage();
112 $startTime = microtime(
true );
113 for ( $i = 0; $i < $loops; $i++ ) {
116 $endUsage = getrusage();
117 $endTime = microtime(
true );
119 printf(
"CPU time = %.3f s, wall clock time = %.3f s\n",
121 ( $endUsage[
'ru_utime.tv_sec'] + $endUsage[
'ru_utime.tv_usec'] * 1
e-6
122 - $startUsage[
'ru_utime.tv_sec'] - $startUsage[
'ru_utime.tv_usec'] * 1
e-6 ) / $loops,
124 ( $endTime - $startTime ) / $loops
138 $id =
$dbr->selectField(
139 [
'revision',
'page' ],
142 'page_namespace' => $title->getNamespace(),
143 'page_title' => $title->getDBkey(),
144 'rev_timestamp <= ' .
$dbr->addQuotes( $timestamp )
147 [
'ORDER BY' =>
'rev_timestamp DESC',
'LIMIT' => 1 ],
148 [
'revision' => [
'INNER JOIN',
'rev_page=page_id' ] ]
161 $content->getParserOutput( $revision->
getTitle(), $revision->
getId() );
162 if ( $this->clearLinkCache ) {
163 $this->linkCache->clear();
178 $pdbk = $title->getPrefixedDBkey();
179 if ( !isset( $this->idCache[$pdbk] ) ) {
180 $proposedId = $this->
getRevIdForTime( $title, $this->templateTimestamp );
181 $this->idCache[$pdbk] = $proposedId;
183 if ( $this->idCache[$pdbk] !==
false ) {
184 $id = $this->idCache[$pdbk];
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Maintenance script to benchmark how long it takes to parse a given title at an optionally specified t...
getRevIdForTime(Title $title, $timestamp)
Fetch the ID of the revision of a Title that occurred.
onFetchTemplate(Parser $parser, Title $title, &$skip, &$id)
Hook into the parser's revision ID fetcher.
__construct()
Default constructor.
runParser(Revision $revision)
Parse the text from a given Revision.
execute()
Do the actual work.
array $idCache
Cache that maps a Title DB key to revision ID for the requested timestamp.
string $templateTimestamp
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Cache for article titles (prefixed DB keys) and ids linked from one source.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
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.
getArg( $argId=0, $default=null)
Get an argument.
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
getTitle()
Returns the title of the page associated with this entry.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
Represents a title within MediaWiki.
in this case you re responsible for computing and outputting the entire conflict i e
do that in ParserLimitReportFormat instead $parser
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 error
require_once RUN_MAINTENANCE_IF_MAIN