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

This commit is contained in:
sam marshall 2013-10-15 14:50:13 +01:00
parent 366b19a954
commit 6edd90ccab
2 changed files with 12 additions and 3 deletions

View File

@ -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();
}

View File

@ -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);