Commit 817d460f authored by Robert Lyon's avatar Robert Lyon
Browse files

Increasing max execution time for install (Bug #1318430)



To allow for systems where the installation takes longer than their
phpini max_execution_time setting.

Made the changing of the limit pass thru a function for sanity checking

Change-Id: I0d27d68a377c338c634f2f845829682af149d79f
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 2f466feb
...@@ -26,7 +26,8 @@ if (!$install) { ...@@ -26,7 +26,8 @@ if (!$install) {
auth_setup(); auth_setup();
} }
} }
raise_time_limit(120);
raise_memory_limit('256M');
$data = array( $data = array(
'key' => $name 'key' => $name
); );
......
...@@ -121,6 +121,8 @@ $localsuccess = json_encode(get_string('localdatasuccess', 'admin')); ...@@ -121,6 +121,8 @@ $localsuccess = json_encode(get_string('localdatasuccess', 'admin'));
// Check if Mahara is being installed. An extra hook is required to insert core // Check if Mahara is being installed. An extra hook is required to insert core
// data if so. // data if so.
if (!empty($upgrades['core']->install)) { if (!empty($upgrades['core']->install)) {
raise_time_limit(120);
raise_memory_limit('256M');
$upgrades['firstcoredata'] = true; $upgrades['firstcoredata'] = true;
$upgrades['localpreinst'] = true; $upgrades['localpreinst'] = true;
$upgrades['lastcoredata'] = true; $upgrades['lastcoredata'] = true;
......
...@@ -270,7 +270,7 @@ function adduser_submit(Pieform $form, $values) { ...@@ -270,7 +270,7 @@ function adduser_submit(Pieform $form, $values) {
global $USER, $SESSION, $TRANSPORTER; global $USER, $SESSION, $TRANSPORTER;
db_begin(); db_begin();
ini_set('max_execution_time', 180); raise_time_limit(180);
// Create user // Create user
$user = (object)array( $user = (object)array(
......
...@@ -15,7 +15,7 @@ define('BULKEXPORT', 1); ...@@ -15,7 +15,7 @@ define('BULKEXPORT', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php'); require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('docroot') . '/lib/htmloutput.php'); require_once(get_config('docroot') . '/lib/htmloutput.php');
raise_memory_limit("1024M"); raise_memory_limit("1024M");
ini_set('max_execution_time', 300); // 5 minutes raise_time_limit(300);
// Download the export file if it's been generated // Download the export file if it's been generated
if ($exportfile = $SESSION->get('exportfile')) { if ($exportfile = $SESSION->get('exportfile')) {
......
...@@ -13,7 +13,7 @@ defined('INTERNAL') || die(); ...@@ -13,7 +13,7 @@ defined('INTERNAL') || die();
function xmldb_core_upgrade($oldversion=0) { function xmldb_core_upgrade($oldversion=0) {
global $SESSION; global $SESSION;
ini_set('max_execution_time', 120); // Let's be safe raise_time_limit(120);
raise_memory_limit('256M'); raise_memory_limit('256M');
$status = true; $status = true;
......
...@@ -2597,6 +2597,37 @@ function raise_memory_limit ($newlimit) { ...@@ -2597,6 +2597,37 @@ function raise_memory_limit ($newlimit) {
return false; return false;
} }
/**
* Function to raise the max execution time to a new value.
* Will respect the time limit if it is higher, thus allowing
* settings in php.ini, apache conf or command line switches
* to override it
*
* @param int $newlimit the new max execution time limit (in seconds)
* @return bool Whether we were able to raise the limit or not
*/
function raise_time_limit($newlimit) {
if (empty($newlimit)) {
return false;
}
$newlimit = intval($newlimit);
$cur = @ini_get('max_execution_time');
if (empty($cur)) {
$cur = 0;
}
// Currently set as umlimited so don't change
if ($cur == '0') {
return false;
}
if ($newlimit > $cur) {
// this won't work in safe mode - but we shouldn't be in safe mode
// as that has been checked for already
ini_set('max_execution_time', $newlimit);
return true;
}
return false;
}
/** /**
* Converts numbers like 10M into bytes. * Converts numbers like 10M into bytes.
* *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment