/** * Execute the restore prechecks to detect any problem before proceed with restore * * This function checks various parts of the restore (versions, users, roles...) * returning true if everything was ok or false if any warning/error was detected. * Any warning/error is returned by the get_precheck_results() method. * Note: if any problem is found it will, automatically, drop all the restore temp * tables as far as the next step is to inform about the warning/errors. If no problem * is found, then default behaviour is to keep the temp tables so, in the same request * restore will be executed, saving a lot of checks to be executed again. * Note: If for any reason (UI to show after prechecks...) you want to force temp tables * to be dropped always, you can pass true to the $droptemptablesafter parameter */ public function execute_precheck($droptemptablesafter = false) { if (is_array($this->precheck)) { throw new restore_controller_exception('precheck_alredy_executed', $this->status); } if ($this->status != backup::STATUS_NEED_PRECHECK) { throw new restore_controller_exception('cannot_precheck_wrong_status', $this->status); } $this->precheck = restore_prechecks_helper::execute_prechecks($this, $droptemptablesafter); if (!array_key_exists('errors', $this->precheck)) { // No errors, can be executed $this->set_status(backup::STATUS_AWAITING); } if (empty($this->precheck)) { // No errors nor warnings, return true return true; } return false; }
/** * Execute the restore prechecks to detect any problem before proceed with restore * * This function checks various parts of the restore (versions, users, roles...) * returning true if everything was ok or false if any warning/error was detected. * Any warning/error is returned by the get_precheck_results() method. * Note: if any problem is found it will, automatically, drop all the restore temp * tables as far as the next step is to inform about the warning/errors. If no problem * is found, then default behaviour is to keep the temp tables so, in the same request * restore will be executed, saving a lot of checks to be executed again. * Note: If for any reason (UI to show after prechecks...) you want to force temp tables * to be dropped always, you can pass true to the $droptemptablesafter parameter */ public function execute_precheck($droptemptablesafter = false) { if (is_array($this->precheck)) { throw new restore_controller_exception('precheck_alredy_executed', $this->status); } if ($this->status != backup::STATUS_NEED_PRECHECK) { throw new restore_controller_exception('cannot_precheck_wrong_status', $this->status); } // Basic/initial prevention against time/memory limits core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted raise_memory_limit(MEMORY_EXTRA); $this->precheck = restore_prechecks_helper::execute_prechecks($this, $droptemptablesafter); if (!array_key_exists('errors', $this->precheck)) { // No errors, can be executed $this->set_status(backup::STATUS_AWAITING); } if (empty($this->precheck)) { // No errors nor warnings, return true return true; } return false; }