r96833 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96832‎ | r96833 | r96834 >
Date:11:17, 12 September 2011
Author:catrope
Status:ok
Tags:
Comment:
Update the Gadgets API in trunk for the name->ID change in r96761. See also r96006
Modified paths:
  • /trunk/extensions/Gadgets/ApiQueryGadgets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Gadgets/ApiQueryGadgets.php
@@ -22,7 +22,7 @@
2323 class ApiQueryGadgets extends ApiQueryBase {
2424 private $props,
2525 $categories,
26 - $neededNames,
 26+ $neededIds,
2727 $listAllowed,
2828 $listEnabled;
2929
@@ -36,8 +36,8 @@
3737 $this->categories = isset( $params['categories'] )
3838 ? array_flip( $params['categories'] )
3939 : false;
40 - $this->neededNames = isset( $params['names'] )
41 - ? array_flip( $params['names'] )
 40+ $this->neededIds = isset( $params['ids'] )
 41+ ? array_flip( $params['ids'] )
4242 : false;
4343 $this->listAllowed = isset( $params['allowedonly'] ) && $params['allowedonly'];
4444 $this->listEnabled = isset( $params['enabledonly'] ) && $params['enabledonly'];
@@ -77,8 +77,8 @@
7878
7979 foreach ( $gadgets as $g ) {
8080 $row = array();
81 - if ( isset( $this->props['name'] ) ) {
82 - $row['name'] = $g->getName();
 81+ if ( isset( $this->props['id'] ) ) {
 82+ $row['id'] = $g->getName();
8383 }
8484 if ( isset( $this->props['metadata'] ) ) {
8585 $row['metadata'] = $this->fakeMetadata( $g );
@@ -101,7 +101,7 @@
102102 private function isNeeded( Gadget $gadget ) {
103103 global $wgUser;
104104
105 - return ( $this->neededNames === false || isset( $this->neededNames[$gadget->getName()] ) )
 105+ return ( $this->neededIds === false || isset( $this->neededIds[$gadget->getName()] ) )
106106 && ( !$this->listAllowed || $gadget->isAllowed( $wgUser ) )
107107 && ( !$this->listEnabled || $gadget->isEnabled( $wgUser ) );
108108 }
@@ -151,10 +151,10 @@
152152 public function getAllowedParams() {
153153 return array(
154154 'prop' => array(
155 - ApiBase::PARAM_DFLT => 'name|metadata',
 155+ ApiBase::PARAM_DFLT => 'id|metadata',
156156 ApiBase::PARAM_ISMULTI => true,
157157 ApiBase::PARAM_TYPE => array(
158 - 'name',
 158+ 'id',
159159 'metadata',
160160 'desc',
161161 ),
@@ -164,7 +164,7 @@
165165 ApiBase::PARAM_ISMULTI => true,
166166 ApiBase::PARAM_TYPE => 'string',
167167 ),
168 - 'names' => array(
 168+ 'ids' => array(
169169 ApiBase::PARAM_TYPE => 'string',
170170 ApiBase::PARAM_ISMULTI => true,
171171 ),
@@ -181,12 +181,12 @@
182182 return array(
183183 'prop' => array(
184184 'What gadget information to get:',
185 - ' name - Internal gadget name',
 185+ ' id - Internal gadget ID',
186186 ' metadata - The gadget metadata',
187187 ' desc - Gadget description transformed into HTML (can be slow, use only if really needed)',
188188 ),
189189 'categories' => 'Gadgets from what categories to retrieve',
190 - 'names' => 'Name(s) of gadgets to retrieve',
 190+ 'ids' => 'ID(s) of gadgets to retrieve',
191191 'allowedonly' => 'List only gadgets allowed to current user',
192192 'enabledonly' => 'List only gadgets enabled by current user',
193193 );
@@ -197,13 +197,13 @@
198198 $allProps = implode( '|', $params['prop'][ApiBase::PARAM_TYPE] );
199199 return array(
200200 'Get a list of gadgets along with their descriptions:',
201 - ' api.php?action=query&list=gadgets&gaprop=name|desc',
 201+ ' api.php?action=query&list=gadgets&gaprop=id|desc',
202202 'Get a list of gadgets with all possble properties:',
203203 " api.php?action=query&list=gadgets&gaprop=$allProps",
204204 'Get a list of gadgets belonging to caregory "foo":',
205205 ' api.php?action=query&list=gadgets&gacategories=foo',
206 - 'Get information about gadgets named "foo" and "bar":',
207 - ' api.php?action=query&list=gadgets&ganames=foo|bar&gaprop=name|desc|metadata',
 206+ 'Get information about gadgets "foo" and "bar":',
 207+ ' api.php?action=query&list=gadgets&gaids=foo|bar&gaprop=id|desc|metadata',
208208 'Get a list of gadgets enabled by current user:',
209209 ' api.php?action=query&list=gadgets&gaenabledonly',
210210 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97274REL1_18 MFT r96825, r96833, r96998reedy14:24, 16 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96006Gadgets: To prevent back compat hacks in 1.19, change the Gadgets API to be c...catrope16:08, 1 September 2011
r96761[ResourceLoader2] (BREAKING CHANGE) Rename gd_name to gd_id to avoid confusio...krinkle00:08, 11 September 2011

Status & tagging log