From: Max Semenik Date: Wed, 12 Jun 2013 22:46:04 +0000 (+0400) Subject: Add section preview mode to API action=parse X-Git-Tag: 1.31.0-rc.0~19432^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=5d3374f48ecce8f71fb21551273e2a72817f6a37;p=lhc%2Fweb%2Fwiklou.git Add section preview mode to API action=parse 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 --- diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 38b2cbdad5..841de3530f 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -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=== diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 800af25afe..58b46a2c3c 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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', );