From 5d3374f48ecce8f71fb21551273e2a72817f6a37 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Thu, 13 Jun 2013 02:46:04 +0400 Subject: [PATCH] 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 --- RELEASE-NOTES-1.22 | 2 +- includes/api/ApiParse.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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', ); -- 2.20.1