r73809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73808‎ | r73809 | r73810 >
Date:14:24, 27 September 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Fix a bunch of '? true : false' instances
Modified paths:
  • /trunk/phase3/includes/Autopromote.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialAllmessages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -1179,7 +1179,7 @@
11801180 . "AND c.relkind IN ('" . implode( "','", $types ) . "')";
11811181 $res = $this->query( $SQL );
11821182 $count = $res ? $res->numRows() : 0;
1183 - return $count ? true : false;
 1183+ return (bool)$count;
11841184 }
11851185
11861186 /**
Index: trunk/phase3/includes/installer/WebInstallerPage.php
@@ -487,7 +487,7 @@
488488 // Title-style validation
489489 $title = Title::newFromText( $name );
490490 if ( !$title ) {
491 - $good = $nsType == 'site-name' ? true : false;
 491+ $good = $nsType == 'site-name';
492492 } else {
493493 $name = $title->getDBkey();
494494 $good = true;
Index: trunk/phase3/includes/WebRequest.php
@@ -345,7 +345,7 @@
346346 * @return Boolean
347347 */
348348 public function getBool( $name, $default = false ) {
349 - return $this->getVal( $name, $default ) ? true : false;
 349+ return (bool)$this->getVal( $name, $default );
350350 }
351351
352352 /**
Index: trunk/phase3/includes/SkinTemplate.php
@@ -659,7 +659,7 @@
660660 self::checkTitle( $title, $name );
661661 return array(
662662 'href' => $title->getLocalURL( $urlaction ),
663 - 'exists' => $title->getArticleID() != 0 ? true : false
 663+ 'exists' => $title->getArticleID() != 0,
664664 );
665665 }
666666
@@ -669,7 +669,7 @@
670670 self::checkTitle( $title, $name );
671671 return array(
672672 'href' => $title->getLocalURL( $urlaction ),
673 - 'exists' => $title->getArticleID() != 0 ? true : false
 673+ 'exists' => $title->getArticleID() != 0,
674674 );
675675 }
676676
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -346,9 +346,9 @@
347347
348348 $f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
349349 Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
350 - 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ? true : false ) . '<br />' .
 350+ 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ) . '<br />' .
351351 Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
352 - 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ? true : false ) . ' ' .
 352+ 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ) . ' ' .
353353 Html::input( 'target', $this->opts['target'], 'text', array(
354354 'size' => '20',
355355 'required' => ''
Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -188,7 +188,7 @@
189189 list( $show, $value ) = explode( ':', $option );
190190 $show = htmlspecialchars( $show );
191191 $value = htmlspecialchars( $value );
192 - $blockExpiryFormOptions .= Xml::option( $show, $value, $this->BlockExpiry === $value ? true : false ) . "\n";
 192+ $blockExpiryFormOptions .= Xml::option( $show, $value, $this->BlockExpiry === $value ) . "\n";
193193 }
194194
195195 $reasonDropDown = Xml::listDropDown( 'wpBlockReasonList',
Index: trunk/phase3/includes/specials/SpecialAllmessages.php
@@ -100,19 +100,19 @@
101101 'filter',
102102 'unmodified',
103103 'mw-allmessages-form-filter-unmodified',
104 - ( $this->filter == 'unmodified' ? true : false )
 104+ ( $this->filter == 'unmodified' )
105105 ) .
106106 Xml::radioLabel( wfMsg( 'allmessages-filter-all' ),
107107 'filter',
108108 'all',
109109 'mw-allmessages-form-filter-all',
110 - ( $this->filter == 'all' ? true : false )
 110+ ( $this->filter == 'all' )
111111 ) .
112112 Xml::radioLabel( wfMsg( 'allmessages-filter-modified' ),
113113 'filter',
114114 'modified',
115115 'mw-allmessages-form-filter-modified',
116 - ( $this->filter == 'modified' ? true : false )
 116+ ( $this->filter == 'modified' )
117117 ) .
118118 "</td>\n
119119 </tr>
@@ -124,7 +124,7 @@
125125 Xml::openElement( 'select', array( 'id' => 'mw-allmessages-form-lang', 'name' => 'lang' ) );
126126
127127 foreach( $languages as $lang => $name ) {
128 - $selected = $lang == $this->langCode ? true : false;
 128+ $selected = $lang == $this->langCode;
129129 $out .= Xml::option( $lang . ' - ' . $name, $lang, $selected ) . "\n";
130130 }
131131 $out .= Xml::closeElement( 'select' ) .
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -67,7 +67,7 @@
6868 if( empty( $this->namespaces ) ) {
6969 $this->namespaces = SearchEngine::userNamespaces( $user );
7070 }
71 - $this->searchRedirects = $request->getcheck( 'redirs' ) ? true : false;
 71+ $this->searchRedirects = $request->getCheck( 'redirs' );
7272 $this->searchAdvanced = $request->getVal( 'advanced' );
7373 $this->active = 'advanced';
7474 $this->sk = $user->getSkin();
Index: trunk/phase3/includes/Autopromote.php
@@ -143,7 +143,7 @@
144144 throw new MWException( "Unrecognized condition {$cond[0]} for autopromotion!" );
145145 }
146146
147 - return $result ? true : false;
 147+ return (bool)$result;
148148 }
149149 }
150150 }
Index: trunk/phase3/includes/Skin.php
@@ -2046,7 +2046,7 @@
20472047
20482048 return array(
20492049 'href' => $title->getLocalURL( $urlaction ),
2050 - 'exists' => $title->getArticleID() != 0 ? true : false
 2050+ 'exists' => $title->getArticleID() != 0;
20512051 );
20522052 }
20532053

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   15:59, 27 September 2010

Oops - that semi-colon should be a comma...

#Comment by Trevor Parscal (WMF) (talk | contribs)   16:01, 27 September 2010

r73816 fixes this up.

#Comment by 😂 (talk | contribs)   16:38, 27 September 2010

Save fail...had the fix for that :P

Status & tagging log