diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 5831a1e32..e07dc043a 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -557,12 +557,16 @@ class UpdateManager * Downloads a plugin from the update server. * @param string $name Plugin name. * @param string $hash Expected file hash. + * @param boolean $installation Indicates whether this is a plugin installation request. * @return self */ - public function downloadPlugin($name, $hash) + public function downloadPlugin($name, $hash, $installation = false) { $fileCode = $name . $hash; - $this->requestServerFile('plugin/get', $fileCode, $hash, ['name' => $name]); + $this->requestServerFile('plugin/get', $fileCode, $hash, [ + 'name' => $name, + 'installation' => $installation ? 1 : 0 + ]); } /** @@ -909,7 +913,13 @@ class UpdateManager */ protected function applyHttpAttributes($http, $postData) { - $postData['server'] = base64_encode(serialize(['php' => PHP_VERSION, 'url' => Url::to('/')])); + $postData['protocol_version'] = '1.1'; + + $postData['server'] = base64_encode(serialize([ + 'php' => PHP_VERSION, + 'url' => Url::to('/'), + 'since' => PluginVersion::orderBy('created_at')->value('created_at') + ])); if ($projectId = Parameter::get('system::project.id')) { $postData['project'] = $projectId; diff --git a/modules/system/console/PluginInstall.php b/modules/system/console/PluginInstall.php index 4b7420a79..6a3264d59 100644 --- a/modules/system/console/PluginInstall.php +++ b/modules/system/console/PluginInstall.php @@ -43,7 +43,7 @@ class PluginInstall extends Command $hash = array_get($pluginDetails, 'hash'); $this->output->writeln(sprintf('Downloading plugin: %s', $code)); - $manager->downloadPlugin($code, $hash); + $manager->downloadPlugin($code, $hash, true); $this->output->writeln(sprintf('Unpacking plugin: %s', $code)); $manager->extractPlugin($code, $hash); diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index 3f67d2cdd..8f0aaf12f 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -279,7 +279,7 @@ class Updates extends Controller break; case 'downloadPlugin': - $manager->downloadPlugin(post('name'), post('hash')); + $manager->downloadPlugin(post('name'), post('hash'), post('install')); break; case 'downloadTheme': @@ -439,7 +439,7 @@ class Updates extends Controller /* * Update steps */ - $updateSteps = $this->buildUpdateSteps($core, $plugins, $themes); + $updateSteps = $this->buildUpdateSteps($core, $plugins, $themes, false); /* * Finish up @@ -534,7 +534,7 @@ class Updates extends Controller /* * Update steps */ - $updateSteps = $this->buildUpdateSteps($core, $plugins, $themes); + $updateSteps = $this->buildUpdateSteps($core, $plugins, $themes, false); /* * Finish up @@ -553,7 +553,7 @@ class Updates extends Controller return $this->makePartial('execute'); } - protected function buildUpdateSteps($core, $plugins, $themes) + protected function buildUpdateSteps($core, $plugins, $themes, $isInstallationRequest) { if (!is_array($core)) { $core = [null, null]; @@ -595,7 +595,8 @@ class Updates extends Controller 'code' => 'downloadPlugin', 'label' => Lang::get('system::lang.updates.plugin_downloading', compact('name')), 'name' => $name, - 'hash' => $hash + 'hash' => $hash, + 'install' => $isInstallationRequest ? 1 : 0 ]; } @@ -717,7 +718,7 @@ class Updates extends Controller /* * Update steps */ - $updateSteps = $this->buildUpdateSteps(null, $plugins, []); + $updateSteps = $this->buildUpdateSteps(null, $plugins, [], true); /* * Finish up @@ -845,7 +846,7 @@ class Updates extends Controller /* * Update steps */ - $updateSteps = $this->buildUpdateSteps(null, $plugins, $themes); + $updateSteps = $this->buildUpdateSteps(null, $plugins, $themes, true); /* * Finish up