MDL-29262 backup: Clean controller obj form DB once finished ok
This commit is contained in:
@@ -170,17 +170,22 @@ class backup_controller extends backup implements loggable {
|
||||
}
|
||||
|
||||
public function set_status($status) {
|
||||
$this->log('setting controller status to', backup::LOG_DEBUG, $status);
|
||||
// TODO: Check it's a correct status
|
||||
$this->status = $status;
|
||||
// Ensure that, once set to backup::STATUS_AWAITING, controller is stored in DB
|
||||
// Note: never save_controller() after STATUS_EXECUTING or the whole controller,
|
||||
// Note: never save_controller() with the object info after STATUS_EXECUTING or the whole controller,
|
||||
// containing all the steps will be sent to DB. 100% (monster) useless.
|
||||
$this->log('setting controller status to', backup::LOG_DEBUG, $status);
|
||||
// TODO: Check it's a correct status.
|
||||
$this->status = $status;
|
||||
// Ensure that, once set to backup::STATUS_AWAITING, controller is stored in DB.
|
||||
if ($status == backup::STATUS_AWAITING) {
|
||||
$this->save_controller();
|
||||
$tbc = self::load_controller($this->backupid);
|
||||
$this->logger = $tbc->logger; // wakeup loggers
|
||||
$tbc->destroy(); // Clean temp controller structures
|
||||
|
||||
} else if ($status == backup::STATUS_FINISHED_OK) {
|
||||
// If the operation has ended without error (backup::STATUS_FINISHED_OK)
|
||||
// proceed by cleaning the object from database. MDL-29262.
|
||||
$this->save_controller(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,12 +317,20 @@ class backup_controller extends backup implements loggable {
|
||||
backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
|
||||
}
|
||||
|
||||
public function save_controller() {
|
||||
/**
|
||||
* Save controller information
|
||||
*
|
||||
* @param bool $includeobj to decide if the object itself must be updated (true) or no (false)
|
||||
* @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)
|
||||
*/
|
||||
public function save_controller($includeobj = true, $cleanobj = false) {
|
||||
// Going to save controller to persistent storage, calculate checksum for later checks and save it
|
||||
// TODO: flag the controller as NA. Any operation on it should be forbidden util loaded back
|
||||
$this->log('saving controller to db', backup::LOG_DEBUG);
|
||||
$this->checksum = $this->calculate_checksum();
|
||||
backup_controller_dbops::save_controller($this, $this->checksum);
|
||||
if ($includeobj ) { // Only calculate checksum if we are going to include the object.
|
||||
$this->checksum = $this->calculate_checksum();
|
||||
}
|
||||
backup_controller_dbops::save_controller($this, $this->checksum, $includeobj, $cleanobj);
|
||||
}
|
||||
|
||||
public static function load_controller($backupid) {
|
||||
|
||||
Reference in New Issue
Block a user