Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'MDL-42084-master' of git://github.com/sammarshallou/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Dec 2, 2013
2 parents b5fd249 + db0f009 commit a59a423
Show file tree
Hide file tree
Showing 69 changed files with 212 additions and 147 deletions.
2 changes: 1 addition & 1 deletion admin/enrol.php
Original file line number Diff line number Diff line change
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
3 changes: 3 additions & 0 deletions admin/settings/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'), new lang_string('configgetremoteaddrconf', 'admin'), 0, $options));

$temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
$temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
$temp->add(new admin_setting_configtext('proxyport', new lang_string('proxyport', 'admin'), new lang_string('configproxyport', 'admin'), 0, PARAM_INT));
Expand Down Expand Up @@ -195,6 +196,8 @@
$temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
new lang_string('configextramemorylimit', 'admin'), '512M',
$memoryoptions));
$temp->add(new admin_setting_configtext('maxtimelimit', new lang_string('maxtimelimit', 'admin'),
new lang_string('maxtimelimit_desc', 'admin'), 0, PARAM_INT));

$temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/customlang/index.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
6 changes: 0 additions & 6 deletions admin/tool/uploadcourse/tests/course_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,6 @@ public function test_restore_course() {
}
}
$this->assertTrue($found);

// Restore the time limit to prevent warning.
set_time_limit(0);
}

public function test_restore_file() {
Expand Down Expand Up @@ -703,9 +700,6 @@ public function test_restore_file() {
}
}
$this->assertTrue($found);

// Restore the time limit to prevent warning.
set_time_limit(0);
}

public function test_restore_invalid_file() {
Expand Down
3 changes: 0 additions & 3 deletions admin/tool/uploadcourse/tests/helper_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ public function test_get_restore_content_dir() {
$this->assertEquals($dir, $dir2);

$CFG->keeptempdirectoriesonbackup = $oldcfg;

// Restore the time limit to prevent warning.
set_time_limit(0);
}

public function test_get_role_ids() {
Expand Down
6 changes: 0 additions & 6 deletions admin/tool/uploadcourse/tests/processor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ public function test_restore_template_course() {
}
}
$this->assertTrue($found);

// Restore the time limit to prevent warning.
set_time_limit(0);
}

public function test_restore_restore_file() {
Expand Down Expand Up @@ -136,9 +133,6 @@ public function test_restore_restore_file() {
}
}
$this->assertTrue($found);

// Restore the time limit to prevent warning.
set_time_limit(0);
}

public function test_shortname_template() {
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/uploaduser/index.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 0 additions & 3 deletions backup/util/plan/tests/step_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ function test_backup_structure_step() {

// Remove the test dir and any content
@remove_dir(dirname($file));

// Clear the time limit, otherwise PHPUnit complains.
set_time_limit(0);
}

/**
Expand Down
11 changes: 9 additions & 2 deletions backup/util/progress/core_backup_progress.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ abstract class core_backup_progress {
const INDETERMINATE = -1;

/**
* This value is set rather high to ensure there are no regressions from
* previous behaviour. For testing, it may be useful to set the
* frontendservertimeout config option to a lower value, such as 180
* seconds (default for some commercial products).
*
* @var int The number of seconds that can pass without progress() calls.
*/
const TIME_LIMIT_WITHOUT_PROGRESS = 120;
const TIME_LIMIT_WITHOUT_PROGRESS = 3600;

/**
* @var int Time of last progress call.
Expand Down Expand Up @@ -201,7 +206,9 @@ public function progress($progress = self::INDETERMINATE) {
// Update progress.
$this->count++;
$this->lastprogresstime = $now;
set_time_limit(self::TIME_LIMIT_WITHOUT_PROGRESS);

// Update time limit before next progress display.
core_php_time_limit::raise(self::TIME_LIMIT_WITHOUT_PROGRESS);
$this->update_progress();
}

Expand Down
19 changes: 3 additions & 16 deletions backup/util/progress/tests/progress_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public function test_basic() {

// Make some progress and check that the time limit gets added.
$progress->step_time();
core_php_time_limit::get_and_clear_unit_test_data();
$progress->progress(2);
$this->assertTrue($progress->was_update_called());
$this->assertEquals(120, ini_get('max_execution_time'));
$this->assertEquals(array(core_backup_progress::TIME_LIMIT_WITHOUT_PROGRESS),
core_php_time_limit::get_and_clear_unit_test_data());

// Check the new value.
$this->assert_min_max(0.2, 0.2, $progress);
Expand All @@ -77,9 +79,6 @@ public function test_basic() {

// There was 1 progress call.
$this->assertEquals(1, $progress->get_progress_count());

// Clear the time limit, otherwise phpunit complains.
set_time_limit(0);
}

/**
Expand Down Expand Up @@ -158,8 +157,6 @@ public function test_nested() {
$this->assert_min_max(0.8, 0.8, $progress);
$progress->end_progress();
$this->assertFalse($progress->is_in_progress_section());

set_time_limit(0);
}

/**
Expand Down Expand Up @@ -192,8 +189,6 @@ public function test_nested_weighted() {
$this->assert_min_max(0.4, 1.0, $progress);
$progress->end_progress();
$this->assert_min_max(1.0, 1.0, $progress);

set_time_limit(0);
}

/**
Expand All @@ -208,9 +203,6 @@ public function test_realistic() {
$this->assert_min_max(0.01, 0.01, $progress);
$progress->end_progress();
$this->assert_min_max(0.01, 0.01, $progress);

// Clear the time limit, otherwise phpunit complains.
set_time_limit(0);
}

/**
Expand All @@ -231,8 +223,6 @@ public function test_zero() {
$this->assert_min_max(0.02, 0.02, $progress);
$progress->end_progress();
$this->assert_min_max(0.02, 0.02, $progress);

set_time_limit(0);
}

/**
Expand Down Expand Up @@ -329,9 +319,6 @@ public function test_exceptions() {
} catch (coding_exception $e) {
$this->assertEquals(1, preg_match('~would exceed max~', $e->getMessage()));
}

// Clear the time limit, otherwise phpunit complains.
set_time_limit(0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion blocks/rss_client/block_rss_client.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 0 additions & 3 deletions course/tests/courselib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1715,9 +1715,6 @@ public function test_course_restored_event() {
// Destroy the resource controller since we are done using it.
$rc->destroy();
unset($rc);

// Clear the time limit, otherwise PHPUnit complains.
set_time_limit(0);
}

/**
Expand Down
Loading

0 comments on commit a59a423

Please sign in to comment.