Example #1
0
	function setUp() {
		$this->origMemLimit = ini_get('memory_limit');
		$this->origTimeLimit = ini_get('max_execution_time');
		$this->origMemLimitMax = get_increase_memory_limit_max();
		$this->origTimeLimitMax = get_increase_time_limit_max();
		set_increase_memory_limit_max(-1);
		set_increase_time_limit_max(-1);
	}
Example #2
0
/**
 * Increase the time limit of this script. By default, the time will be unlimited.
 * Only works if 'safe_mode' is off in the PHP configuration.
 * Only values up to {@link get_increase_time_limit_max()} are allowed.
 * 
 * @param $timeLimit The time limit in seconds.  If omitted, no time limit will be set.
 * @return Boolean TRUE indicates a successful change, FALSE a denied change.
 */
function increase_time_limit_to($timeLimit = null)
{
    $max = get_increase_time_limit_max();
    if ($max != -1 && $timeLimit > $max) {
        return false;
    }
    if (!ini_get('safe_mode')) {
        if (!$timeLimit) {
            set_time_limit(0);
            return true;
        } else {
            $currTimeLimit = ini_get('max_execution_time');
            // Only increase if its smaller
            if ($currTimeLimit && $currTimeLimit < $timeLimit) {
                set_time_limit($timeLimit);
            }
            return true;
        }
    } else {
        return false;
    }
}