From d8aa4337f9b21137572f7a89cb3a9d1d3eb2c5ce Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Tue, 14 Jul 2009 20:14:47 +0000 Subject: [PATCH] (bug 19040) Fix prependtext and appendtext in combination with section parameter in action=edit --- RELEASE-NOTES | 2 ++ includes/api/ApiEditPage.php | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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', -- 2.20.1