API: Added optional md5 parameter to action=edit. If set, the edit will only be commi...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 28 May 2008 09:22:40 +0000 (09:22 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 28 May 2008 09:22:40 +0000 (09:22 +0000)
RELEASE-NOTES
includes/api/ApiBase.php
includes/api/ApiEditPage.php

index b45b146..5f0ee3c 100644 (file)
@@ -374,6 +374,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 14140) URL-encoded page titles are now decoded in edit summaries
 * (bug 14243) Only accept post requests in action=edit; patch by HardDisk
 * action=block now returns an ISO8601 timestamp, like all other modules do
+* Added md5 parameter to action=edit
 
 === Languages updated in 1.13 ===
 
index cd4fa1a..e6af87e 100644 (file)
@@ -662,6 +662,7 @@ abstract class ApiBase {
                'wasdeleted' => array('code' => 'pagedeleted', 'info' => "The page has been deleted since you fetched its timestamp"),
                'blankpage' => array('code' => 'emptypage', 'info' => "Creating new, empty pages is not allowed"),
                'editconflict' => array('code' => 'editconflict', 'info' => "Edit conflict detected"),
+               'hashcheckfailed' => array('code' => 'badmd5', 'info' => "The supplied MD5 hash was incorrect"),
        );
 
        /**
index 63626ab..6140265 100644 (file)
@@ -67,6 +67,11 @@ class ApiEditPage extends ApiBase {
                if(!empty($errors))
                        $this->dieUsageMsg($errors[0]);
 
+               # See if the MD5 hash checks out
+               if(isset($params['md5']))
+                       if(md5($params['text']) !== $params['md5'])
+                               $this->dieUsageMsg(array('hashcheckfailed'));
+               
                $articleObj = new Article($titleObj);
                $ep = new EditPage($articleObj);
                
@@ -240,6 +245,7 @@ class ApiEditPage extends ApiBase {
                        'captchaid' => null,
                        'watch' => false,
                        'unwatch' => false,
+                       'md5' => null,
                );
        }
 
@@ -262,6 +268,7 @@ 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',
                );
        }