From: Roan Kattouw Date: Fri, 14 Mar 2008 13:07:38 +0000 (+0000) Subject: API: Added rvsection parameter to prop=revisions to allow fetching the content of... X-Git-Tag: 1.31.0-rc.0~49109 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=bfed0111650c2b07b22d687c1b6f3a227b2248ca;p=lhc%2Fweb%2Fwiklou.git API: Added rvsection parameter to prop=revisions to allow fetching the content of a certain section only --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index eb8f733ae1..19efca48c7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -99,6 +99,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added watch and unwatch parameters to action=delete and action=move * Added action=edit * (bug 11401) Added xmldoublequote to xml formatter +* Added rvsection parameter to prop=revisions to allow fetching the content of a certain section only === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index c93aefc88d..6032868e62 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -45,7 +45,7 @@ class ApiQueryRevisions extends ApiQueryBase { $fld_comment = false, $fld_user = false, $fld_content = false; public function execute() { - $limit = $startid = $endid = $start = $end = $dir = $prop = $user = $excludeuser = $token = null; + $limit = $startid = $endid = $start = $end = $dir = $prop = $user = $excludeuser = $expandtemplates = $section = $token = null; extract($this->extractRequestParams(false)); // If any of those parameters are used, work in 'enumeration' mode. @@ -118,6 +118,10 @@ class ApiQueryRevisions extends ApiQueryBase { $this->fld_content = true; $this->expandTemplates = $expandtemplates; + if(isset($section)) + $this->section = $section; + else + $this->section = false; } $userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 ); @@ -270,9 +274,17 @@ class ApiQueryRevisions extends ApiQueryBase { if ($this->fld_content) { - $text = Revision :: getRevisionText($row); + global $wgParser; + $text = Revision :: getRevisionText($row); + # Expand templates after getting section content because + # template-added sections don't count and Parser::preprocess() + # will have less input + if ($this->section !== false) { + $text = $wgParser->getSection( $text, $this->section, false); + if($text === false) + $this->dieUsage("There is no section {$this->section} in r{$row->rev_id}", 'nosuchsection'); + } if ($this->expandTemplates) { - global $wgParser; $text = $wgParser->preprocess( $text, $title, new ParserOptions() ); } ApiResult :: setContent($vals, $text); @@ -328,6 +340,9 @@ class ApiQueryRevisions extends ApiQueryBase { ), 'expandtemplates' => false, + 'section' => array( + ApiBase :: PARAM_TYPE => 'integer' + ), 'token' => array( ApiBase :: PARAM_TYPE => array( 'rollback' @@ -349,6 +364,7 @@ class ApiQueryRevisions extends ApiQueryBase { 'user' => 'only include revisions made by user', 'excludeuser' => 'exclude revisions made by user', 'expandtemplates' => 'expand templates in revision content', + 'section' => 'only retrieve the content of this section', 'token' => 'Which tokens to obtain for each revision', ); }