r75678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75677‎ | r75678 | r75679 >
Date:21:36, 29 October 2010
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
Can only use continue in a loop
Modified paths:
  • /trunk/extensions/Gadgets/Gadgets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Gadgets/Gadgets.php
@@ -48,7 +48,9 @@
4949 function wfLoadGadgets() {
5050 static $gadgets = null;
5151
52 - if ( $gadgets !== null ) return $gadgets;
 52+ if ( $gadgets !== null ) {
 53+ return $gadgets;
 54+ }
5355
5456 $struct = wfLoadGadgetsStructured();
5557 if ( !$struct ) {
@@ -57,7 +59,7 @@
5860 }
5961
6062 $gadgets = array();
61 - foreach ( $struct as $section => $entries ) {
 63+ foreach ( $struct as $entries ) {
6264 $gadgets = array_merge( $gadgets, $entries );
6365 }
6466
@@ -68,7 +70,9 @@
6971 global $wgMemc;
7072
7173 static $gadgets = null;
72 - if ( $gadgets !== null && $forceNewText === null ) return $gadgets;
 74+ if ( $gadgets !== null && $forceNewText === null ) {
 75+ return $gadgets;
 76+ }
7377
7478 $key = wfMemcKey( 'gadgets-definition' );
7579
@@ -120,7 +124,9 @@
121125
122126 function wfGadgetsGetPreferences( $user, &$preferences ) {
123127 $gadgets = wfLoadGadgetsStructured();
124 - if (!$gadgets) return true;
 128+ if (!$gadgets) {
 129+ return true;
 130+ }
125131
126132 $options = array();
127133 foreach( $gadgets as $section => $thisSection ) {
@@ -162,7 +168,9 @@
163169
164170 function wfGadgetsBeforePageDisplay( $out ) {
165171 global $wgUser;
166 - if ( !$wgUser->isLoggedIn() ) return true;
 172+ if ( !$wgUser->isLoggedIn() ) {
 173+ return true;
 174+ }
167175
168176 //disable all gadgets on critical special pages
169177 //NOTE: $out->isUserJsAllowed() is tempting, but always fals if $wgAllowUserJs is false.
@@ -177,7 +185,9 @@
178186 }
179187
180188 $gadgets = wfLoadGadgets();
181 - if ( !$gadgets ) return true;
 189+ if ( !$gadgets ) {
 190+ return true;
 191+ }
182192
183193 $lb = new LinkBatch();
184194 $lb->setCaller( __METHOD__ );
@@ -197,7 +207,9 @@
198208
199209 $done = array();
200210 foreach ( $pages as $page ) {
201 - if ( isset( $done[$page] ) ) continue;
 211+ if ( isset( $done[$page] ) ) {
 212+ continue;
 213+ }
202214 $done[$page] = true;
203215 wfApplyGadgetCode( $page, $out );
204216 }
@@ -212,7 +224,9 @@
213225 // but we'd want it to appear above explicit user stuff, so it can be overwritten.
214226
215227 $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$page" );
216 - if ( !$t ) continue;
 228+ if ( !$t ) {
 229+ return;
 230+ }
217231
218232 if ( preg_match( '/\.js/', $page ) ) {
219233 $u = $t->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );

Comments

#Comment by MaxSem (talk | contribs)   08:48, 6 November 2010

Either this, or r75973 broke Gadgets: http://img46.imageshack.us/i/gadgets.png/ Please test your code before committing, always, no matter how trivial it seems.

Status & tagging log