diff --git a/admin/settings/server.php b/admin/settings/server.php index 85e3f2dc6c3..3a58d34479e 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -175,16 +175,25 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo // "performance" settingpage $temp = new admin_settingpage('performance', new lang_string('performance', 'admin')); +// Memory limit options for large administration tasks. +$memoryoptions = array( + '64M' => '64M', + '128M' => '128M', + '256M' => '256M', + '512M' => '512M', + '1024M' => '1024M', + '2048M' => '2048M'); + +// Allow larger memory usage for 64-bit sites only. +if (PHP_INT_SIZE === 8) { + $memoryoptions['3072M'] = '3072M'; + $memoryoptions['4096M'] = '4096M'; +} + $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'), new lang_string('configextramemorylimit', 'admin'), '512M', - // if this option is set to 0, default 128M will be used - array( '64M' => '64M', - '128M' => '128M', - '256M' => '256M', - '512M' => '512M', - '1024M' => '1024M', - '2048M' => '2048M', - ))); + $memoryoptions)); + $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'), new lang_string('configcurlcache', 'admin'), 120, PARAM_INT)); diff --git a/backup/backup.php b/backup/backup.php index 2847665f4fa..cfe16efb364 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -79,6 +79,10 @@ switch ($type) { print_error('unknownbackuptype'); } +// Backup of large courses requires extra memory. Use the amount configured +// in admin settings. +raise_memory_limit(MEMORY_EXTRA); + if (!($bc = backup_ui::load_controller($backupid))) { $bc = new backup_controller($type, $id, backup::FORMAT_MOODLE, backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id); diff --git a/backup/restore.php b/backup/restore.php index 6091c092bbc..cd51caebdeb 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -17,6 +17,10 @@ $PAGE->set_pagelayout('standard'); require_login($course, null, $cm); require_capability('moodle/restore:restorecourse', $context); +// Restore of large courses requires extra memory. Use the amount configured +// in admin settings. +raise_memory_limit(MEMORY_EXTRA); + if ($stage & restore_ui::STAGE_CONFIRM + restore_ui::STAGE_DESTINATION) { $restore = restore_ui::engage_independent_stage($stage, $contextid); } else { diff --git a/lib/setuplib.php b/lib/setuplib.php index a74a1d34c45..2de85e5b0a5 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -1026,7 +1026,14 @@ function raise_memory_limit($newlimit) { } } else if ($newlimit == MEMORY_HUGE) { + // MEMORY_HUGE uses 2G or MEMORY_EXTRA, whichever is bigger. $newlimit = get_real_size('2G'); + if (!empty($CFG->extramemorylimit)) { + $extra = get_real_size($CFG->extramemorylimit); + if ($extra > $newlimit) { + $newlimit = $extra; + } + } } else { $newlimit = get_real_size($newlimit);