r88727 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88726‎ | r88727 | r88728 >
Date:17:28, 24 May 2011
Author:ialex
Status:ok
Tags:
Comment:
Simplify message existence checks by using wfMessage() instead of wfEmptyMsg()
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -3610,10 +3610,8 @@
36113611 */
36123612 static function getRightDescription( $right ) {
36133613 $key = "right-$right";
3614 - $name = wfMsg( $key );
3615 - return $name == '' || wfEmptyMsg( $key )
3616 - ? $right
3617 - : $name;
 3614+ $msg = wfMessage( $key );
 3615+ return $msg->isBlank() ? $right : $msg->text();
36183616 }
36193617
36203618 /**
Index: trunk/phase3/includes/HTMLForm.php
@@ -973,23 +973,20 @@
974974 $helptext = null;
975975
976976 if ( isset( $this->mParams['help-message'] ) ) {
977 - $msg = $this->mParams['help-message'];
978 - $helptext = wfMsgExt( $msg, 'parseinline' );
979 - if ( wfEmptyMsg( $msg ) ) {
980 - # Never mind
981 - $helptext = null;
 977+ $msg = wfMessage( $this->mParams['help-message'] );
 978+ if ( $msg->exists() ) {
 979+ $helptext = $msg->parse();
982980 }
983981 } elseif ( isset( $this->mParams['help-messages'] ) ) {
984982 # help-message can be passed a message key (string) or an array containing
985983 # a message key and additional parameters. This makes it impossible to pass
986984 # an array of message key
987 - foreach( $this->mParams['help-messages'] as $msg ) {
988 - $candidate = wfMsgExt( $msg, 'parseinline' );
989 - if( wfEmptyMsg( $msg ) ) {
990 - $candidate = null;
 985+ foreach( $this->mParams['help-messages'] as $name ) {
 986+ $msg = wfMessage( $name );
 987+ if( $msg->exists() ) {
 988+ $helptext .= $msg->parse(); // append message
991989 }
992 - $helptext .= $candidate; // append message
993 - }
 990+ }
994991 } elseif ( isset( $this->mParams['help'] ) ) {
995992 $helptext = $this->mParams['help'];
996993 }

Sign-offs

UserFlagDate
Hasharinspected19:55, 2 June 2011

Status & tagging log