API: Adding dontcreate parameter to action=edit
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 25 Mar 2008 20:41:55 +0000 (20:41 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 25 Mar 2008 20:41:55 +0000 (20:41 +0000)
RELEASE-NOTES
includes/api/ApiBase.php
includes/api/ApiEditPage.php

index 7622dfe..cfdcb48 100644 (file)
@@ -162,6 +162,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 13482) Disabled search types handled properly
 * Added inprop=talkid,subjectid to prop=info
 * Added help text message that specifies whether a module is POST-only
+* Added dontcreate parameter to action=edit
 
 === Languages updated in 1.13 ===
 
index 4295046..0499ab5 100644 (file)
@@ -625,6 +625,7 @@ abstract class ApiBase {
                'cantunblock' => array('code' => 'permissiondenied', 'info' => "You don't have permission to unblock users"),
                'cannotundelete' => array('code' => 'cantundelete', 'info' => "Couldn't undelete: the requested revisions may not exist, or may have been undeleted already"),
                'permdenied-undelete' => array('code' => 'permissiondenied', 'info' => "You don't have permission to restore deleted revisions"),
+               'dontcreate-exists' => array('code' => 'articleexists', 'info' => "The article you tried to create has been created already"),
        );
        
        /**
index 3e9512c..091ac59 100644 (file)
@@ -56,6 +56,9 @@ class ApiEditPage extends ApiBase {
                $titleObj = Title::newFromText($params['title']);
                if(!$titleObj)
                        $this->dieUsageMsg(array('invalidtitle', $params['title']));
+
+               if($params['dontcreate'] && $titleObj->exists())
+                       $this->dieUsageMsg(array('dontcreate-exists'));
                
                // Now let's check whether we're even allowed to do this
                $errors = $titleObj->getUserPermissionsErrors('edit', $wgUser);
@@ -241,6 +244,7 @@ class ApiEditPage extends ApiBase {
                                                'Used to detect edit conflicts; leave unset to ignore conflicts.'
                        ),
                        'recreate' => 'Override any errors about the article having been deleted in the meantime',
+                       'dontcreate' => 'Don\'t create the page if it exists already',
                        'watch' => 'Add the page to your watchlist',
                        'unwatch' => 'Remove the page from your watchlist',
                        'captchaid' => 'CAPTCHA ID from previous request',