From 78d24550afbcd0981ab34620a914383d086b48f1 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 18 Apr 2023 22:42:13 +0100 Subject: [PATCH] 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. --- lib/classes/moodlenet/activity_packager.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/classes/moodlenet/activity_packager.php b/lib/classes/moodlenet/activity_packager.php index ef69c20b4fd..fe5e21f1cd0 100644 --- a/lib/classes/moodlenet/activity_packager.php +++ b/lib/classes/moodlenet/activity_packager.php @@ -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.');