r36306 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36305‎ | r36306 | r36307 >
Date:19:59, 15 June 2008
Author:catrope
Status:old
Tags:
Comment:
API: action=edit: Make the combination of prepend/appendtext and md5 do something useful. See also mailing list
Modified paths:
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -68,15 +68,17 @@
6969 $this->dieUsageMsg($errors[0]);
7070
7171 $articleObj = new Article($titleObj);
 72+ $toMD5 = $params['text'];
7273 if(!is_null($params['appendtext']) || !is_null($params['prependtext']))
7374 {
7475 $content = $articleObj->getContent();
7576 $params['text'] = $params['prependtext'] . $content . $params['appendtext'];
 77+ $toMD5 = $params['prependtext'] . $params['appendtext'];
7678 }
7779
7880 # See if the MD5 hash checks out
7981 if(isset($params['md5']))
80 - if(md5($params['text']) !== $params['md5'])
 82+ if(md5($toMD5) !== $params['md5'])
8183 $this->dieUsageMsg(array('hashcheckfailed'));
8284
8385 $ep = new EditPage($articleObj);
@@ -272,7 +274,8 @@
273275 'unwatch' => 'Remove the page from your watchlist',
274276 'captchaid' => 'CAPTCHA ID from previous request',
275277 'captchaword' => 'Answer to the CAPTCHA',
276 - 'md5' => 'The MD5 hash of the new article text. If set, the edit won\'t be done unless the hash is correct',
 278+ 'md5' => array( 'The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated.',
 279+ 'If set, the edit won\'t be done unless the hash is correct'),
277280 'prependtext' => array( 'Add this text to the beginning of the page. Overrides text.',
278281 'Don\'t use together with section: that won\'t do what you expect.'),
279282 'appendtext' => 'Add this text to the end of the page. Overrides text',

Status & tagging log