Add section preview mode to API action=parse
authorMax Semenik <maxsem.wiki@gmail.com>
Wed, 12 Jun 2013 22:46:04 +0000 (02:46 +0400)
committerMax Semenik <maxsem.wiki@gmail.com>
Wed, 12 Jun 2013 22:46:04 +0000 (02:46 +0400)
In https://gerrit.wikimedia.org/r/#/c/67266/, it was enabled automatically
when a section was specified in preview mode. However, this only works for
previews of a saved page's content, failing for user input previews which
might contain several sections of various degrees of nestedness.

Change-Id: I987144e5e315ed9e0a67f599083461a78879c0df

RELEASE-NOTES-1.22
includes/api/ApiParse.php

index 38b2cbd..841de35 100644 (file)
@@ -172,7 +172,7 @@ production.
 * 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.
+* (bug 49239) action=parse now can parse in preview and section preview modes.
 * (bug 49259) action=patrol now accepts revision ids.
 
 === Languages updated in 1.22===
index 800af25..58b46a2 100644 (file)
@@ -369,8 +369,8 @@ class ApiParse extends ApiBase {
 
                $popts = $pageObj->makeParserOptions( $this->getContext() );
                $popts->enableLimitReport( !$params['disablepp'] );
-               $popts->setIsPreview( $params['preview'] );
-               $popts->setIsSectionPreview( $params['preview'] && $this->section !== false );
+               $popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
+               $popts->setIsSectionPreview( $params['sectionpreview'] );
 
                wfProfileOut( __METHOD__ );
                return $popts;
@@ -612,6 +612,7 @@ class ApiParse extends ApiBase {
                        'disablepp' => false,
                        'generatexml' => false,
                        'preview' => false,
+                       'sectionpreview' => false,
                        'contentformat' => array(
                                ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
                        ),
@@ -668,6 +669,7 @@ class ApiParse extends ApiBase {
                        'disablepp' => 'Disable the PP Report from the parser output',
                        'generatexml' => 'Generate XML parse tree (requires prop=wikitext)',
                        'preview' => 'Parse in preview mode',
+                       'sectionpreview' => 'Parse in section preview mode (enables preview mode too)',
                        'contentformat' => 'Content serialization format used for the input text',
                        'contentmodel' => 'Content model of the new content',
                );