From 6afa8f9d63d4f633fa79aa20d364efe1dd99c9b5 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 25 Mar 2008 20:41:55 +0000 Subject: [PATCH] API: Adding dontcreate parameter to action=edit --- RELEASE-NOTES | 1 + includes/api/ApiBase.php | 1 + includes/api/ApiEditPage.php | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7622dfe47a..cfdcb48fe3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 42950463b8..0499ab5b49 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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"), ); /** diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 3e9512c9f7..091ac59688 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -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', -- 2.20.1