r26165 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26164‎ | r26165 | r26166 >
Date:17:59, 26 September 2007
Author:brion
Status:old
Tags:
Comment:
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)
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1783,7 +1783,7 @@
17841784 * for code that just takes the ini_get() return value as a boolean.
17851785 *
17861786 * To make things extra interesting, setting via php_value accepts
1787 - * "true" as true, but php.ini and php_flag consider it false. :)
 1787+ * "true" and "yes" as true, but php.ini and php_flag consider them false. :)
17881788 * Unrecognized values go false... again opposite PHP's own coercion
17891789 * from string to bool.
17901790 *
@@ -1798,9 +1798,10 @@
17991799 function wfIniGetBool( $setting ) {
18001800 $val = ini_get( $setting );
18011801 // 'on' and 'true' can't have whitespace around them, but '1' can.
1802 - return trim( $val ) == '1'
1803 - || strtolower( $val ) == 'on'
1804 - || strtolower( $val ) == 'true';
 1802+ return strtolower( $val ) == 'on'
 1803+ || strtolower( $val ) == 'true'
 1804+ || strtolower( $val ) == 'yes'
 1805+ || preg_match( "/^\s*[+-]?0*[1-9]/", $val ); // approx C atoi() function
18051806 }
18061807
18071808 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r26257Merged revisions 26134-26247 via svnmerge from...david19:06, 30 September 2007

Status & tagging log