From: Bryan Tong Minh Date: Tue, 14 Jul 2009 20:14:47 +0000 (+0000) Subject: (bug 19040) Fix prependtext and appendtext in combination with section parameter... X-Git-Tag: 1.31.0-rc.0~40957 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=d8aa4337f9b21137572f7a89cb3a9d1d3eb2c5ce;p=lhc%2Fweb%2Fwiklou.git (bug 19040) Fix prependtext and appendtext in combination with section parameter in action=edit --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 769c8b75ca..e9fc5c3aaa 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -294,6 +294,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 17809) Add number of users in user groups to meta=siteinfo * (bug 18533) Add readonly reason to readonly exception * (bug 19528) Added XSLT parameter to API queries in format=xml +* (bug 19040) Fix prependtext and appendtext in combination with section + parameter in action=edit === Languages updated in 1.16 === diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index f3cf492354..d46b1f0f44 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -86,6 +86,16 @@ class ApiEditPage extends ApiBase { $content = ''; else $content = $articleObj->getContent(); + + if (!is_null($params['section'])) + { + // Process the content for section edits + global $wgParser; + $section = intval($params['section']); + $content = $wgParser->getSection($content, $section, false); + if ($content === false) + $this->dieUsage("There is no section {$section}.", 'nosuchsection'); + } $params['text'] = $params['prependtext'] . $content . $params['appendtext']; $toMD5 = $params['prependtext'] . $params['appendtext']; } @@ -345,8 +355,7 @@ class ApiEditPage extends ApiBase { 'captchaword' => 'Answer to the CAPTCHA', 'md5' => array( 'The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated.', 'If set, the edit won\'t be done unless the hash is correct'), - 'prependtext' => array( 'Add this text to the beginning of the page. Overrides text.', - 'Don\'t use together with section: that won\'t do what you expect.'), + 'prependtext' => 'Add this text to the beginning of the page. Overrides text.', 'appendtext' => 'Add this text to the end of the page. Overrides text', 'undo' => 'Undo this revision. Overrides text, prependtext and appendtext', 'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',