Commit 3ef7279f authored by sam marshall's avatar sam marshall
Browse files

MDL-42084 Core: Change set_time_limit to core_php_time_limit::raise everywhere

Exceptions (places where set_time_limit is still left) are:

Third-party libraries:
  ADODB
  PHPMailer

Moodle core:
  PHPUnit - not relevant (CLI mode)
parent 6edd90cc
......@@ -108,7 +108,7 @@ switch ($action) {
echo $OUTPUT->header();
// This may take a long time.
set_time_limit(0);
core_php_time_limit::raise();
// Disable plugin to prevent concurrent cron execution.
unset($enabled[$enrol]);
......
......@@ -55,7 +55,7 @@ if ($action === 'checkout') {
$progressbar->create(); // prints the HTML code of the progress bar
// we may need a bit of extra execution time and memory here
@set_time_limit(HOURSECS);
core_php_time_limit::raise(HOURSECS);
raise_memory_limit(MEMORY_EXTRA);
tool_customlang_utils::checkout($lng, $progressbar);
......
......@@ -50,7 +50,7 @@ require_once($CFG->libdir.'/dtllib.php');
* @return does not return, calls die()
*/
function tool_dbtransfer_export_xml_database($description, $mdb) {
@set_time_limit(0);
core_php_time_limit::raise();
\core\session\manager::write_close(); // Release session.
......@@ -77,7 +77,7 @@ function tool_dbtransfer_export_xml_database($description, $mdb) {
* @return void
*/
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null) {
@set_time_limit(0);
core_php_time_limit::raise();
\core\session\manager::write_close(); // Release session.
......
......@@ -177,7 +177,7 @@ abstract class tool_generator_backend {
// Update time limit so PHP doesn't time out.
if (!CLI_SCRIPT) {
set_time_limit(120);
core_php_time_limit::raise(120);
}
}
......
......@@ -57,7 +57,7 @@ if (data_submitted() and $confirm and confirm_sesskey()) {
echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
set_time_limit(0);
core_php_time_limit::raise();
foreach ($rs as $table) {
$DB->set_debug(true);
......
......@@ -69,7 +69,7 @@ $notice_ok = array();
$notice_error = array();
if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($pack)) {
set_time_limit(0);
core_php_time_limit::raise();
make_temp_directory('');
make_upload_directory('lang');
......@@ -125,7 +125,7 @@ if ($mode == DELETION_OF_SELECTED_LANG and !empty($uninstalllang)) {
}
if ($mode == UPDATE_ALL_LANG) {
set_time_limit(0);
core_php_time_limit::raise();
$installer = new lang_installer();
......
......@@ -59,7 +59,7 @@ echo $OUTPUT->box_start();
/// Turn off time limits, sometimes upgrades can be slow.
@set_time_limit(0);
core_php_time_limit::raise();
echo '<strong>Progress:</strong>';
$i = 0;
......
......@@ -38,7 +38,7 @@ if (!$CFG->debugdeveloper) {
error('Not available on production sites, sorry.');
}
set_time_limit(60*30);
core_php_time_limit::raise(60*30);
$oldcwd = getcwd();
$code = 0;
......
......@@ -195,7 +195,7 @@ class tool_uploadcourse_processor {
$errors = 0;
// We will most certainly need extra time and memory to process big files.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Loop over the CSV lines.
......@@ -335,7 +335,7 @@ class tool_uploadcourse_processor {
$tracker->start();
// We might need extra time and memory depending on the number of rows to preview.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Loop over the CSV lines.
......
......@@ -36,7 +36,7 @@ require_once('user_form.php');
$iid = optional_param('iid', '', PARAM_INT);
$previewrows = optional_param('previewrows', 10, PARAM_INT);
@set_time_limit(60*60); // 1 hour should be enough
core_php_time_limit::raise(60*60); // 1 hour should be enough
raise_memory_limit(MEMORY_HUGE);
require_login();
......
......@@ -72,7 +72,7 @@ if ($formdata = $mform->get_data()) {
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Create a unique temporary directory, to process the zip file
......
......@@ -307,7 +307,7 @@ class backup_controller extends base_controller {
*/
public function execute_plan() {
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
// If this is not a course backup, inform the plan we are not
// including all the activities for sure. This will affect any
......
......@@ -315,7 +315,7 @@ class restore_controller extends base_controller {
public function execute_plan() {
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
// If this is not a course restore, inform the plan we are not
// including all the activities for sure. This will affect any
......@@ -349,7 +349,7 @@ class restore_controller extends base_controller {
throw new restore_controller_exception('cannot_precheck_wrong_status', $this->status);
}
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
$this->precheck = restore_prechecks_helper::execute_prechecks($this, $droptemptablesafter);
if (!array_key_exists('errors', $this->precheck)) { // No errors, can be executed
......@@ -420,7 +420,7 @@ class restore_controller extends base_controller {
require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
// Basic/initial prevention against time/memory limits
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
$this->progress->start_progress('Backup format conversion');
......
......@@ -111,7 +111,7 @@ abstract class backup_cron_automated_helper {
cron_trace_time_and_memory();
// This could take a while!
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
$nextstarttime = backup_cron_automated_helper::calculate_next_automated_backup($admin->timezone, $now);
......
......@@ -304,7 +304,7 @@
mtrace(' ' . $rec->url . ' ', '');
// Fetch the rss feed, using standard simplepie caching
// so feeds will be renewed only if cache has expired
@set_time_limit(60);
core_php_time_limit::raise(60);
$feed = new moodle_simplepie();
// set timeout for longer than normal to be agressive at
......
......@@ -3025,7 +3025,7 @@ function calendar_import_icalendar_events($ical, $courseid, $subscriptionid = nu
$updatecount = 0;
// Large calendars take a while...
set_time_limit(300);
core_php_time_limit::raise(300);
// Mark all events in a subscription with a zero timestamp.
if (!empty($subscriptionid)) {
......
......@@ -141,7 +141,7 @@ function enrol_category_sync_full(progress_trace $trace) {
}
// We may need a lot of time here.
@set_time_limit(0);
core_php_time_limit::raise();
$plugin = enrol_get_plugin('category');
......
......@@ -167,7 +167,7 @@ function enrol_cohort_sync(progress_trace $trace, $courseid = NULL) {
}
// Unfortunately this may take a long time, this script can be interrupted without problems.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$trace->output('Starting user enrolment synchronisation...');
......
......@@ -307,7 +307,7 @@ class enrol_database_plugin extends enrol_plugin {
}
// We may need a lot of memory here.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$table = $this->get_config('remoteenroltable');
......@@ -625,7 +625,7 @@ class enrol_database_plugin extends enrol_plugin {
$trace->output('Starting course synchronisation...');
// We may need a lot of memory here.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
if (!$extdb = $this->db_init()) {
......
......@@ -229,7 +229,7 @@ class enrol_flatfile_plugin extends enrol_plugin {
global $CFG, $DB;
// We may need more memory here.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$filelocation = $this->get_config('location');
......
Supports Markdown
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