Skip to content

Commit

Permalink
MDL-42084 Core: Change set_time_limit to core_php_time_limit::raise e…
Browse files Browse the repository at this point in the history
…verywhere

Exceptions (places where set_time_limit is still left) are:

Third-party libraries:
  ADODB
  PHPMailer

Moodle core:
  PHPUnit - not relevant (CLI mode)
  • Loading branch information
sammarshallou committed Nov 6, 2013
1 parent 6edd90c commit 3ef7279
Show file tree
Hide file tree
Showing 56 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion admin/enrol.php
Expand Up @@ -108,7 +108,7 @@
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]);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/customlang/index.php
Expand Up @@ -55,7 +55,7 @@
$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);

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/dbtransfer/locallib.php
Expand Up @@ -50,7 +50,7 @@
* @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.

Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/generator/classes/backend.php
Expand Up @@ -177,7 +177,7 @@ protected function dot($number, $total) {

// Update time limit so PHP doesn't time out.
if (!CLI_SCRIPT) {
set_time_limit(120);
core_php_time_limit::raise(120);
}
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/innodb/index.php
Expand Up @@ -57,7 +57,7 @@

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);
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/langimport/index.php
Expand Up @@ -69,7 +69,7 @@
$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');

Expand Down Expand Up @@ -125,7 +125,7 @@
}

if ($mode == UPDATE_ALL_LANG) {
set_time_limit(0);
core_php_time_limit::raise();

$installer = new lang_installer();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/multilangupgrade/index.php
Expand Up @@ -59,7 +59,7 @@

/// Turn off time limits, sometimes upgrades can be slow.

@set_time_limit(0);
core_php_time_limit::raise();

echo '<strong>Progress:</strong>';
$i = 0;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/phpunit/webrunner.php
Expand Up @@ -38,7 +38,7 @@
error('Not available on production sites, sorry.');
}

set_time_limit(60*30);
core_php_time_limit::raise(60*30);

