r98731 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98730‎ | r98731 | r98732 >
Date:02:27, 3 October 2011
Author:krinkle
Status:ok
Tags:
Comment:
[RL2] Move addModules code to before the early return for 'no-gadgets-found'.
* Previously, if a wiki had no gadgets, the module would not be loaded, and thus the 'create' tab would not be added and no editor was loaded to ajaxify the saving.
Modified paths:
  • /branches/RL2/extensions/Gadgets/SpecialGadgets.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/SpecialGadgets.php
@@ -204,6 +204,14 @@
205205 $repo = LocalGadgetRepo::singleton();
206206 $gadgetsByCategory = $repo->getGadgetsByCategory();
207207
 208+ // Only load the gadget manager module if needed
 209+ if ( $user->isAllowed( 'gadgets-definition-delete' )
 210+ || $user->isAllowed( 'gadgets-definition-edit' )
 211+ || $user->isAllowed( 'gadgets-definition-create' )
 212+ ) {
 213+ $out->addModules( 'ext.gadgets.gadgetmanager' );
 214+ }
 215+
208216 // If there there are no gadgets at all, exit early.
209217 if ( !count( $gadgetsByCategory ) ) {
210218 $noGadgetsMsgHtml = Html::element( 'p',
@@ -220,14 +228,6 @@
221229 Title::newFromText( 'Special:Recentchanges/namespace=' . NS_GADGET_DEFINITION )->getPrefixedText()
222230 );
223231
224 - // Only load the gadget manager module if needed
225 - if ( $user->isAllowed( 'gadgets-definition-delete' )
226 - || $user->isAllowed( 'gadgets-definition-edit' )
227 - || $user->isAllowed( 'gadgets-definition-create' )
228 - ) {
229 - $out->addModules( 'ext.gadgets.gadgetmanager' );
230 - }
231 -
232232 // Sort categories alphabetically
233233 ksort( $gadgetsByCategory );
234234

Status & tagging log