r74156 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74155‎ | r74156 | r74157 >
Date:21:35, 2 October 2010
Author:bawolff
Status:ok (Comments)
Tags:
Comment:
follow-up r74150 - empty() == bad.
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Preferences.php
@@ -1107,7 +1107,8 @@
11081108 $wgLang->formatNum( $wgMaxSigChars )
11091109 )
11101110 );
1111 - } elseif ( !empty( $alldata['fancysig'] ) &&
 1111+ } elseif ( isset( $alldata['fancysig'] ) &&
 1112+ $alldata['fancysig'] &&
11121113 false === $wgParser->validateSig( $signature ) ) {
11131114 return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) );
11141115 } else {
@@ -1117,7 +1118,7 @@
11181119
11191120 static function cleanSignature( $signature, $alldata ) {
11201121 global $wgParser;
1121 - if ( !empty( $alldata['fancysig'] ) ) {
 1122+ if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
11221123 $signature = $wgParser->cleanSig( $signature );
11231124 } else {
11241125 // When no fancy sig used, make sure ~{3,5} get removed.

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74150Fix undefined variable notice if $wgHiddenPrefs[] = 'fancysig'....bawolff20:36, 2 October 2010

Comments

#Comment by Brion VIBBER (talk | contribs)   23:58, 2 October 2010

Note that '!empty($foo)' should be exactly the same as 'isset($foo) && $foo', but it ain't a bad idea to avoid empty, since it's behavior often isn't quite what folks expect it to be. :)

Status & tagging log