r101344 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101343‎ | r101344 | r101345 >
Date:09:27, 31 October 2011
Author:catrope
Status:ok
Tags:
Comment:
[RL2] Revert r101305, broken. Warning: Illegal offset type in /home/catrope/mediawiki/branches/RL2/extensions/Gadgets/Gadgets.hooks.php on line 304
Modified paths:
  • /branches/RL2/extensions/Gadgets/backend/GadgetRepo.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/backend/GadgetRepo.php
@@ -113,28 +113,28 @@
114114
115115 /**
116116 * Helper function for getAllGadgets(), getAllGadgetIDs(), getAllRemoteGadgets() and getAllRemoteGadgetIDs()
117 - * @param $source String: one of 'local', 'remote', 'all'.
118 - * @param $retType String: Whether to return an array of IDs ('ids'), or Gadget objects ('objects').
 117+ * @param $includeLocal boolean Whether gadgets from the local repo should be included
 118+ * @param $getObjects boolean Whether Gadget objects should be constructed. If false, IDs (strings) will be returned
119119 * @return array of Gadget objects or strings
120120 */
121 - private static function getAllGadgets_internal( $source = 'all', $retType = 'ids' ) {
122 - $retVal = array();
 121+ private static function getAllGadgets_internal( $includeLocal, $getObjects ) {
 122+ $retval = array();
123123 $repos = GadgetRepo::getAllRepos();
124124 foreach ( $repos as $repo ) {
125 - if ( $source == 'remote' && $repo->isLocal() ) {
 125+ if ( !$includeLocal && $repo->isLocal() ) {
126126 continue;
127127 }
128128
129129 $gadgets = $repo->getGadgetIds();
130 - if ( $retType = 'objects' ) {
 130+ if ( $getObjects ) {
131131 foreach ( $gadgets as $id ) {
132 - $retVal[] = $repo->getGadget( $id );
 132+ $retval[] = $repo->getGadget( $id );
133133 }
134134 } else {
135 - $retVal = array_merge( $retVal, $gadgets );
 135+ $retval = array_merge( $retval, $gadgets );
136136 }
137137 }
138 - return $retVal;
 138+ return $retval;
139139 }
140140
141141 /**
@@ -142,7 +142,7 @@
143143 * @return array of Gadget objects
144144 */
145145 public static function getAllGadgets() {
146 - return self::getAllGadgets_internal( 'all', 'objects' );
 146+ return self::getAllGadgets_internal( true, true );
147147 }
148148
149149 /**
@@ -150,7 +150,7 @@
151151 * @return array of gadget IDs (strings)
152152 */
153153 public static function getAllGadgetIDs() {
154 - return self::getAllGadgets_internal( 'all', 'ids' );
 154+ return self::getAllGadgets_internal( true, false );
155155 }
156156
157157 /**
@@ -158,7 +158,7 @@
159159 * @return array of Gadget objects
160160 */
161161 public static function getAllRemoteGadgets() {
162 - return self::getAllGadgets_internal( 'remote', 'objects' );
 162+ return self::getAllGadgets_internal( false, true );
163163 }
164164
165165 /**
@@ -166,6 +166,6 @@
167167 * @return array of gadget IDs (strings)
168168 */
169169 public static function getAllRemoteGadgetIDs() {
170 - return self::getAllGadgets_internal( 'remote', 'ids' );
 170+ return self::getAllGadgets_internal( false, false );
171171 }
172172 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101305[RL2] Use Strangs instead of booleans for GadgetRepo::getAllGadgets_internal...krinkle16:42, 30 October 2011

Status & tagging log