Esempio n. 1
0
 /**
  * @param      $uid
  * @param bool $dbBackupPath
  * @return array
  */
 public function rollbackUpdate($uid, $dbBackupPath = false)
 {
     try {
         craft()->config->maxPowerCaptain();
         if ($dbBackupPath && craft()->config->get('backupDbOnUpdate') && craft()->config->get('restoreDbOnUpdateFailure')) {
             Craft::log('Rolling back any database changes.', LogLevel::Info, true);
             UpdateHelper::rollBackDatabaseChanges($dbBackupPath);
             Craft::log('Done rolling back any database changes.', LogLevel::Info, true);
         }
         // If uid !== false, it's an auto-update.
         if ($uid !== false) {
             Craft::log('Rolling back any file changes.', LogLevel::Info, true);
             $manifestData = UpdateHelper::getManifestData(UpdateHelper::getUnzipFolderFromUID($uid));
             if ($manifestData) {
                 UpdateHelper::rollBackFileChanges($manifestData);
             }
             Craft::log('Done rolling back any file changes.', LogLevel::Info, true);
         }
         Craft::log('Finished rolling back changes.', LogLevel::Info, true);
         return array('success' => true);
     } catch (\Exception $e) {
         return array('success' => false, 'message' => $e->getMessage());
     }
 }
Esempio n. 2
0
 /**
  * @param string $uid
  * @param string $handle
  * @param bool   $dbBackupPath
  *
  * @return array
  */
 public function rollbackUpdate($uid, $handle, $dbBackupPath = false)
 {
     try {
         // Fire an 'onEndUpdate' event and pass in that the update failed.
         $this->onEndUpdate(new Event($this, array('success' => false)));
         craft()->config->maxPowerCaptain();
         if ($dbBackupPath && craft()->config->get('backupDbOnUpdate') && craft()->config->get('restoreDbOnUpdateFailure')) {
             Craft::log('Rolling back any database changes.', LogLevel::Info, true);
             UpdateHelper::rollBackDatabaseChanges($dbBackupPath);
             Craft::log('Done rolling back any database changes.', LogLevel::Info, true);
         }
         // If uid !== false, it's an auto-update.
         if ($uid !== false) {
             Craft::log('Rolling back any file changes.', LogLevel::Info, true);
             $manifestData = UpdateHelper::getManifestData(UpdateHelper::getUnzipFolderFromUID($uid), $handle);
             if ($manifestData) {
                 UpdateHelper::rollBackFileChanges($manifestData, $handle);
             }
             Craft::log('Done rolling back any file changes.', LogLevel::Info, true);
         }
         Craft::log('Finished rolling back changes.', LogLevel::Info, true);
         Craft::log('Taking the site out of maintenance mode.', LogLevel::Info, true);
         craft()->disableMaintenanceMode();
         return array('success' => true);
     } catch (\Exception $e) {
         return array('success' => false, 'message' => $e->getMessage());
     }
 }