r90295 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90294‎ | r90295 | r90296 >
Date:16:49, 17 June 2011
Author:salvatoreingala
Status:ok
Tags:
Comment:
Added info on possible errors to API modules
Modified paths:
  • /branches/salvatoreingala/Gadgets/ApiGetGadgetPrefs.php (modified) (history)
  • /branches/salvatoreingala/Gadgets/ApiSetGadgetPrefs.php (modified) (history)

Diff [purge]

Index: branches/salvatoreingala/Gadgets/ApiSetGadgetPrefs.php
@@ -57,7 +57,7 @@
5858 $this->getResult()->addValue(
5959 null, $this->getModuleName(), array( 'result' => 'Success' ) );
6060 } else {
61 - $this->dieUsage( 'Invalid preferences.', 'invalidprefs' );
 61+ $this->dieUsage( 'Invalid preferences', 'invalidprefs' );
6262 }
6363 }
6464
@@ -98,6 +98,16 @@
9999 return 'Allows user code to set preferences for gadgets';
100100 }
101101
 102+ public function getPossibleErrors() {
 103+ return array_merge( parent::getPossibleErrors(), array(
 104+ array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to get gadget\'s preferences' ),
 105+ array( 'sessionfailure' ),
 106+ array( 'code' => 'notfound', 'info' => 'Gadget not found' ),
 107+ array( 'code' => 'notjson', 'info' => 'The \'pref\' parameter must be valid JSON' ),
 108+ array( 'code' => 'invalidprefs', 'info' => 'Invalid preferences' ),
 109+ ) );
 110+ }
 111+
102112 public function needsToken() {
103113 return true;
104114 }
Index: branches/salvatoreingala/Gadgets/ApiGetGadgetPrefs.php
@@ -43,7 +43,7 @@
4444 $prefsDescription = $gadget->getPrefsDescription();
4545
4646 if ( $prefsDescription === null ) {
47 - $this->dieUsage( 'Gadget ' . $gadget->getName() . ' does not have any preference.', 'noprefs' );
 47+ $this->dieUsage( 'Gadget ' . $gadget->getName() . ' does not have any preference', 'noprefs' );
4848 }
4949
5050 $userPrefs = $gadget->getPrefs();
@@ -76,9 +76,17 @@
7777 }
7878
7979 public function getDescription() {
80 - return 'Allows user code to get preferences for gadgets, along with preference descriptions';
 80+ return 'Allows user code to get preferences for gadgets, along with preference descriptions and values for currently logged in user';
8181 }
8282
 83+ public function getPossibleErrors() {
 84+ return array_merge( parent::getPossibleErrors(), array(
 85+ array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to get gadget\'s preferences' ),
 86+ array( 'code' => 'notfound', 'info' => 'Gadget not found' ),
 87+ array( 'code' => 'noprefs', 'info' => 'Gadget gadgetname does not have any preferences' ),
 88+ ) );
 89+ }
 90+
8391 public function getVersion() {
8492 return __CLASS__ . ': $Id$';
8593 }

Status & tagging log