From: Reedy Date: Sat, 7 Apr 2012 15:48:39 +0000 (+0000) Subject: Merge "(bug 32492) API now allows editing using pageid" X-Git-Tag: 1.31.0-rc.0~23990 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=90f59e104638156131edd1f70115cd664c7ddb85;hp=f6068075adde04e5a020a98a3d79b799d656b4f7;p=lhc%2Fweb%2Fwiklou.git Merge "(bug 32492) API now allows editing using pageid" --- diff --git a/CREDITS b/CREDITS index 5c41d9627e..bac73913e6 100644 --- a/CREDITS +++ b/CREDITS @@ -124,6 +124,7 @@ following names for their contribution to the product. * John N * Karun Dambietz * Kim Hyun-Joon +* Krenair * Lee Worden * Lejonel * liangent diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index e0cb9b13a0..c6b275663a 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -83,6 +83,7 @@ production. the format parameter. * (bug 32384) Allow descending order for list=watchlistraw. * (bug 31883) Limit of bkusers of list=blocks and titles of action=query is not documented in API help. +* (bug 32492) API now allows editing using pageid === Languages updated in 1.20 === diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 9ed6d08da7..229afde816 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -1,4 +1,4 @@ -dieUsageMsg( 'missingtext' ); } - $titleObj = Title::newFromText( $params['title'] ); - if ( !$titleObj || $titleObj->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + $this->requireOnlyOneParameter( $params, 'title', 'pageid' ); + + if ( isset( $params['title'] ) ) { + $titleObj = Title::newFromText( $params['title'] ); + if ( !$titleObj || $titleObj->isExternal() ) { + $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + } + } elseif ( isset( $params['pageid'] ) ) { + $titleObj = Title::newFromID( $params['pageid'] ); + if ( !$titleObj ) { + $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) ); + } } $apiResult = $this->getResult(); @@ -371,45 +380,51 @@ class ApiEditPage extends ApiBase { public function getPossibleErrors() { global $wgMaxArticleSize; - return array_merge( parent::getPossibleErrors(), array( - array( 'missingtext' ), - array( 'invalidtitle', 'title' ), - array( 'createonly-exists' ), - array( 'nocreate-missing' ), - array( 'nosuchrevid', 'undo' ), - array( 'nosuchrevid', 'undoafter' ), - array( 'revwrongpage', 'id', 'text' ), - array( 'undo-failure' ), - array( 'hashcheckfailed' ), - array( 'hookaborted' ), - array( 'noimageredirect-anon' ), - array( 'noimageredirect-logged' ), - array( 'spamdetected', 'spam' ), - array( 'summaryrequired' ), - array( 'filtered' ), - array( 'blockedtext' ), - array( 'contenttoobig', $wgMaxArticleSize ), - array( 'noedit-anon' ), - array( 'noedit' ), - array( 'actionthrottledtext' ), - array( 'wasdeleted' ), - array( 'nocreate-loggedin' ), - array( 'blankpage' ), - array( 'editconflict' ), - array( 'emptynewsection' ), - array( 'unknownerror', 'retval' ), - array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ), - array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ), - array( 'customcssprotected' ), - array( 'customjsprotected' ), - ) ); + return array_merge( parent::getPossibleErrors(), + $this->getRequireOnlyOneParameterErrorMessages( 'title', 'pageid' ), + array( + array( 'nosuchpageid', 'pageid' ), + array( 'missingtext' ), + array( 'invalidtitle', 'title' ), + array( 'createonly-exists' ), + array( 'nocreate-missing' ), + array( 'nosuchrevid', 'undo' ), + array( 'nosuchrevid', 'undoafter' ), + array( 'revwrongpage', 'id', 'text' ), + array( 'undo-failure' ), + array( 'hashcheckfailed' ), + array( 'hookaborted' ), + array( 'noimageredirect-anon' ), + array( 'noimageredirect-logged' ), + array( 'spamdetected', 'spam' ), + array( 'summaryrequired' ), + array( 'filtered' ), + array( 'blockedtext' ), + array( 'contenttoobig', $wgMaxArticleSize ), + array( 'noedit-anon' ), + array( 'noedit' ), + array( 'actionthrottledtext' ), + array( 'wasdeleted' ), + array( 'nocreate-loggedin' ), + array( 'blankpage' ), + array( 'editconflict' ), + array( 'emptynewsection' ), + array( 'unknownerror', 'retval' ), + array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ), + array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ), + array( 'customcssprotected' ), + array( 'customjsprotected' ), + ) + ); } public function getAllowedParams() { return array( 'title' => array( ApiBase::PARAM_TYPE => 'string', - ApiBase::PARAM_REQUIRED => true + ), + 'pageid' => array( + ApiBase::PARAM_TYPE => 'integer', ), 'section' => null, 'sectiontitle' => array( @@ -463,7 +478,8 @@ class ApiEditPage extends ApiBase { public function getParamDescription() { $p = $this->getModulePrefix(); return array( - 'title' => 'Page title', + 'title' => "Title of the page you want to edit. Cannot be used together with {$p}pageid", + 'pageid' => "Page ID of the page you want to edit. Cannot be used together with {$p}title, 'section' => 'Section number. 0 for the top section, \'new\' for a new section', 'sectiontitle' => 'The title for a new section', 'text' => 'Page content',