From: Brion Vibber Date: Wed, 26 Sep 2007 17:59:29 +0000 (+0000) Subject: Make wfIniGetBool() more accurate: X-Git-Tag: 1.31.0-rc.0~51278 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=1a45c87c478847e11e3e78cf89a9df7227bf246e;p=lhc%2Fweb%2Fwiklou.git Make wfIniGetBool() more accurate: * accepts 'yes' as well as 'on' and 'true' * accepts negative and non-1 integers, as well as garbage characters after the number (as C atoi() function for nonzero result) --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a67972ded0..b216eca9b3 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1783,7 +1783,7 @@ function wfUrlProtocols() { * for code that just takes the ini_get() return value as a boolean. * * To make things extra interesting, setting via php_value accepts - * "true" as true, but php.ini and php_flag consider it false. :) + * "true" and "yes" as true, but php.ini and php_flag consider them false. :) * Unrecognized values go false... again opposite PHP's own coercion * from string to bool. * @@ -1798,9 +1798,10 @@ function wfUrlProtocols() { function wfIniGetBool( $setting ) { $val = ini_get( $setting ); // 'on' and 'true' can't have whitespace around them, but '1' can. - return trim( $val ) == '1' - || strtolower( $val ) == 'on' - || strtolower( $val ) == 'true'; + return strtolower( $val ) == 'on' + || strtolower( $val ) == 'true' + || strtolower( $val ) == 'yes' + || preg_match( "/^\s*[+-]?0*[1-9]/", $val ); // approx C atoi() function } /**