$this->section = $params['section'];
if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section ) ) {
$this->dieUsage(
- "The section parameter must be a valid section id or 'new'", "invalidsection"
+ 'The section parameter must be a valid section id or "new"', 'invalidsection'
);
}
} else {
$titleObj = $rev->getTitle();
$wgTitle = $titleObj;
$pageObj = WikiPage::factory( $titleObj );
- $popts = $this->makeParserOptions( $pageObj, $params );
+ list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
// If for some reason the "oldid" is actually the current revision, it may be cached
// Deliberately comparing $pageObj->getLatest() with $rev->getId(), rather than
// checking $rev->isCurrent(), because $pageObj is what actually ends up being used,
// and if its ->getLatest() is outdated, $rev->isCurrent() won't tell us that.
- if ( $rev->getId() == $pageObj->getLatest() ) {
+ if ( !$suppressCache && $rev->getId() == $pageObj->getLatest() ) {
// May get from/save to parser cache
$p_result = $this->getParsedContent( $pageObj, $popts,
$pageid, isset( $prop['wikitext'] ) );
$oldid = $pageObj->getLatest();
}
- $popts = $this->makeParserOptions( $pageObj, $params );
+ list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
// Don't pollute the parser cache when setting options that aren't
// in ParserOptions::optionsHash()
/// @todo: This should be handled closer to the actual cache instead of here, see T110269
- $suppressCache =
+ $suppressCache = $suppressCache ||
$params['disablepp'] ||
$params['disablelimitreport'] ||
$params['preview'] ||
$pageObj = $article->getPage();
}
- $popts = $this->makeParserOptions( $pageObj, $params );
+ list( $popts, $reset ) = $this->makeParserOptions( $pageObj, $params );
$textProvided = !is_null( $text );
if ( !$textProvided ) {
$result_array = [];
$result_array['title'] = $titleObj->getPrefixedText();
- $result_array['pageid'] = $pageid ? $pageid : $pageObj->getId();
+ $result_array['pageid'] = $pageid ?: $pageObj->getId();
if ( !is_null( $oldid ) ) {
$result_array['revid'] = intval( $oldid );
}
if ( isset( $prop['displaytitle'] ) ) {
- $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
- $p_result->getDisplayTitle() :
+ $result_array['displaytitle'] = $p_result->getDisplayTitle() ?:
$titleObj->getPrefixedText();
}
if ( isset( $prop['modules'] ) &&
!isset( $prop['jsconfigvars'] ) && !isset( $prop['encodedjsconfigvars'] ) ) {
- $this->setWarning( "Property 'modules' was set but not 'jsconfigvars' " .
- "or 'encodedjsconfigvars'. Configuration variables are necessary " .
- "for proper module usage." );
+ $this->setWarning( 'Property "modules" was set but not "jsconfigvars" ' .
+ 'or "encodedjsconfigvars". Configuration variables are necessary ' .
+ 'for proper module usage.' );
}
if ( isset( $prop['indicators'] ) ) {
if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
- $this->dieUsage( "parsetree is only supported for wikitext content", "notwikitext" );
+ $this->dieUsage( 'parsetree is only supported for wikitext content', 'notwikitext' );
}
$wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
* @param WikiPage $pageObj
* @param array $params
*
- * @return ParserOptions
+ * @return array [ ParserOptions, ScopedCallback, bool $suppressCache ]
*/
protected function makeParserOptions( WikiPage $pageObj, array $params ) {
-
$popts = $pageObj->makeParserOptions( $this->getContext() );
$popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
$popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
$popts->setTidy( false );
}
- return $popts;
+ $reset = null;
+ $suppressCache = false;
+ Hooks::run( 'ApiMakeParserOptions',
+ [ $popts, $pageObj->getTitle(), $params, $this, &$reset, &$suppressCache ] );
+
+ return [ $popts, $reset, $suppressCache ];
}
/**
// Not cached (save or load)
$section = $content->getSection( $this->section );
if ( $section === false ) {
- $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
+ $this->dieUsage( "There is no section {$this->section} in $what", 'nosuchsection' );
}
if ( $section === null ) {
- $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
+ $this->dieUsage( "Sections are not supported by $what", 'nosuchsection' );
$section = false;
}