MDL-54205 backup: loggers close() and destroy()

Any backup & restore operation may be leaving opened files
if a file logger is being used. This implementes the close()
method, so every logger can close any resource.

Also, the recommended backup_controlled::destroy() method
now calls to new logger::destroy() method in charge of
deleting all the references and closing any resource.

Finally, some internally used controllers, were missing
their destroy call, leading to associated loggers to
remain open. Now all them are explicitly deltroyed.
This commit is contained in:
Eloy Lafuente (stronk7)
2016-05-13 01:54:28 +02:00
parent e4b5a062d8
commit 53f95c99cb
7 changed files with 60 additions and 4 deletions
@@ -170,6 +170,8 @@ class restore_controller extends base_controller {
public function destroy() {
// Only need to destroy circulars under the plan. Delegate to it.
$this->plan->destroy();
// Loggers may have also chained references, destroy them. Also closing resources when needed.
$this->logger->destroy();
}
public function finish_ui() {
@@ -196,7 +198,7 @@ class restore_controller extends base_controller {
$this->save_controller();
$tbc = self::load_controller($this->restoreid);
$this->logger = $tbc->logger; // wakeup loggers
$tbc->destroy(); // Clean temp controller structures
$tbc->plan->destroy(); // Clean plan controller structures, keeping logger alive.
} else if ($status == backup::STATUS_FINISHED_OK) {
// If the operation has ended without error (backup::STATUS_FINISHED_OK)