From 45e9b032ecd4ae1884c6331a70a3a2326628dfdd Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Sun, 24 May 2009 12:09:15 +0000 Subject: [PATCH] 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 --- RELEASE-NOTES | 5 +++-- includes/Credits.php | 18 +++++++++--------- includes/DefaultSettings.php | 5 ++++- includes/Preferences.php | 23 ++++++++++------------- includes/Setup.php | 8 ++++++-- includes/User.php | 6 ++++-- includes/specials/SpecialUserlogin.php | 8 ++++---- 7 files changed, 40 insertions(+), 33 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7e9a45ad7b..cc10190ee0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -26,8 +26,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN be used when uploading/moving files * (bug 18761) $wgHiddenPrefs is a new array for specifying preferences not to be shown to users -* $wgAllowRealName was deprecated in favor of $wgHiddenPrefs[] = 'realname', - but the former is still retained for backwards-compatibility +* $wgAllowRealName and $wgAllowUserSkin were deprecated in favor of + $wgHiddenPrefs[] = 'realname', but the former are still retained + for backwards-compatibility * (bug 9257) $wgRCMaxAge now defaults to three months * $wgDevelopmentWarnings can be set to true to show warnings about deprecated functions and other potential errors when developing. diff --git a/includes/Credits.php b/includes/Credits.php index 9137c3fc5d..817f1794cd 100644 --- a/includes/Credits.php +++ b/includes/Credits.php @@ -75,7 +75,7 @@ class Credits { * @param $article Article object */ protected static function getAuthor( Article $article ){ - global $wgLang, $wgAllowRealName; + global $wgLang; $user = User::newFromId( $article->getUser() ); @@ -98,7 +98,7 @@ class Credits { * @return String: html */ protected static function getContributors( Article $article, $cnt, $showIfMax ) { - global $wgLang, $wgAllowRealName; + global $wgLang, $wgHiddenPrefs; $contributors = $article->getContributors(); @@ -120,7 +120,7 @@ class Credits { $cnt--; if( $user->isLoggedIn() ){ $link = self::link( $user ); - if( $wgAllowRealName && $user->getRealName() ) + if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) $real_names[] = $link; else $user_names[] = $link; @@ -162,15 +162,15 @@ class Credits { * @return String: html */ protected static function link( User $user ) { - global $wgUser, $wgAllowRealName; - if( $wgAllowRealName ) + global $wgHiddenPrefs; + if( !in_array( 'realname', $wgHiddenPrefs ) ) $real = $user->getRealName(); else $real = false; - $skin = $wgUser->getSkin(); + $skin = $user->getSkin(); $page = $user->getUserPage(); - + return $skin->link( $page, htmlspecialchars( $real ? $real : $user->getName() ) ); } @@ -181,12 +181,12 @@ class Credits { * @return String: html */ protected static function userLink( User $user ) { - global $wgUser, $wgAllowRealName; if( $user->isAnon() ){ return wfMsgExt( 'anonymous', array( 'parseinline' ), 1 ); } else { + global $wgHiddenPrefs; $link = self::link( $user ); - if( $wgAllowRealName && $user->getRealName() ) + if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) return $link; else return wfMsgExt( 'siteuser', array( 'parseinline', 'replaceafter' ), $link ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 393ac1df71..79a42db08a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2398,7 +2398,10 @@ $wgValidateAllHtml = false; /** See list of skins and their symbolic names in languages/Language.php */ $wgDefaultSkin = 'monobook'; -/** Should we allow the user's to select their own skin that will override the default? */ +/** +* Should we allow the user's to select their own skin that will override the default? +* @deprecated in 1.16, use $wgHiddenPrefs[] = 'skin' to disable it +*/ $wgAllowUserSkin = true; /** diff --git a/includes/Preferences.php b/includes/Preferences.php index 419aa8c149..3e8f7081c5 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -379,20 +379,17 @@ class Preferences { static function skinPreferences( $user, &$defaultPreferences ) { ## Skin ##################################### - global $wgAllowUserSkin, $wgLang; - - if ($wgAllowUserSkin) { - $defaultPreferences['skin'] = - array( - 'type' => 'radio', - 'options' => self::generateSkinOptions( $user ), - 'label' => ' ', - 'section' => 'rendering/skin', - ); - } + $defaultPreferences['skin'] = + array( + 'type' => 'radio', + 'options' => self::generateSkinOptions( $user ), + 'label' => ' ', + 'section' => 'rendering/skin', + ); $selectedSkin = $user->getOption( 'skin' ); if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) { + global $wgLang; $settings = array_flip($wgLang->getQuickbarSettings()); $defaultPreferences['quickbar'] = @@ -1151,8 +1148,8 @@ class Preferences { } // Fortunately, the realname field is MUCH simpler - global $wgAllowRealName; - if ($wgAllowRealName) { + global $wgHiddenPrefs; + if ( !in_array( 'realname', $wgHiddenPrefs ) ) { $realName = $formData['realname']; $wgUser->setRealName( $realName ); } diff --git a/includes/Setup.php b/includes/Setup.php index 8df3f98300..6df6ac3eef 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -201,12 +201,16 @@ $wgContLanguageCode = $wgLanguageCode; # If file cache or squid cache is on, just disable this (DWIMD). if( $wgUseFileCache || $wgUseSquid ) $wgShowIPinHeader = false; -# $wgAllowRealName was removed in 1.16 in favor of $wgHiddenPrefs, -# handle b/c here +# $wgAllowRealName and $wgAllowUserSkin were removed in 1.16 +# in favor of $wgHiddenPrefs, handle b/c here if( !$wgAllowRealName ) { $wgHiddenPrefs[] = 'realname'; } +if( !$wgAllowUserSkin ) { + $wgHiddenPrefs[] = 'skin'; +} + wfProfileOut( $fname.'-misc1' ); wfProfileIn( $fname.'-memcached' ); diff --git a/includes/User.php b/includes/User.php index d10bc34c43..3085628e55 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2149,16 +2149,18 @@ class User { * @todo FIXME : need to check the old failback system [AV] */ function &getSkin( $t = null ) { - global $wgRequest, $wgAllowUserSkin, $wgDefaultSkin; if ( ! isset( $this->mSkin ) ) { wfProfileIn( __METHOD__ ); - if( $wgAllowUserSkin ) { + global $wgHiddenPrefs; + if( !in_array( 'skin', $wgHiddenPrefs ) ) { # get the user skin + global $wgRequest; $userSkin = $this->getOption( 'skin' ); $userSkin = $wgRequest->getVal('useskin', $userSkin); } else { # if we're not allowing users to override, then use the default + global $wgDefaultSkin; $userSkin = $wgDefaultSkin; } diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 55615a9f76..2c21de68a4 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -44,7 +44,7 @@ class LoginForm { * @param WebRequest $request A WebRequest object passed by reference */ function LoginForm( &$request, $par = '' ) { - global $wgLang, $wgAllowRealName, $wgEnableEmail; + global $wgLang, $wgHiddenPrefs, $wgEnableEmail; global $wgAuth, $wgRedirectOnLogin; $this->mType = ( $par == 'signup' ) ? $par : $request->getText( 'type' ); # Check for [[Special:Userlogin/signup]] @@ -75,7 +75,7 @@ class LoginForm { } else { $this->mEmail = ''; } - if( $wgAllowRealName ) { + if( !in_array( 'realname', $wgHiddenPrefs ) ) { $this->mRealName = $request->getText( 'wpRealName' ); } else { $this->mRealName = ''; @@ -798,7 +798,7 @@ class LoginForm { * @private */ function mainLoginForm( $msg, $msgtype = 'error' ) { - global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail; + global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail; global $wgCookiePrefix, $wgLoginLanguageSelector; global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration; @@ -874,7 +874,7 @@ class LoginForm { $template->set( 'message', $msg ); $template->set( 'messagetype', $msgtype ); $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() ); - $template->set( 'userealname', $wgAllowRealName ); + $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs ) ); $template->set( 'useemail', $wgEnableEmail ); $template->set( 'emailrequired', $wgEmailConfirmToEdit ); $template->set( 'canreset', $wgAuth->allowPasswordChange() ); -- 2.20.1