MDL-44141 Completion: System updates data during restore

The completion system has code which is supposed to prevent it
updating completion status while grades are being restored. This
code was a nasty hack and had not worked for some time. As a result
completion dates were restored incorrectly.

This commit implements a 'proper' way to find out if a restore is
currently running, replacing the previous hack.
This commit is contained in:
sam marshall
2014-03-18 13:31:34 +00:00
parent c0e88129d1
commit ddf368a213
3 changed files with 96 additions and 10 deletions
+23 -1
View File
@@ -57,6 +57,9 @@ class restore_controller extends base_controller {
protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
/** @var int Number of restore_controllers that are currently executing */
protected static $executing = 0;
/**
* Constructor.
*
@@ -325,7 +328,26 @@ class restore_controller extends base_controller {
$this->log('notifying plan about excluded activities by type', backup::LOG_DEBUG);
$this->plan->set_excluding_activities();
}
return $this->plan->execute();
self::$executing++;
try {
$this->plan->execute();
} catch (Exception $e) {
self::$executing--;
throw $e;
}
self::$executing--;
}
/**
* Checks whether restore is currently executing. Certain parts of code that
* is called during restore, but not directly part of the restore system, may
* need to behave differently during restore (e.g. do not bother resetting a
* cache because we know it will be reset at end of operation).
*
* @return bool True if any restore is currently executing
*/
public static function is_executing() {
return self::$executing > 0;
}
/**