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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user