MDL-54205 tool_recyclebin: Adding missing destroy() calls.
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 12 May 2016 20:55:34 +0000 (22:55 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 12 May 2016 23:54:37 +0000 (01:54 +0200)
This was causing controller references not cleaned till gc
and loggers to remain open, leading to problems under windows.

admin/tool/recyclebin/classes/category_bin.php
admin/tool/recyclebin/classes/course_bin.php

index 06b06de..2acb3b2 100644 (file)
@@ -126,6 +126,9 @@ class category_bin extends base_bin {
             throw new \moodle_exception('Failed to backup activity prior to deletion.');
         }
 
+        // Have finished with the controller, let's destroy it, freeing mem and resources.
+        $controller->destroy();
+
         // Grab the filename.
         $file = $result['backup_destination'];
         if (!$file->get_contenthash()) {
@@ -259,6 +262,9 @@ class category_bin extends base_bin {
         // Run the import.
         $controller->execute_plan();
 
+        // Have finished with the controller, let's destroy it, freeing mem and resources.
+        $controller->destroy();
+
         // Fire event.
         $event = \tool_recyclebin\event\category_bin_item_restored::create(array(
             'objectid' => $item->id,
index a05a7cf..67e1a21 100644 (file)
@@ -130,6 +130,9 @@ class course_bin extends base_bin {
             throw new \moodle_exception('Failed to backup activity prior to deletion.');
         }
 
+        // Have finished with the controller, let's destroy it, freeing mem and resources.
+        $controller->destroy();
+
         // Grab the filename.
         $file = $result['backup_destination'];
         if (!$file->get_contenthash()) {
@@ -246,6 +249,9 @@ class course_bin extends base_bin {
         // Run the import.
         $controller->execute_plan();
 
+        // Have finished with the controller, let's destroy it, freeing mem and resources.
+        $controller->destroy();
+
         // Fire event.
         $event = \tool_recyclebin\event\course_bin_item_restored::create(array(
             'objectid' => $item->id,