r35134 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35133‎ | r35134 | r35135 >
Date:05:45, 21 May 2008
Author:aaron
Status:old
Tags:
Comment:
* validateIntOrNull() returns null for empty input
* NULL options become the defaults if saved (bug 14100)
Modified paths:
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1730,9 +1730,16 @@
17311731 }
17321732 // Filter out any newlines that may have passed through input validation.
17331733 // Newlines are used to separate items in the options blob.
1734 - $val = str_replace( "\r\n", "\n", $val );
1735 - $val = str_replace( "\r", "\n", $val );
1736 - $val = str_replace( "\n", " ", $val );
 1734+ if( $val ) {
 1735+ $val = str_replace( "\r\n", "\n", $val );
 1736+ $val = str_replace( "\r", "\n", $val );
 1737+ $val = str_replace( "\n", " ", $val );
 1738+ }
 1739+ // Explicitly NULL values should refer to defaults
 1740+ global $wgDefaultUserOptions;
 1741+ if( is_null($val) && isset($wgDefaultUserOptions[$oname]) ) {
 1742+ $val = $wgDefaultUserOptions[$oname];
 1743+ }
17371744 $this->mOptions[$oname] = $val;
17381745 }
17391746
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -151,7 +151,7 @@
152152 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
153153 $val = trim($val);
154154 if($val === '') {
155 - return $val;
 155+ return null;
156156 } else {
157157 return $this->validateInt( $val, $min, $max );
158158 }

Status & tagging log