/**
  * @param $manual
  * @param $handle
  * @return array
  */
 public function prepareUpdate($manual, $handle)
 {
     Craft::log('Preparing to update ' . $handle . '.', LogLevel::Info, true);
     try {
         $updater = new Updater();
         // No need to get the latest update info if this is a manual update.
         if (!$manual) {
             $updater->getLatestUpdateInfo();
         }
         $updater->checkRequirements();
         Craft::log('Finished preparing to update ' . $handle . '.', LogLevel::Info, true);
         return array('success' => true);
     } catch (\Exception $e) {
         return array('success' => false, 'message' => $e->getMessage());
     }
 }
Example #2
0
 /**
  * @param $manual
  * @param $handle
  *
  * @return array
  */
 public function prepareUpdate($manual, $handle)
 {
     Craft::log('Preparing to update ' . $handle . '.', LogLevel::Info, true);
     try {
         // Fire an 'onBeginUpdate' event and pass in the type
         $this->onBeginUpdate(new Event($this, array('type' => $manual ? 'manual' : 'auto')));
         $updater = new Updater();
         // Make sure we still meet the existing requirements.
         $updater->checkRequirements();
         // No need to get the latest update info if this is a manual update.
         if (!$manual) {
             $updateModel = $this->getUpdates();
             if ($handle == 'craft') {
                 Craft::log('Updating from ' . $updateModel->app->localVersion . '.' . $updateModel->app->localBuild . ' to ' . $updateModel->app->latestVersion . '.' . $updateModel->app->latestBuild . '.', LogLevel::Info, true);
             } else {
                 $latestVersion = null;
                 $localVersion = null;
                 $class = null;
                 foreach ($updateModel->plugins as $pluginUpdateModel) {
                     if (strtolower($pluginUpdateModel->class) === $handle) {
                         $latestVersion = $pluginUpdateModel->latestVersion;
                         $localVersion = $pluginUpdateModel->localVersion;
                         $class = $pluginUpdateModel->class;
                         break;
                     }
                 }
                 Craft::log('Updating plugin "' . $class . '" from ' . $localVersion . ' to ' . $latestVersion . '.', LogLevel::Info, true);
             }
             $result = $updater->getUpdateFileInfo($handle);
         }
         $result['success'] = true;
         Craft::log('Finished preparing to update ' . $handle . '.', LogLevel::Info, true);
         return $result;
     } catch (\Exception $e) {
         return array('success' => false, 'message' => $e->getMessage());
     }
 }