From d9fc810c9e293ac23dae1897a455488591406a18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 20 Jul 2005 03:30:44 +0000 Subject: [PATCH] * Added a validateDate() function, the date preference option is somtimes not an integer and this was causing an error that made the DateFormatter.php not work for ISO 8601 dates. --- includes/SpecialPreferences.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 4616fcc025..066db60ae5 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -121,8 +121,7 @@ class PreferencesForm { $this->mainPrefsForm( '' ); } } - - /** + /** * @access private */ function validateInt( &$val, $min=0, $max=0x7fffffff ) { @@ -144,6 +143,16 @@ class PreferencesForm { } } + /** + * @access private + */ + function validateDate( &$val, $min = 0, $max = 0, $max=0x7fffffff ) { + if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) || $val == 'ISO 8601' ) + return $val; + else + return 0; + } + /** * Used to validate the user inputed timezone before saving it as * 'timeciorrection', will return '00:00' if fed bogus data. @@ -217,7 +226,7 @@ class PreferencesForm { if( $wgUseTeX ) { $wgUser->setOption( 'math', $this->mMath ); } - $wgUser->setOption( 'date', $this->validateInt( $this->mDate, 0, 10 ) ); + $wgUser->setOption( 'date', $this->validateDate( $this->mDate, 0, 10 ) ); $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) ); $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) ); $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) ); -- 2.20.1