r102129 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102128‎ | r102129 | r102130 >
Date:23:45, 5 November 2011
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: as per Markus' in-depth review:
*add an informational message when someone tries to view SocialProfile.php directly
*clarify doc comment about this being the main setup file -- it's also the only one right now; things were different years ago
*moved hooked functions into the same place
*move globals to the beginning of the function
Modified paths:
  • /trunk/extensions/SocialProfile/SocialProfile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SocialProfile.php
@@ -4,12 +4,22 @@
55 * This line must be present before any global variable is referenced.
66 */
77 if ( !defined( 'MEDIAWIKI' ) ) {
8 - die();
 8+ die(
 9+ 'This is the setup file for the SocialProfile extension to MediaWiki.' .
 10+ 'Please see http://www.mediawiki.org/wiki/Extension:SocialProfile for' .
 11+ ' more information about this extension.'
 12+ );
913 }
1014
1115 /**
12 - * This is the *main* (but certainly not the only) loader file for SocialProfile extension.
 16+ * This is the loader file for the SocialProfile extension. You should include
 17+ * this file in your wiki's LocalSettings.php to activate SocialProfile.
1318 *
 19+ * If you want to use the UserWelcome extension (bundled with SocialProfile),
 20+ * the <topusers /> tag or the user levels feature, there are some other files
 21+ * you will need to include in LocalSettings.php. The online manual has more
 22+ * details about this.
 23+ *
1424 * For more info about SocialProfile, please see http://www.mediawiki.org/wiki/Extension:SocialProfile.
1525 */
1626 $dir = dirname( __FILE__ ) . '/';
@@ -210,9 +220,26 @@
211221 require_once( "$IP/extensions/SocialProfile/SystemGifts/SystemGifts.php" ); // SystemGifts (awards functionality) loader file
212222 require_once( "$IP/extensions/SocialProfile/UserActivity/UserActivity.php" ); // UserActivity - recent social changes
213223
214 -# Schema changes
 224+// Hooked functions
 225+$wgHooks['CanonicalNamespaces'][] = 'wfSocialProfileRegisterCanonicalNamespaces';
215226 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efSocialProfileSchemaUpdates';
216227
 228+/**
 229+ * Register the canonical names for our custom namespaces and their talkspaces.
 230+ *
 231+ * @param $list Array: array of namespace numbers with corresponding
 232+ * canonical names
 233+ * @return Boolean: true
 234+ */
 235+function wfSocialProfileRegisterCanonicalNamespaces( &$list ) {
 236+ $list[NS_USER_WIKI] = 'UserWiki';
 237+ $list[NS_USER_WIKI_TALK] = 'UserWiki_talk';
 238+ $list[NS_USER_PROFILE] = 'User_profile';
 239+ $list[NS_USER_PROFILE_TALK] = 'User_profile_talk';
 240+ return true;
 241+}
 242+
 243+// Schema changes
217244 function efSocialProfileDBUpdate( $updater, $label, $file ) {
218245 if ( $updater === null ) {
219246 global $wgExtNewTables;
@@ -224,9 +251,10 @@
225252 }
226253
227254 function efSocialProfileSchemaUpdates( $updater = null ) {
 255+ global $wgDBtype;
 256+
228257 $dir = dirname( __FILE__ );
229258 $dbExt = '';
230 - global $wgDBtype;
231259
232260 if ( $wgDBtype == 'postgres' ) {
233261 $dbExt = '.postgres';
@@ -308,20 +336,4 @@
309337
310338 if( !defined( 'NS_USER_PROFILE_TALK' ) ) {
311339 define( 'NS_USER_PROFILE_TALK', 203 );
312 -}
313 -
314 -$wgHooks['CanonicalNamespaces'][] = 'wfSocialProfileRegisterCanonicalNamespaces';
315 -/**
316 - * Register the canonical names for our custom namespaces and their talkspaces.
317 - *
318 - * @param $list Array: array of namespace numbers with corresponding
319 - * canonical names
320 - * @return Boolean: true
321 - */
322 -function wfSocialProfileRegisterCanonicalNamespaces( &$list ) {
323 - $list[NS_USER_WIKI] = 'UserWiki';
324 - $list[NS_USER_WIKI_TALK] = 'UserWiki_talk';
325 - $list[NS_USER_PROFILE] = 'User_profile';
326 - $list[NS_USER_PROFILE_TALK] = 'User_profile_talk';
327 - return true;
328340 }
\ No newline at end of file

Status & tagging log