r70478 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70477‎ | r70478 | r70479 >
Date:20:47, 4 August 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Make search enforced by API in search by setting PARAM_REQUIRED

Same for ApiQueryCategoryMembers and ApiWatch title params

More followup to r70461
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySearch.php (modified) (history)
  • /trunk/phase3/includes/api/ApiWatch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiWatch.php
@@ -76,7 +76,11 @@
7777
7878 public function getAllowedParams() {
7979 return array(
80 - 'title' => null,
 80+ 'title' => array(
 81+ ApiBase::PARAM_TYPE => 'string',
 82+ ApiBase::PARAM_REQUIRED => true
 83+ ),
 84+
8185 'unwatch' => false,
8286 );
8387 }
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -54,9 +54,6 @@
5555 private function run( $resultPageSet = null ) {
5656 $params = $this->extractRequestParams();
5757
58 - if ( !isset( $params['title'] ) || is_null( $params['title'] ) ) {
59 - $this->dieUsage( 'The cmtitle parameter is required', 'notitle' );
60 - }
6158 $categoryTitle = Title::newFromText( $params['title'] );
6259
6360 if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY ) {
@@ -208,7 +205,11 @@
209206
210207 public function getAllowedParams() {
211208 return array(
212 - 'title' => null,
 209+ 'title' => array(
 210+ ApiBase::PARAM_TYPE => 'string',
 211+ ApiBase::PARAM_REQUIRED => true
 212+ ),
 213+
213214 'prop' => array(
214215 ApiBase::PARAM_DFLT => 'ids|title',
215216 ApiBase::PARAM_ISMULTI => true,
Index: trunk/phase3/includes/api/ApiQuerySearch.php
@@ -58,10 +58,6 @@
5959 $searchInfo = array_flip( $params['info'] );
6060 $prop = array_flip( $params['prop'] );
6161
62 - if ( strval( $query ) === '' ) {
63 - $this->dieUsage( 'empty search string is not allowed', 'param-search' );
64 - }
65 -
6662 // Create search engine instance and set options
6763 $search = SearchEngine::create();
6864 $search->setLimitOffset( $limit + 1, $params['offset'] );
@@ -170,7 +166,10 @@
171167
172168 public function getAllowedParams() {
173169 return array(
174 - 'search' => null,
 170+ 'search' => array(
 171+ ApiBase::PARAM_TYPE => 'string',
 172+ ApiBase::PARAM_REQUIRED => true
 173+ ),
175174 'namespace' => array(
176175 ApiBase::PARAM_DFLT => 0,
177176 ApiBase::PARAM_TYPE => 'namespace',
@@ -239,7 +238,6 @@
240239
241240 public function getPossibleErrors() {
242241 return array_merge( parent::getPossibleErrors(), array(
243 - array( 'code' => 'param-search', 'info' => 'empty search string is not allowed' ),
244242 array( 'code' => 'search-text-disabled', 'info' => 'text search is disabled' ),
245243 array( 'code' => 'search-title-disabled', 'info' => 'title search is disabled' ),
246244 ) );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70461Followup to r70460: Committed wrong version of ApiBase.php, convert all core ...soxred9314:15, 4 August 2010

Comments

#Comment by Reedy (talk | contribs)   20:49, 4 August 2010

Can probably make username/password in ApiLogin required too...

Status & tagging log