API: Add nocreate parameter to action=edit
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 15 Jun 2008 20:37:28 +0000 (20:37 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 15 Jun 2008 20:37:28 +0000 (20:37 +0000)
RELEASE-NOTES
includes/api/ApiBase.php
includes/api/ApiEditPage.php

index 8c46064..de00596 100644 (file)
@@ -447,6 +447,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 14459) Added prependtext and appendtext parameters to action=edit
 * (bug 14526) Unescaped SQL in list=backlinks
 * Added 'hidden' flag to list=allcategories and prop=categoryinfo output
+* Added nocreate parameter to action=edit
 
 === Languages updated in 1.13 ===
 
index f64f56e..aebc442 100644 (file)
@@ -650,6 +650,7 @@ abstract class ApiBase {
                '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"),
                'createonly-exists' => array('code' => 'articleexists', 'info' => "The article you tried to create has been created already"),
+               'nocreate-missing' => array('code' => 'missingtitle', 'info' => "The article you tried to edit doesn't exist"),
 
                // ApiEditPage messages
                'noimageredirect-anon' => array('code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects"),
index 0a19ae7..e9d3e1e 100644 (file)
@@ -59,6 +59,8 @@ class ApiEditPage extends ApiBase {
 
                if($params['createonly'] && $titleObj->exists())
                        $this->dieUsageMsg(array('createonly-exists'));
+               if($params['nocreate'] && !$titleObj->exists())
+                       $this->dieUsageMsg(array('nocreate-missing'));
 
                // Now let's check whether we're even allowed to do this
                $errors = $titleObj->getUserPermissionsErrors('edit', $wgUser);
@@ -245,6 +247,7 @@ class ApiEditPage extends ApiBase {
                        'basetimestamp' => null,
                        'recreate' => false,
                        'createonly' => false,
+                       'nocreate' => false,
                        'captchaword' => null,
                        'captchaid' => null,
                        'watch' => false,
@@ -269,7 +272,8 @@ 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',
-                       'createonly' => 'Don\'t create the page if it exists already',
+                       'createonly' => 'Don\'t edit the page if it exists already',
+                       'nocreate' => 'Throw an error if the page doesn\'t exist',
                        'watch' => 'Add the page to your watchlist',
                        'unwatch' => 'Remove the page from your watchlist',
                        'captchaid' => 'CAPTCHA ID from previous request',