r105586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105585‎ | r105586 | r105587 >
Date:20:41, 8 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix a few minor issues with Harvard related code

Documentation

Fix usage of global when we have an $out parameter
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -102,6 +102,8 @@
103103
104104 /**
105105 * UnitTestsList hook handler
 106+ * @param $files array
 107+ * @return bool
106108 */
107109 function efCentralNoticeUnitTests( &$files ) {
108110 $files[] = dirname( __FILE__ ) . '/tests/CentralNoticeTest.php';
@@ -165,6 +167,8 @@
166168
167169 /**
168170 * LoadExtensionSchemaUpdates hook handler
 171+ * @param $updater DatabaseUpdater|null
 172+ * @return bool
169173 */
170174 function efCentralNoticeSchema( $updater = null ) {
171175 $base = dirname( __FILE__ );
@@ -222,21 +226,25 @@
223227
224228 /**
225229 * BeforePageDisplay hook handler
 230+ * @param $out OutputPage
 231+ * @param $skin Skin
 232+ * @return bool
226233 */
227234 function efCentralNoticeLoader( $out, $skin ) {
228 - global $wgOut;
229 -
230235 // Include '.js' to exempt script from squid cache expiration override
231236 $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl( 'cache=/cn.js' );
232237
233238 // Insert the banner controller Javascript into the page
234 - $wgOut->addScriptFile( $centralLoader );
 239+ $out->addScriptFile( $centralLoader );
235240
236241 return true;
237242 }
238243
239244 /**
240245 * SkinAfterBottomScripts hook handler
 246+ * @param $skin Skin
 247+ * @param $text string
 248+ * @return bool
241249 */
242250 function efCentralNoticeGeoLoader( $skin, &$text ) {
243251 // Insert the geo IP lookup
@@ -244,9 +252,10 @@
245253 return true;
246254 }
247255
248 -
249256 /**
250257 * MakeGlobalVariablesScript hook handler
 258+ * @param $vars array
 259+ * @return bool
251260 */
252261 function efCentralNoticeDefaults( &$vars ) {
253262 // Using global $wgUser for compatibility with 1.18
@@ -294,14 +303,14 @@
295304 'login' => intval( $wgUser->getId() ),
296305
297306 // "group" is the group name(s) of the user (comma-separated).
298 - 'group' => join( ',', $groups ),
 307+ 'group' => implode( ',', $groups ),
299308
300309 // "duration" is the number of days since the user registered his (on the launching date).
301310 // Note: Will be negative if user registered after launch date!
302311 'duration' => intval( $daysOld ),
303312
304313 // "editcounts" is the user's total number of edits
305 - 'editcounts' => $wgUser->getEditCount() == NULL ? 0 : intval( $wgUser->getEditCount() ),
 314+ 'editcounts' => $wgUser->getEditCount() == null ? 0 : intval( $wgUser->getEditCount() ),
306315
307316 // "last6monthseditcount" is the user's total number of edits in the last 180 days (on the launching date)
308317 'last6monthseditcount' => getUserEditCountSince(
@@ -346,6 +355,8 @@
347356
348357 /**
349358 * SiteNoticeAfter hook handler
 359+ * @param $notice string
 360+ * @return bool
350361 */
351362 function efCentralNoticeDisplay( &$notice ) {
352363 // setup siteNotice div
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -14,6 +14,12 @@
1515 /**
1616 * Return campaigns in the system within given constraints
1717 * By default returns enabled campaigns, if $enabled set to false, returns both enabled and disabled campaigns
 18+ * @param $project string
 19+ * @param $language string
 20+ * @param $date string
 21+ * @param $enabled bool
 22+ * @param $preferred string
 23+ * @param $location string
1824 * @return an array of ids
1925 */
2026 static function getCampaigns( $project = false, $language = false, $date = false, $enabled = true, $preferred = false, $location = false ) {
@@ -289,7 +295,10 @@
290296 * Lookup function for active banners under a given language/project/location. This function is
291297 * called by SpecialBannerListLoader::getJsonList() in order to build the banner list JSON for
292298 * each project.
293 - * @return a 2D array of running banners with associated weights and settings
 299+ * @param $project string
 300+ * @param $language string
 301+ * @param $location string
 302+ * @return array a 2D array of running banners with associated weights and settings
294303 */
295304 static function getBannersByTarget( $project, $language, $location = null ) {
296305 global $wgCentralDBname;
@@ -371,6 +380,8 @@
372381
373382 /**
374383 * See if a given campaign exists in the database
 384+ * @param $campaignName string
 385+ * @return bool
375386 */
376387 public static function campaignExists( $campaignName ) {
377388 global $wgCentralDBname;
@@ -382,6 +393,8 @@
383394
384395 /**
385396 * See if a given banner exists in the database
 397+ * @param $bannerName string
 398+ * @return bool
386399 */
387400 public static function bannerExists( $bannerName ) {
388401 global $wgCentralDBname;
@@ -399,6 +412,7 @@
400413 /**
401414 * Return all of the available countries for geotargeting
402415 * (This should probably be moved to a core database table at some point.)
 416+ * @return array
403417 */
404418 static function getCountriesList() {
405419 return array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r105588CentralNotice MFT r105239, 105241, r105267, r105450, r105452, r105453, r105586reedy20:57, 8 December 2011

Status & tagging log