mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
MDL-42084 Backup: Update time limit to avoid regression, use new class
This commit is contained in:
parent
366b19a954
commit
6edd90ccab
backup/util/progress
@ -31,9 +31,14 @@ abstract class core_backup_progress {
|
|||||||
const INDETERMINATE = -1;
|
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.
|
* @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.
|
* @var int Time of last progress call.
|
||||||
@ -202,7 +207,9 @@ abstract class core_backup_progress {
|
|||||||
// Update progress.
|
// Update progress.
|
||||||
$this->count++;
|
$this->count++;
|
||||||
$this->lastprogresstime = $now;
|
$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();
|
$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.
|
// Make some progress and check that the time limit gets added.
|
||||||
$progress->step_time();
|
$progress->step_time();
|
||||||
|
core_php_time_limit::get_and_clear_unit_test_data();
|
||||||
$progress->progress(2);
|
$progress->progress(2);
|
||||||
$this->assertTrue($progress->was_update_called());
|
$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.
|
// Check the new value.
|
||||||
$this->assert_min_max(0.2, 0.2, $progress);
|
$this->assert_min_max(0.2, 0.2, $progress);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user