r50318 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50317‎ | r50318 | r50319 >
Date:19:23, 7 May 2009
Author:demon
Status:ok
Tags:
Comment:
* Use new LoadAllMessages hook
* Remove useless globals ($wgTitle, $wgMessageCache, $wgLang, $wgSkin)
* NULL -> null
Modified paths:
  • /trunk/extensions/Gadgets/Gadgets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Gadgets/Gadgets.php
@@ -48,9 +48,9 @@
4949 }
5050
5151 function wfLoadGadgets() {
52 - static $gadgets = NULL;
 52+ static $gadgets = null;
5353
54 - if ( $gadgets !== NULL ) return $gadgets;
 54+ if ( $gadgets !== null ) return $gadgets;
5555
5656 $struct = wfLoadGadgetsStructured();
5757 if ( !$struct ) {
@@ -66,15 +66,15 @@
6767 return $gadgets;
6868 }
6969
70 -function wfLoadGadgetsStructured( $forceNewText = NULL ) {
 70+function wfLoadGadgetsStructured( $forceNewText = null ) {
7171 global $wgMemc;
7272
73 - static $gadgets = NULL;
74 - if ( $gadgets !== NULL && $forceNewText === NULL ) return $gadgets;
 73+ static $gadgets = null;
 74+ if ( $gadgets !== null && $forceNewText === null ) return $gadgets;
7575
7676 $key = wfMemcKey( 'gadgets-definition' );
7777
78 - if ( $forceNewText === NULL ) {
 78+ if ( $forceNewText === null ) {
7979 //cached?
8080 $gadgets = $wgMemc->get( $key );
8181 if ( is_array($gadgets) ) return $gadgets;
@@ -114,7 +114,7 @@
115115
116116 //cache for a while. gets purged automatically when MediaWiki:Gadgets-definition is edited
117117 $wgMemc->set( $key, $gadgets, 60*60*24 );
118 - $source = $forceNewText !== NULL ? 'input text' : 'MediaWiki:Gadgets-definition';
 118+ $source = $forceNewText !== null ? 'input text' : 'MediaWiki:Gadgets-definition';
119119 wfDebug( __METHOD__ . ": $source parsed, cache entry $key updated\n");
120120
121121 return $gadgets;
@@ -159,12 +159,12 @@
160160 }
161161
162162 function wfGadgetsBeforePageDisplay( &$out ) {
163 - global $wgUser, $wgTitle;
 163+ global $wgUser;
164164 if ( !$wgUser->isLoggedIn() ) return true;
165165
166166 //disable all gadgets on Special:Preferences
167 - if ( $wgTitle->getNamespace() == NS_SPECIAL ) {
168 - $name = SpecialPage::resolveAlias( $wgTitle->getText() );
 167+ if ( $out->getTitle()->getNamespace() == NS_SPECIAL ) {
 168+ $name = SpecialPage::resolveAlias( $out->getTitle()->getText() );
169169 if ( $name == "Preferences" ) return true;
170170 }
171171
@@ -184,7 +184,7 @@
185185 }
186186
187187 function wfApplyGadgetCode( $code, &$out, &$done ) {
188 - global $wgSkin, $wgJsMimeType;
 188+ global $wgJsMimeType;
189189
190190 //FIXME: stuff added via $out->addScript appears below usercss and userjs in the head tag.
191191 // but we'd want it to appear above explicit user stuff, so it can be overwritten.
@@ -211,9 +211,7 @@
212212 /**
213213 * inject descriptions into system messages, so they show on Special:Allmessages
214214 */
215 -function wfGadgetsInjectMessages() {
216 - global $wgLang, $wgMessageCache;
217 -
 215+function wfGadgetsInjectMessages( $msgCache ) {
218216 $gadgets = wfLoadGadgetsStructured();
219217 if ( !$gadgets ) return true;
220218
@@ -236,7 +234,7 @@
237235 }
238236 }
239237
240 - $wgMessageCache->addMessages( $messages );
 238+ $msgCache->addMessages( $messages );
241239 return true;
242240 }
243241

Status & tagging log