* @param int $revid Number to pass in {{REVISIONID}}
* @return ParserOutput A ParserOutput
*/
- public function parse( $text, Title $title, ParserOptions $options,
+ public function parse(
+ $text, Title $title, ParserOptions $options,
$linestart = true, $clearState = true, $revid = null
) {
/**
}
}
+ # Done parsing! Compute runtime adaptive expiry if set
+ $this->mOutput->finalizeAdaptiveCacheExpiry();
+
+ # Warn if too many heavyweight parser functions were used
if ( $this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit() ) {
$this->limitationWarn( 'expensive-parserfunction',
$this->mExpensiveFunctionCount,
* the form:
*
* @code
- * 'UNIQ-xxxxx' => array(
+ * 'UNIQ-xxxxx' => [
* 'element',
* 'tag content',
- * array( 'param' => 'x' ),
- * '<element param="x">tag content</element>' ) )
+ * [ 'param' => 'x' ],
+ * '<element param="x">tag content</element>' ]
* @endcode
*
* @param array $elements List of element names. Comments are always extracted.
$context->setUser( User::newFromName( '127.0.0.1', false ) );
}
$context->setLanguage( $this->mOptions->getUserLangObj() );
- $ret = SpecialPageFactory::capturePath( $title, $context, $this->getLinkRenderer() );
+ $ret = SpecialPageFactory::capturePath(
+ $title, $context, $this->getLinkRenderer() );
if ( $ret ) {
$text = $context->getOutput()->getHTML();
$this->mOutput->addOutputPageMetadata( $context->getOutput() );
$found = true;
$isHTML = true;
if ( $specialPage && $specialPage->maxIncludeCacheTime() !== false ) {
- $this->mOutput->updateCacheExpiry( $specialPage->maxIncludeCacheTime() );
+ $this->mOutput->updateRuntimeAdaptiveExpiry(
+ $specialPage->maxIncludeCacheTime()
+ );
}
}
} elseif ( MWNamespace::isNonincludable( $title->getNamespace() ) ) {
* @since 1.24
* @param Title $title
* @param Parser|bool $parser
- * @return Revision
+ * @return Revision|bool False if missing
*/
- public static function statelessFetchRevision( $title, $parser = false ) {
- return Revision::newFromTitle( $title );
+ public static function statelessFetchRevision( Title $title, $parser = false ) {
+ $pageId = $title->getArticleID();
+ $revId = $title->getLatestRevID();
+
+ $rev = Revision::newKnownCurrent( wfGetDB( DB_REPLICA ), $pageId, $revId );
+ if ( $rev ) {
+ $rev->setTitle( $title );
+ }
+
+ return $rev;
}
/**
*/
public function fetchScaryTemplateMaybeFromCache( $url ) {
global $wgTranscludeCacheExpiry;
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$tsCond = $dbr->timestamp( time() - $wgTranscludeCacheExpiry );
$obj = $dbr->selectRow( 'transcache', [ 'tc_time', 'tc_contents' ],
[ 'tc_url' => $url, "tc_time >= " . $dbr->addQuotes( $tsCond ) ] );
$this->startParse( $title, $options, self::OT_WIKI, $clearState );
$this->setUser( $user );
- $text = str_replace( [ "\r\n", "\r" ], "\n", $text );
+ // We still normalize line endings for backwards-compatibility
+ // with other code that just calls PST, but this should already
+ // be handled in TextContent subclasses
+ $text = TextContent::normalizeLineEndings( $text );
+
if ( $options->getPreSaveTransform() ) {
$text = $this->pstPass2( $text, $user );
}
$text = preg_replace( $p2, '[[\\1]]', $text );
}
- # Trim trailing whitespace
- $text = rtrim( $text );
-
return $text;
}