Simplify message existence checks by using wfMessage() instead of wfEmptyMsg()
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 24 May 2011 17:28:21 +0000 (17:28 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 24 May 2011 17:28:21 +0000 (17:28 +0000)
includes/HTMLForm.php
includes/User.php

index 44669df..ea6fe05 100644 (file)
@@ -973,23 +973,20 @@ abstract class HTMLFormField {
                $helptext = null;
 
                if ( isset( $this->mParams['help-message'] ) ) {
-                       $msg = $this->mParams['help-message'];
-                       $helptext = wfMsgExt( $msg, 'parseinline' );
-                       if ( wfEmptyMsg( $msg ) ) {
-                               # Never mind
-                               $helptext = null;
+                       $msg = wfMessage( $this->mParams['help-message'] );
+                       if ( $msg->exists() ) {
+                               $helptext = $msg->parse();
                        }
                } elseif ( isset( $this->mParams['help-messages'] ) ) {
                        # help-message can be passed a message key (string) or an array containing
                        # a message key and additional parameters. This makes it impossible to pass
                        # an array of message key
-                       foreach( $this->mParams['help-messages'] as $msg ) {
-                               $candidate = wfMsgExt( $msg, 'parseinline' );
-                               if( wfEmptyMsg( $msg ) ) {
-                                       $candidate = null;
+                       foreach( $this->mParams['help-messages'] as $name ) {
+                               $msg = wfMessage( $name );
+                               if( $msg->exists() ) {
+                                       $helptext .= $msg->parse(); // append message
                                }
-                               $helptext .= $candidate; // append message
-                       }       
+                       }
                } elseif ( isset( $this->mParams['help'] ) ) {
                        $helptext = $this->mParams['help'];
                }
index 186072c..20946f5 100644 (file)
@@ -3610,10 +3610,8 @@ class User {
         */
        static function getRightDescription( $right ) {
                $key = "right-$right";
-               $name = wfMsg( $key );
-               return $name == '' || wfEmptyMsg( $key )
-                       ? $right
-                       : $name;
+               $msg = wfMessage( $key );
+               return $msg->isBlank() ? $right : $msg->text();
        }
 
        /**