Page MenuHomePhabricator

safe_mode check broken (fix inside)
Closed, ResolvedPublic


Author: philipp.gruber

In my wiki, when generating thumbnails, I got an error which said, that it can't generate thumbnails because safe_mode was on, although I disabled safe_mode.

After searching in the code, I found the followig:

if( ini_get( 'safe_mode' )) {
    wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
    $retval = 1;
    return "Unable to run external programs in safe mode.";

The problem here is, that the if only checks wether the variable safe_mode is set. In my case, it was actually set, but the value is 'Off'.

Then I changed it to

if( ini_get( 'safe_mode' ) && ini_get('safe_mode') != 'Off') {

And now it works fine. It's not a nice solution, but it works for me. Not sure wether it is neccessary to check also for 'off', '0', 'false', etc.



Version: 1.11.x
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:00 PM
bzimport set Reference to bz11355.
bzimport added a subscriber: Unknown Object (MLST).

Fixed in r25896.

The problem seems to be that PHP is a bit inconsistent about what it returns for these settings; when they're set via php_value or php_admin_value in the Apache configuration, it returns the original string instead of the boolean value, while normally they're normalized to '0' or '1' based on the interpretation of the php.ini or php_flag / php_admin_flag setting.

This gets confusing because the way it interprets the strings is different from how PHP coerces strings into boolean values. I've attempted to replicate this in a new wfIniGetBool() wrapper, which in my quick testing seems to match.