r53258 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53257‎ | r53258 | r53259 >
Date:20:14, 14 July 2009
Author:btongminh
Status:deferred (Comments)
Tags:
Comment:
(bug 19040) Fix prependtext and appendtext in combination with section parameter in action=edit
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -86,6 +86,16 @@
8787 $content = '';
8888 else
8989 $content = $articleObj->getContent();
 90+
 91+ if (!is_null($params['section']))
 92+ {
 93+ // Process the content for section edits
 94+ global $wgParser;
 95+ $section = intval($params['section']);
 96+ $content = $wgParser->getSection($content, $section, false);
 97+ if ($content === false)
 98+ $this->dieUsage("There is no section {$section}.", 'nosuchsection');
 99+ }
90100 $params['text'] = $params['prependtext'] . $content . $params['appendtext'];
91101 $toMD5 = $params['prependtext'] . $params['appendtext'];
92102 }
@@ -345,8 +355,7 @@
346356 'captchaword' => 'Answer to the CAPTCHA',
347357 'md5' => array( 'The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated.',
348358 'If set, the edit won\'t be done unless the hash is correct'),
349 - 'prependtext' => array( 'Add this text to the beginning of the page. Overrides text.',
350 - 'Don\'t use together with section: that won\'t do what you expect.'),
 359+ 'prependtext' => 'Add this text to the beginning of the page. Overrides text.',
351360 'appendtext' => 'Add this text to the end of the page. Overrides text',
352361 'undo' => 'Undo this revision. Overrides text, prependtext and appendtext',
353362 'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',
Index: trunk/phase3/RELEASE-NOTES
@@ -294,6 +294,8 @@
295295 * (bug 17809) Add number of users in user groups to meta=siteinfo
296296 * (bug 18533) Add readonly reason to readonly exception
297297 * (bug 19528) Added XSLT parameter to API queries in format=xml
 298+* (bug 19040) Fix prependtext and appendtext in combination with section
 299+ parameter in action=edit
298300
299301 === Languages updated in 1.16 ===
300302

Comments

#Comment by Catrope (talk | contribs)   20:54, 14 July 2009

Please use dieUsageMsg() and ApiBase::$messageMap for the nosuchsection error

Status & tagging log