dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Improve comments on fields and fix opening_text - needs no highlights."
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiParse.php
diff --git
a/includes/api/ApiParse.php
b/includes/api/ApiParse.php
index
fe418e3
..
3e66cad
100644
(file)
--- a/
includes/api/ApiParse.php
+++ b/
includes/api/ApiParse.php
@@
-109,13
+109,13
@@
class ApiParse extends ApiBase {
$titleObj = $rev->getTitle();
$wgTitle = $titleObj;
$pageObj = WikiPage::factory( $titleObj );
$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 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'] ) );
// May get from/save to parser cache
$p_result = $this->getParsedContent( $pageObj, $popts,
$pageid, isset( $prop['wikitext'] ) );
@@
-167,12
+167,12
@@
class ApiParse extends ApiBase {
$oldid = $pageObj->getLatest();
}
$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
// 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'] ||
$params['disablepp'] ||
$params['disablelimitreport'] ||
$params['preview'] ||
@@
-202,7
+202,7
@@
class ApiParse extends ApiBase {
$pageObj = $article->getPage();
}
$pageObj = $article->getPage();
}
-
$popts
= $this->makeParserOptions( $pageObj, $params );
+
list( $popts, $reset )
= $this->makeParserOptions( $pageObj, $params );
$textProvided = !is_null( $text );
if ( !$textProvided ) {
$textProvided = !is_null( $text );
if ( !$textProvided ) {
@@
-346,22
+346,27
@@
class ApiParse extends ApiBase {
}
if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
}
if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
- $context =
$this->getContext(
);
+ $context =
new DerivativeContext( $this->getContext()
);
$context->setTitle( $titleObj );
$context->setTitle( $titleObj );
- $context->getOutput()->addParserOutputMetadata( $p_result );
+ $context->setWikiPage( $pageObj );
+
+ // We need an OutputPage tied to $context, not to the
+ // RequestContext at the root of the stack.
+ $output = new OutputPage( $context );
+ $output->addParserOutputMetadata( $p_result );
if ( isset( $prop['headitems'] ) ) {
$headItems = $this->formatHeadItems( $p_result->getHeadItems() );
if ( isset( $prop['headitems'] ) ) {
$headItems = $this->formatHeadItems( $p_result->getHeadItems() );
- $css = $this->formatCss( $
context->getOutput()
->buildCssLinksArray() );
+ $css = $this->formatCss( $
output
->buildCssLinksArray() );
- $scripts = [ $
context->getOutput()
->getHeadScripts() ];
+ $scripts = [ $
output
->getHeadScripts() ];
$result_array['headitems'] = array_merge( $headItems, $css, $scripts );
}
if ( isset( $prop['headhtml'] ) ) {
$result_array['headitems'] = array_merge( $headItems, $css, $scripts );
}
if ( isset( $prop['headhtml'] ) ) {
- $result_array['headhtml'] = $
context->getOutput()
->headElement( $context->getSkin() );
+ $result_array['headhtml'] = $
output
->headElement( $context->getSkin() );
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
}
}
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
}
}
@@
-470,10
+475,9
@@
class ApiParse extends ApiBase {
* @param WikiPage $pageObj
* @param array $params
*
* @param WikiPage $pageObj
* @param array $params
*
- * @return
ParserOptions
+ * @return
array [ ParserOptions, ScopedCallback, bool $suppressCache ]
*/
protected function makeParserOptions( WikiPage $pageObj, array $params ) {
*/
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 = $pageObj->makeParserOptions( $this->getContext() );
$popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
$popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
@@
-483,7
+487,12
@@
class ApiParse extends ApiBase {
$popts->setTidy( false );
}
$popts->setTidy( false );
}
- return $popts;
+ $reset = null;
+ $suppressCache = false;
+ Hooks::run( 'ApiMakeParserOptions',
+ [ $popts, $pageObj->getTitle(), $params, $this, &$reset, &$suppressCache ] );
+
+ return [ $popts, $reset, $suppressCache ];
}
/**
}
/**