From 042a034033f6cbf7c6ab76221560badb7461f288 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 15 Jun 2008 20:37:28 +0000 Subject: [PATCH] API: Add nocreate parameter to action=edit --- RELEASE-NOTES | 1 + includes/api/ApiBase.php | 1 + includes/api/ApiEditPage.php | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8c46064e6c..de005969ed 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index f64f56e55c..aebc442f11 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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"), diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 0a19ae727d..e9d3e1e0f0 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -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', -- 2.20.1