r75402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75401‎ | r75402 | r75403 >
Date:23:49, 25 October 2010
Author:brion
Status:ok (Comments)
Tags:
Comment:
Followup for r75314 (bug 23923) -- regression fix for prefix of '0' being ignored since r75314

Don't forget that the string '0' evaluates to false in boolean context!
Modified paths:
  • /trunk/phase3/includes/specials/SpecialPrefixindex.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialPrefixindex.php
@@ -56,9 +56,9 @@
5757
5858 if( isset( $par ) ){
5959 $this->showPrefixChunk( $namespace, $par, $from );
60 - } elseif( $prefix ){
 60+ } elseif( $prefix != '' ){
6161 $this->showPrefixChunk( $namespace, $prefix, $from );
62 - } elseif( $from ){
 62+ } elseif( $from != '' ){
6363 $this->showPrefixChunk( $namespace, $from, $from );
6464 } else {
6565 $wgOut->addHTML( $this->namespacePrefixForm( $namespace, null ) );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75314(bug 23923) Special:Prefixindex no longer shows results if nothing was reques...btongminh15:33, 24 October 2010

Comments

#Comment by Nikerabbit (talk | contribs)   11:41, 26 October 2010

This would still break with number 0, although it is unlikely that it would ever end up in here. I would use !== here just because I can.

#Comment by Brion VIBBER (talk | contribs)   20:10, 26 October 2010

getVal will always return a string or null, and the default empty string prevents null. There's no valid way to end up with an int 0 in there. Do feel free to change to !== if you like, though, as a coding standards thing.

#Comment by Krinkle (talk | contribs)   19:11, 1 May 2011
Don't forget that the string '0' evaluates to false in boolean context!

It does ? I thought 0 would only return as false (as a string) when used with empty()

http://codepad.org/BdLgET8S

Status & tagging log