r74150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74149‎ | r74150 | r74151 >
Date:20:36, 2 October 2010
Author:bawolff
Status:resolved (Comments)
Tags:
Comment:
Fix undefined variable notice if $wgHiddenPrefs[] = 'fancysig'.

Use !empty($blah) since that is what the rest of the code is doing. This does
not change the behaviour in any way, only gets rid of the warning. Issue
discovered by jorenl on irc.
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Preferences.php
@@ -1117,7 +1117,7 @@
11181118
11191119 static function cleanSignature( $signature, $alldata ) {
11201120 global $wgParser;
1121 - if ( $alldata['fancysig'] ) {
 1121+ if ( !empty( $alldata['fancysig'] ) ) {
11221122 $signature = $wgParser->cleanSig( $signature );
11231123 } else {
11241124 // When no fancy sig used, make sure ~{3,5} get removed.

Follow-up revisions

RevisionCommit summaryAuthorDate
r74156follow-up r74150 - empty() == bad.bawolff21:35, 2 October 2010

Comments

#Comment by 😂 (talk | contribs)   21:13, 2 October 2010

Do not use empty, it silently suppresses errors. Use isset() instead.

#Comment by Bawolff (talk | contribs)   21:21, 2 October 2010

Ok. Should I change the other instances of empty() in Preferences.php too? I mainly used it because thats the way the rest of the code looked.

#Comment by 😂 (talk | contribs)   21:27, 2 October 2010

Probably couldn't hurt. Per the code guide: "empty() is inverted conversion to boolean with error suppression. Only use it when you really want to suppress errors..."

#Comment by Bawolff (talk | contribs)   21:40, 2 October 2010

hmm, I guess it wasn't really used all over the place, just in the one place I looked. Fixed in r74156, so resetting the status of this revision back to new.

Status & tagging log