MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/67266
Change subject: action=parse now can parse in preview mode
......................................................................
action=parse now can parse in preview mode
Bug: 49239
Change-Id: Iacfea0219ef21dc91d669f51140ec129c2f41f76
---
M RELEASE-NOTES-1.22
M includes/api/ApiParse.php
2 files changed, 26 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/66/67266/1
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 5339514..07763d9 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -158,6 +158,7 @@
* prop=info now adds the content model and page language of the title.
* New upload log entries will now contain information on the relavent
image (sha1 and timestamp).
+* (bug 49239) action=parse now can parse in preview mode.
=== Languages updated in 1.22===
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index bde1d99..800af25 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -94,8 +94,7 @@
$titleObj = $rev->getTitle();
$wgTitle = $titleObj;
$pageObj = WikiPage::factory( $titleObj );
- $popts = $pageObj->makeParserOptions(
$this->getContext() );
- $popts->enableLimitReport(
!$params['disablepp'] );
+ $popts = $this->makeParserOptions( $pageObj,
$params );
// If for some reason the "oldid" is actually
the current revision, it may be cached
if ( $rev->isCurrent() ) {
@@ -152,8 +151,7 @@
$oldid = $pageObj->getLatest();
}
- $popts = $pageObj->makeParserOptions(
$this->getContext() );
- $popts->enableLimitReport(
!$params['disablepp'] );
+ $popts = $this->makeParserOptions( $pageObj,
$params );
// Potentially cached
$p_result = $this->getParsedContent( $pageObj,
$popts, $pageid,
@@ -170,8 +168,7 @@
$wgTitle = $titleObj;
$pageObj = WikiPage::factory( $titleObj );
- $popts = $pageObj->makeParserOptions(
$this->getContext() );
- $popts->enableLimitReport( !$params['disablepp'] );
+ $popts = $this->makeParserOptions( $pageObj, $params );
if ( is_null( $text ) ) {
$this->dieUsage( 'The text parameter should be
passed with the title parameter. Should you be using the "page" parameter
instead?', 'params' );
@@ -357,6 +354,26 @@
if ( !is_null( $oldLang ) ) {
$this->getContext()->setLanguage( $oldLang ); // Reset
language to $oldLang
}
+ }
+
+ /**
+ * Constructs a ParserOptions object
+ *
+ * @param WikiPage $pageObj
+ * @param array $params
+ *
+ * @return ParserOptions
+ */
+ protected function makeParserOptions( WikiPage $pageObj, array $params
) {
+ wfProfileIn( __METHOD__ );
+
+ $popts = $pageObj->makeParserOptions( $this->getContext() );
+ $popts->enableLimitReport( !$params['disablepp'] );
+ $popts->setIsPreview( $params['preview'] );
+ $popts->setIsSectionPreview( $params['preview'] &&
$this->section !== false );
+
+ wfProfileOut( __METHOD__ );
+ return $popts;
}
/**
@@ -594,6 +611,7 @@
'section' => null,
'disablepp' => false,
'generatexml' => false,
+ 'preview' => false,
'contentformat' => array(
ApiBase::PARAM_TYPE =>
ContentHandler::getAllContentFormats(),
),
@@ -649,6 +667,7 @@
'section' => 'Only retrieve the content of this section
number',
'disablepp' => 'Disable the PP Report from the parser
output',
'generatexml' => 'Generate XML parse tree (requires
prop=wikitext)',
+ 'preview' => 'Parse in preview mode',
'contentformat' => 'Content serialization format used
for the input text',
'contentmodel' => 'Content model of the new content',
);
--
To view, visit https://gerrit.wikimedia.org/r/67266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacfea0219ef21dc91d669f51140ec129c2f41f76
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits