Commit 6edd90cc authored by sam marshall's avatar sam marshall
Browse files

MDL-42084 Backup: Update time limit to avoid regression, use new class

parent 366b19a9
......@@ -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.
......@@ -202,7 +207,9 @@ abstract class core_backup_progress {
// 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();
}
......
......@@ -56,9 +56,11 @@ class backup_progress_testcase extends basic_testcase {
// 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);
......
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