$oldcwd = getcwd();
$code = 0;
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/uploadcourse/classes/processor.php
Expand Up @@ -195,7 +195,7 @@ public function execute($tracker = null) {
$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.
Expand Down Expand Up @@ -335,7 +335,7 @@ public function preview($rows = 10, $tracker = null) {
$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.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/uploaduser/index.php
Expand Up @@ -36,7 +36,7 @@
$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();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/uploaduser/picture.php
Expand Up @@ -72,7 +72,7 @@
// 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
Expand Down
2 changes: 1 addition & 1 deletion backup/controller/backup_controller.class.php
Expand Up @@ -307,7 +307,7 @@ public function get_plan() {
*/
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
Expand Down
6 changes: 3 additions & 3 deletions backup/controller/restore_controller.class.php
Expand Up @@ -315,7 +315,7 @@ public function get_info() {

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
Expand Down Expand Up @@ -349,7 +349,7 @@ public function execute_precheck($droptemptablesafter = false) {
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
Expand Down Expand Up @@ -420,7 +420,7 @@ public function convert() {
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');

Expand Down
2 changes: 1 addition & 1 deletion backup/util/helper/backup_cron_helper.class.php
Expand Up @@ -111,7 +111,7 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL
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);
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/block_rss_client.php
Expand Up @@ -304,7 +304,7 @@ function cron() {
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
Expand Down
2 changes: 1 addition & 1 deletion calendar/lib.php
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion enrol/category/locallib.php
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion enrol/cohort/locallib.php
Expand Up @@ -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...');
Expand Down
4 changes: 2 additions & 2 deletions enrol/database/lib.php
Expand Up @@ -307,7 +307,7 @@ public function sync_enrolments(progress_trace $trace, $onecourse = null) {
}

// 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');
Expand Down Expand Up @@ -625,7 +625,7 @@ public function sync_courses(progress_trace $trace) {
$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()) {
Expand Down
2 changes: 1 addition & 1 deletion enrol/flatfile/lib.php
Expand Up @@ -229,7 +229,7 @@ protected function process_file(progress_trace $trace) {
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');
Expand Down
2 changes: 1 addition & 1 deletion enrol/imsenterprise/lib.php
Expand Up @@ -94,7 +94,7 @@ public function cron() {

$fileisnew = false;
if ( file_exists($filename) ) {
@set_time_limit(0);
core_php_time_limit::raise();
$starttime = time();

$this->log_line('----------------------------------------------------------------------');
Expand Down
4 changes: 2 additions & 2 deletions enrol/ldap/lib.php
Expand Up @@ -147,7 +147,7 @@ public function sync_user_enrolments($user) {
}

// We may need a lot of memory here
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);

// Get enrolments for each type of role.
Expand Down Expand Up @@ -311,7 +311,7 @@ public function sync_enrolments(progress_trace $trace, $onecourse = null) {
$ldap_pagedresults = ldap_paged_results_supported($this->get_config('ldap_version'));

// we may need a lot of memory here
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);

$oneidnumber = null;
Expand Down
2 changes: 1 addition & 1 deletion enrol/manual/lib.php
Expand Up @@ -303,7 +303,7 @@ public function sync(progress_trace $trace, $courseid = null) {
}

// Unfortunately this may take a long time, execution can be interrupted safely here.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);

$trace->output('Verifying manual enrolment expiration...');
Expand Down
2 changes: 1 addition & 1 deletion enrol/meta/locallib.php
Expand Up @@ -255,7 +255,7 @@ function enrol_meta_sync($courseid = NULL, $verbose = false) {
}

// unfortunately this may take a long time, execution can be interrupted safely
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);

if ($verbose) {
Expand Down
2 changes: 1 addition & 1 deletion enrol/self/lib.php
Expand Up @@ -468,7 +468,7 @@ public function sync(progress_trace $trace, $courseid = null) {
}

// Unfortunately this may take a long time, execution can be interrupted safely here.
@set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);

$trace->output('Verifying self-enrolments...');
Expand Down
4 changes: 2 additions & 2 deletions grade/import/csv/index.php
Expand Up @@ -85,7 +85,7 @@
// 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);

// Use current (non-conflicting) time stamp.
Expand Down Expand Up @@ -183,7 +183,7 @@
// 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);

$csvimport->init();
Expand Down
2 changes: 1 addition & 1 deletion grade/import/xml/import.php
Expand Up @@ -43,7 +43,7 @@
// 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);

$text = download_file_content($url);
Expand Down
2 changes: 1 addition & 1 deletion grade/import/xml/index.php
Expand Up @@ -47,7 +47,7 @@
// 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);

if ($text = $mform->get_file_content('userfile')) {
Expand Down
2 changes: 1 addition & 1 deletion grade/report/grader/preferences.php
Expand Up @@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

set_time_limit(0);
core_php_time_limit::raise();
require_once '../../../config.php';
require_once $CFG->libdir . '/gradelib.php';
require_once '../../lib.php';
Expand Down
4 changes: 2 additions & 2 deletions lib/adminlib.php
Expand Up @@ -126,7 +126,7 @@ function uninstall_plugin($type, $name) {
global $CFG, $DB, $OUTPUT;

// This may take a long time.
@set_time_limit(0);
core_php_time_limit::raise();

// Recursively uninstall all subplugins first.
$subplugintypes = core_component::get_plugin_types_with_subplugins();
Expand Down Expand Up @@ -6728,7 +6728,7 @@ function db_replace($search, $replace) {
'block_instances', '');

// Turn off time limits, sometimes upgrades can be slow.
@set_time_limit(0);
core_php_time_limit::raise();

if (!$tables = $DB->get_tables() ) { // No tables yet at all.
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/badgeslib.php
Expand Up @@ -426,7 +426,7 @@ public function review_all_criteria() {
$awards = 0;

// Raise timelimit as this could take a while for big web sites.
set_time_limit(0);
core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);

// For site level badges, get all active site users who can earn this badge and haven't got it yet.
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/session/manager.php
Expand Up @@ -614,7 +614,7 @@ public static function gc() {
global $CFG, $DB;

// This may take a long time...
set_time_limit(0);
\core_php_time_limit::raise();

$maxlifetime = $CFG->sessiontimeout;

Expand Down

0 comments on commit 3ef7279

Please sign in to comment.