MDL-77955 moodlenet: destroy backup controller in class destructor.

This ensures that it's always cleaned up during tests, where not doing
so can cause spurious errors on Windows.
This commit is contained in:
Paul Holden 2023-04-18 22:42:13 +01:00
parent 7beda01cae
commit 78d24550af
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -63,6 +63,13 @@ class activity_packager {
);
}
/**
* Destructor
*/
public function __destruct() {
$this->controller->destroy();
}
/**
* Prepare the backup file using appropriate setting overrides and return relevant information.
*
@ -133,8 +140,6 @@ class activity_packager {
// Execute the backup and fetch the result.
$this->controller->execute_plan();
$result = $this->controller->get_results();
// Controller no longer required.
$this->controller->destroy();
if (!isset($result['backup_destination'])) {
throw new \moodle_exception('Failed to package activity.');