r25896 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25895‎ | r25896 | r25897 >
Date:19:44, 17 September 2007
Author:brion
Status:old
Tags:
Comment:
* (bug 11355) Fix false positives in Safe Mode and other config detection
when boolean settings are disabled with 'Off' via php_admin_value/php_value
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/config/index.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/install-utils.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1773,6 +1773,37 @@
17741774 }
17751775
17761776 /**
 1777+ * Safety wrapper around ini_get() for boolean settings.
 1778+ * The values returned from ini_get() are pre-normalized for settings
 1779+ * set via php.ini or php_flag/php_admin_flag... but *not*
 1780+ * for those set via php_value/php_admin_value.
 1781+ *
 1782+ * It's fairly common for people to use php_value instead of php_flag,
 1783+ * which can leave you with an 'off' setting giving a false positive
 1784+ * for code that just takes the ini_get() return value as a boolean.
 1785+ *
 1786+ * To make things extra interesting, setting via php_value accepts
 1787+ * "true" as true, but php.ini and php_flag consider it false. :)
 1788+ * Unrecognized values go false... again opposite PHP's own coercion
 1789+ * from string to bool.
 1790+ *
 1791+ * Luckily, 'properly' set settings will always come back as '0' or '1',
 1792+ * so we only have to worry about them and the 'improper' settings.
 1793+ *
 1794+ * I frickin' hate PHP... :P
 1795+ *
 1796+ * @param string $setting
 1797+ * @return bool
 1798+ */
 1799+function wfIniGetBool( $setting ) {
 1800+ $val = ini_get( $setting );
 1801+ // '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';
 1805+}
 1806+
 1807+/**
17771808 * Execute a shell command, with time and memory limits mirrored from the PHP
17781809 * configuration if supported.
17791810 * @param $cmd Command line, properly escaped for shell.
@@ -1783,7 +1814,7 @@
17841815 function wfShellExec( $cmd, &$retval=null ) {
17851816 global $IP, $wgMaxShellMemory, $wgMaxShellFileSize;
17861817
1787 - if( ini_get( 'safe_mode' ) ) {
 1818+ if( wfIniGetBool( 'safe_mode' ) ) {
17881819 wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
17891820 $retval = 1;
17901821 return "Unable to run external programs in safe mode.";
Index: trunk/phase3/includes/Setup.php
@@ -198,7 +198,7 @@
199199
200200 # If session.auto_start is there, we can't touch session name
201201 #
202 -if( !ini_get( 'session.auto_start' ) )
 202+if( !wfIniGetBool( 'session.auto_start' ) )
203203 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
204204
205205 if( !$wgCommandLineMode && ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
Index: trunk/phase3/install-utils.inc
@@ -135,6 +135,6 @@
136136 function mw_have_dl() {
137137 return function_exists( 'dl' )
138138 && is_callable( 'dl' )
139 - && ini_get( 'enable_dl' )
140 - && !ini_get( 'safe_mode' );
 139+ && wfIniGetBool( 'enable_dl' )
 140+ && !wfIniGetBool( 'safe_mode' );
141141 }
\ No newline at end of file
Index: trunk/phase3/config/index.php
@@ -325,7 +325,7 @@
326326 }
327327 print "</li>\n";
328328
329 -if( ini_get( "register_globals" ) ) {
 329+if( wfIniGetBool( "register_globals" ) ) {
330330 ?>
331331 <li>
332332 <div style="font-size:110%">
@@ -339,7 +339,7 @@
340340
341341 $fatal = false;
342342
343 -if( ini_get( "magic_quotes_runtime" ) ) {
 343+if( wfIniGetBool( "magic_quotes_runtime" ) ) {
344344 $fatal = true;
345345 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime</a> is active!</strong>
346346 This option corrupts data input unpredictably; you cannot install or use
@@ -347,7 +347,7 @@
348348 <?php
349349 }
350350
351 -if( ini_get( "magic_quotes_sybase" ) ) {
 351+if( wfIniGetBool( "magic_quotes_sybase" ) ) {
352352 $fatal = true;
353353 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase</a> is active!</strong>
354354 This option corrupts data input unpredictably; you cannot install or use
@@ -355,7 +355,7 @@
356356 <?php
357357 }
358358
359 -if( ini_get( "mbstring.func_overload" ) ) {
 359+if( wfIniGetBool( "mbstring.func_overload" ) ) {
360360 $fatal = true;
361361 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload'>mbstring.func_overload</a> is active!</strong>
362362 This option causes errors and may corrupt data unpredictably;
@@ -363,7 +363,7 @@
364364 <?php
365365 }
366366
367 -if( ini_get( "zend.ze1_compatibility_mode" ) ) {
 367+if( wfIniGetBool( "zend.ze1_compatibility_mode" ) ) {
368368 $fatal = true;
369369 ?><li class="error"><strong>Fatal: <a href="http://www.php.net/manual/en/ini.core.php">zend.ze1_compatibility_mode</a> is active!</strong>
370370 This option causes horrible bugs with MediaWiki; you cannot install or use
@@ -376,7 +376,7 @@
377377 dieout( "</ul><p>Cannot install MediaWiki.</p>" );
378378 }
379379
380 -if( ini_get( "safe_mode" ) ) {
 380+if( wfIniGetBool( "safe_mode" ) ) {
381381 $conf->safeMode = true;
382382 ?>
383383 <li><b class='error'>Warning:</b> <strong>PHP's
@@ -1435,7 +1435,7 @@
14361436 /* -------------------------------------------------------------------------------------- */
14371437 function writeSuccessMessage() {
14381438 $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php';
1439 - if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
 1439+ if ( wfIniGetBool( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
14401440 echo <<<EOT
14411441 <div class="success-box">
14421442 <p>Installation successful!</p>
Index: trunk/phase3/RELEASE-NOTES
@@ -57,8 +57,9 @@
5858 * (bug 11342) Fix several 'returnto' links in permissions/error pages which
5959 linked to the main page instead of targetted page
6060 * Strike the link to the redirect rather than using an asterisk in Special:Listredirects
 61+* (bug 11355) Fix false positives in Safe Mode and other config detection
 62+ when boolean settings are disabled with 'Off' via php_admin_value/php_value
6163
62 -
6364 === API changes in 1.12 ===
6465
6566 Full API documentation is available at http://www.mediawiki.org/wiki/API

Follow-up revisions

RevisionCommit summaryAuthorDate
r25932Merged revisions 25861-25931 via svnmerge from...david06:43, 19 September 2007

Status & tagging log