r50955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50954‎ | r50955 | r50956 >
Date:12:09, 24 May 2009
Author:robin
Status:ok (Comments)
Tags:
Comment:
Update per r50782:
* Remove all $wgAllowRealName, check $wgHiddenPrefs instead
* Make $wgAllowUserSkin obsolete too, check $wgHiddenPrefs instead
* And also only call globals if really needed, and remove unused globals
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Credits.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2149,16 +2149,18 @@
21502150 * @todo FIXME : need to check the old failback system [AV]
21512151 */
21522152 function &getSkin( $t = null ) {
2153 - global $wgRequest, $wgAllowUserSkin, $wgDefaultSkin;
21542153 if ( ! isset( $this->mSkin ) ) {
21552154 wfProfileIn( __METHOD__ );
21562155
2157 - if( $wgAllowUserSkin ) {
 2156+ global $wgHiddenPrefs;
 2157+ if( !in_array( 'skin', $wgHiddenPrefs ) ) {
21582158 # get the user skin
 2159+ global $wgRequest;
21592160 $userSkin = $this->getOption( 'skin' );
21602161 $userSkin = $wgRequest->getVal('useskin', $userSkin);
21612162 } else {
21622163 # if we're not allowing users to override, then use the default
 2164+ global $wgDefaultSkin;
21632165 $userSkin = $wgDefaultSkin;
21642166 }
21652167
Index: trunk/phase3/includes/Setup.php
@@ -201,12 +201,16 @@
202202 # If file cache or squid cache is on, just disable this (DWIMD).
203203 if( $wgUseFileCache || $wgUseSquid ) $wgShowIPinHeader = false;
204204
205 -# $wgAllowRealName was removed in 1.16 in favor of $wgHiddenPrefs,
206 -# handle b/c here
 205+# $wgAllowRealName and $wgAllowUserSkin were removed in 1.16
 206+# in favor of $wgHiddenPrefs, handle b/c here
207207 if( !$wgAllowRealName ) {
208208 $wgHiddenPrefs[] = 'realname';
209209 }
210210
 211+if( !$wgAllowUserSkin ) {
 212+ $wgHiddenPrefs[] = 'skin';
 213+}
 214+
211215 wfProfileOut( $fname.'-misc1' );
212216 wfProfileIn( $fname.'-memcached' );
213217
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2398,7 +2398,10 @@
23992399 /** See list of skins and their symbolic names in languages/Language.php */
24002400 $wgDefaultSkin = 'monobook';
24012401
2402 -/** Should we allow the user's to select their own skin that will override the default? */
 2402+/**
 2403+* Should we allow the user's to select their own skin that will override the default?
 2404+* @deprecated in 1.16, use $wgHiddenPrefs[] = 'skin' to disable it
 2405+*/
24032406 $wgAllowUserSkin = true;
24042407
24052408 /**
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -44,7 +44,7 @@
4545 * @param WebRequest $request A WebRequest object passed by reference
4646 */
4747 function LoginForm( &$request, $par = '' ) {
48 - global $wgLang, $wgAllowRealName, $wgEnableEmail;
 48+ global $wgLang, $wgHiddenPrefs, $wgEnableEmail;
4949 global $wgAuth, $wgRedirectOnLogin;
5050
5151 $this->mType = ( $par == 'signup' ) ? $par : $request->getText( 'type' ); # Check for [[Special:Userlogin/signup]]
@@ -75,7 +75,7 @@
7676 } else {
7777 $this->mEmail = '';
7878 }
79 - if( $wgAllowRealName ) {
 79+ if( !in_array( 'realname', $wgHiddenPrefs ) ) {
8080 $this->mRealName = $request->getText( 'wpRealName' );
8181 } else {
8282 $this->mRealName = '';
@@ -798,7 +798,7 @@
799799 * @private
800800 */
801801 function mainLoginForm( $msg, $msgtype = 'error' ) {
802 - global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
 802+ global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail;
803803 global $wgCookiePrefix, $wgLoginLanguageSelector;
804804 global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
805805
@@ -874,7 +874,7 @@
875875 $template->set( 'message', $msg );
876876 $template->set( 'messagetype', $msgtype );
877877 $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
878 - $template->set( 'userealname', $wgAllowRealName );
 878+ $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs ) );
879879 $template->set( 'useemail', $wgEnableEmail );
880880 $template->set( 'emailrequired', $wgEmailConfirmToEdit );
881881 $template->set( 'canreset', $wgAuth->allowPasswordChange() );
Index: trunk/phase3/includes/Credits.php
@@ -75,7 +75,7 @@
7676 * @param $article Article object
7777 */
7878 protected static function getAuthor( Article $article ){
79 - global $wgLang, $wgAllowRealName;
 79+ global $wgLang;
8080
8181 $user = User::newFromId( $article->getUser() );
8282
@@ -98,7 +98,7 @@
9999 * @return String: html
100100 */
101101 protected static function getContributors( Article $article, $cnt, $showIfMax ) {
102 - global $wgLang, $wgAllowRealName;
 102+ global $wgLang, $wgHiddenPrefs;
103103
104104 $contributors = $article->getContributors();
105105
@@ -120,7 +120,7 @@
121121 $cnt--;
122122 if( $user->isLoggedIn() ){
123123 $link = self::link( $user );
124 - if( $wgAllowRealName && $user->getRealName() )
 124+ if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
125125 $real_names[] = $link;
126126 else
127127 $user_names[] = $link;
@@ -162,15 +162,15 @@
163163 * @return String: html
164164 */
165165 protected static function link( User $user ) {
166 - global $wgUser, $wgAllowRealName;
167 - if( $wgAllowRealName )
 166+ global $wgHiddenPrefs;
 167+ if( !in_array( 'realname', $wgHiddenPrefs ) )
168168 $real = $user->getRealName();
169169 else
170170 $real = false;
171171
172 - $skin = $wgUser->getSkin();
 172+ $skin = $user->getSkin();
173173 $page = $user->getUserPage();
174 -
 174+
175175 return $skin->link( $page, htmlspecialchars( $real ? $real : $user->getName() ) );
176176 }
177177
@@ -181,12 +181,12 @@
182182 * @return String: html
183183 */
184184 protected static function userLink( User $user ) {
185 - global $wgUser, $wgAllowRealName;
186185 if( $user->isAnon() ){
187186 return wfMsgExt( 'anonymous', array( 'parseinline' ), 1 );
188187 } else {
 188+ global $wgHiddenPrefs;
189189 $link = self::link( $user );
190 - if( $wgAllowRealName && $user->getRealName() )
 190+ if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
191191 return $link;
192192 else
193193 return wfMsgExt( 'siteuser', array( 'parseinline', 'replaceafter' ), $link );
Index: trunk/phase3/includes/Preferences.php
@@ -379,20 +379,17 @@
380380
381381 static function skinPreferences( $user, &$defaultPreferences ) {
382382 ## Skin #####################################
383 - global $wgAllowUserSkin, $wgLang;
 383+ $defaultPreferences['skin'] =
 384+ array(
 385+ 'type' => 'radio',
 386+ 'options' => self::generateSkinOptions( $user ),
 387+ 'label' => ' ',
 388+ 'section' => 'rendering/skin',
 389+ );
384390
385 - if ($wgAllowUserSkin) {
386 - $defaultPreferences['skin'] =
387 - array(
388 - 'type' => 'radio',
389 - 'options' => self::generateSkinOptions( $user ),
390 - 'label' => ' ',
391 - 'section' => 'rendering/skin',
392 - );
393 - }
394 -
395391 $selectedSkin = $user->getOption( 'skin' );
396392 if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) {
 393+ global $wgLang;
397394 $settings = array_flip($wgLang->getQuickbarSettings());
398395
399396 $defaultPreferences['quickbar'] =
@@ -1151,8 +1148,8 @@
11521149 }
11531150
11541151 // Fortunately, the realname field is MUCH simpler
1155 - global $wgAllowRealName;
1156 - if ($wgAllowRealName) {
 1152+ global $wgHiddenPrefs;
 1153+ if ( !in_array( 'realname', $wgHiddenPrefs ) ) {
11571154 $realName = $formData['realname'];
11581155 $wgUser->setRealName( $realName );
11591156 }
Index: trunk/phase3/RELEASE-NOTES
@@ -26,8 +26,9 @@
2727 be used when uploading/moving files
2828 * (bug 18761) $wgHiddenPrefs is a new array for specifying preferences not
2929 to be shown to users
30 -* $wgAllowRealName was deprecated in favor of $wgHiddenPrefs[] = 'realname',
31 - but the former is still retained for backwards-compatibility
 30+* $wgAllowRealName and $wgAllowUserSkin were deprecated in favor of
 31+ $wgHiddenPrefs[] = 'realname', but the former are still retained
 32+ for backwards-compatibility
3233 * (bug 9257) $wgRCMaxAge now defaults to three months
3334 * $wgDevelopmentWarnings can be set to true to show warnings about deprecated
3435 functions and other potential errors when developing.

Follow-up revisions

RevisionCommit summaryAuthorDate
r51025Fix for r50955, don't use the skin of the target user when linking to them.tstarling15:20, 26 May 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r50782(bug 18761) Add setting to hide a list of preferences.demon17:07, 19 May 2009

Comments

#Comment by Tim Starling (talk | contribs)   15:16, 26 May 2009
-		$skin = $wgUser->getSkin();
+		$skin = $user->getSkin();

The former was correct.

#Comment by Tim Starling (talk | contribs)   15:21, 26 May 2009

Should be OK after r51025.

Status & tagging log