From: Roan Kattouw Date: Sun, 15 Jun 2008 19:59:55 +0000 (+0000) Subject: API: action=edit: Make the combination of prepend/appendtext and md5 do something... X-Git-Tag: 1.31.0-rc.0~47010 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=fd919706554716fb800c25067ceded30a54adc1b;p=lhc%2Fweb%2Fwiklou.git API: action=edit: Make the combination of prepend/appendtext and md5 do something useful. See also mailing list --- diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index ac225d616a..0a19ae727d 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -68,15 +68,17 @@ class ApiEditPage extends ApiBase { $this->dieUsageMsg($errors[0]); $articleObj = new Article($titleObj); + $toMD5 = $params['text']; if(!is_null($params['appendtext']) || !is_null($params['prependtext'])) { $content = $articleObj->getContent(); $params['text'] = $params['prependtext'] . $content . $params['appendtext']; + $toMD5 = $params['prependtext'] . $params['appendtext']; } # See if the MD5 hash checks out if(isset($params['md5'])) - if(md5($params['text']) !== $params['md5']) + if(md5($toMD5) !== $params['md5']) $this->dieUsageMsg(array('hashcheckfailed')); $ep = new EditPage($articleObj); @@ -272,7 +274,8 @@ class ApiEditPage extends ApiBase { 'unwatch' => 'Remove the page from your watchlist', 'captchaid' => 'CAPTCHA ID from previous request', 'captchaword' => 'Answer to the CAPTCHA', - 'md5' => 'The MD5 hash of the new article text. If set, the edit won\'t be done unless the hash is correct', + '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.'), 'appendtext' => 'Add this text to the end of the page. Overrides text',