From 50e029c17e42baf56e4e1cce41cabe62bed2a453 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 25 Sep 2007 18:36:25 +0000 Subject: [PATCH] API: (bug 11405) Expand templates implementation in the API Modified patch by Bryan Tongh Minh --- RELEASE-NOTES | 1 + includes/api/ApiQueryRevisions.php | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a2244e89d8..7437a0fcc2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -79,6 +79,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * (bug 11308) Allow the API to output the image metadata * (bug 11296) Temporary fix for escaping of ampersands inside links in pretty-printed help document. +* (bug 11405) Expand templates implementation in the API === Languages updated in 1.12 === diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index dc63c20e99..b8af8cae32 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -105,7 +105,10 @@ class ApiQueryRevisions extends ApiQueryBase { $this->addFields('old_id'); $this->addFields('old_text'); $this->addFields('old_flags'); + $this->fld_content = true; + + $this->expandTemplates = $expandtemplates; } $userMax = ($this->fld_content ? 50 : 500); @@ -245,7 +248,12 @@ class ApiQueryRevisions extends ApiQueryBase { } if ($this->fld_content) { - ApiResult :: setContent($vals, Revision :: getRevisionText($row)); + $text = Revision :: getRevisionText($row); + if ($this->expandTemplates) { + global $wgParser; + $text = $wgParser->preprocess( $text, Title::newFromID($row->rev_page), new ParserOptions() ); + } + ApiResult :: setContent($vals, $text); } return $vals; @@ -296,7 +304,9 @@ class ApiQueryRevisions extends ApiQueryBase { ), 'excludeuser' => array( ApiBase :: PARAM_TYPE => 'user' - ) + ), + + 'expandtemplates' => false, ); } @@ -311,6 +321,7 @@ class ApiQueryRevisions extends ApiQueryBase { 'dir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)', 'user' => 'only include revisions made by user', 'excludeuser' => 'exclude revisions made by user', + 'expandtemplates' => 'expand templates in revision content' ); } -- 2.20.1