Merge "Log to DBPerformance log when many LB connections are acquired"
[lhc/web/wiklou.git] / includes / actions / CreditsAction.php
index dd5195d..c19e8fa 100644 (file)
@@ -42,7 +42,6 @@ class CreditsAction extends FormlessAction {
         * @return string HTML
         */
        public function onView() {
-               wfProfileIn( __METHOD__ );
 
                if ( $this->page->getID() == 0 ) {
                        $s = $this->msg( 'nocredits' )->parse();
@@ -50,8 +49,6 @@ class CreditsAction extends FormlessAction {
                        $s = $this->getCredits( -1 );
                }
 
-               wfProfileOut( __METHOD__ );
-
                return Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $s );
        }
 
@@ -63,7 +60,6 @@ class CreditsAction extends FormlessAction {
         * @return string Html
         */
        public function getCredits( $cnt, $showIfMax = true ) {
-               wfProfileIn( __METHOD__ );
                $s = '';
 
                if ( $cnt != 0 ) {
@@ -73,8 +69,6 @@ class CreditsAction extends FormlessAction {
                        }
                }
 
-               wfProfileOut( __METHOD__ );
-
                return $s;
        }
 
@@ -100,6 +94,17 @@ class CreditsAction extends FormlessAction {
                        $this->userLink( $user ) )->params( $user->getName() )->escaped();
        }
 
+       /**
+        * Whether we can display the user's real name (not a hidden pref)
+        *
+        * @since 1.24
+        * @return bool
+        */
+       protected function canShowRealUserName() {
+               $hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' );
+               return !in_array( 'realname', $hiddenPrefs );
+       }
+
        /**
         * Get a list of contributors of $article
         * @param int $cnt Maximum list of contributors to show
@@ -107,8 +112,6 @@ class CreditsAction extends FormlessAction {
         * @return string Html
         */
        protected function getContributors( $cnt, $showIfMax ) {
-               global $wgHiddenPrefs;
-
                $contributors = $this->page->getContributors();
 
                $others_link = false;
@@ -132,7 +135,7 @@ class CreditsAction extends FormlessAction {
                        $cnt--;
                        if ( $user->isLoggedIn() ) {
                                $link = $this->link( $user );
-                               if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
+                               if ( $this->canShowRealUserName() && $user->getRealName() ) {
                                        $real_names[] = $link;
                                } else {
                                        $user_names[] = $link;
@@ -192,8 +195,7 @@ class CreditsAction extends FormlessAction {
         * @return string Html
         */
        protected function link( User $user ) {
-               global $wgHiddenPrefs;
-               if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) {
+               if ( $this->canShowRealUserName() && !$user->isAnon() ) {
                        $real = $user->getRealName();
                } else {
                        $real = false;
@@ -216,8 +218,7 @@ class CreditsAction extends FormlessAction {
                if ( $user->isAnon() ) {
                        return $this->msg( 'anonuser' )->rawParams( $link )->parse();
                } else {
-                       global $wgHiddenPrefs;
-                       if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
+                       if ( $this->canShowRealUserName() && $user->getRealName() ) {
                                return $link;
                        } else {
                                return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();