r95981 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95980‎ | r95981 | r95982 >
Date:13:31, 1 September 2011
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
RL2: Make list=gadgetcategories work again
Modified paths:
  • /branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgetCategories.php
@@ -42,9 +42,17 @@
4343 private function getList() {
4444 $data = array();
4545 $result = $this->getResult();
46 - $gadgets = Gadget::loadStructuredList();
 46+ $repo = new LocalGadgetRepo( array() );
 47+ $gadgets = $repo->getGadgetNames();
 48+
 49+ // TODO: Put the grouping in the repo
 50+ $gadgetsByCategory = array();
 51+ foreach ( $gadgets as $name ) {
 52+ $gadget = $repo->getGadget( $name );
 53+ $gadgetsByCategory[$gadget->getCategory()] = $gadget;
 54+ }
4755
48 - foreach ( $gadgets as $category => $list ) {
 56+ foreach ( $gadgetsByCategory as $category => $gadgets ) {
4957 if ( !$this->neededNames || isset( $this->neededNames[$category] ) ) {
5058 $row = array();
5159 if ( isset( $this->props['name'] ) ) {
@@ -52,6 +60,7 @@
5361 }
5462 if ( $category !== "" ) {
5563 if ( isset( $this->props['desc'] ) ) {
 64+ // TODO: Put message into the repo too, with fallback behavior
5665 $row['desc'] = wfMessage( "gadgetcategory-$category" )->parse();
5766 }
5867 if ( isset( $this->props['desc-raw'] ) ) {
@@ -59,7 +68,7 @@
6069 }
6170 }
6271 if ( isset( $this->props['members'] ) ) {
63 - $row['members'] = count( $list );
 72+ $row['members'] = count( $gadgets );
6473 }
6574 $data[] = $row;
6675 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r96215[ResourceLoader2] Needs [] for it to be an array and count() to work....krinkle02:26, 4 September 2011

Comments

#Comment by Krinkle (talk | contribs)   02:25, 4 September 2011

The count is always 1 for some reason... Related to the issue of empty string-keys overwriting eachother ?

#Comment by Krinkle (talk | contribs)   02:26, 4 September 2011

OK otherwise.

Found problem, missing []. Fixed in r96215.

Status & tagging log