diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 43cb03a21..af3a9a62d 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -365,11 +365,10 @@ class UpdateManager public function setBuildNumberManually() { $result = $this->requestServerData('ping'); + $build = (int) array_get($result, 'pong', 420); - Parameter::set([ - 'system::core.build' => $build - ]); + $this->setBuild($build); return $build; } @@ -448,17 +447,28 @@ class UpdateManager throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath])); } - // Database may fall asleep after this long process - Db::reconnect(); - - Parameter::set([ - 'system::core.hash' => $hash, - 'system::core.build' => $build - ]); - @unlink($filePath); } + /** + * Sets the build number and hash + * @param string $hash + * @param string $build + * @return void + */ + public function setBuild($build, $hash = null) + { + $params = [ + 'system::core.build' => $build + ]; + + if ($hash) { + $params['system::core.hash'] = $hash; + } + + Parameter::set($params); + } + // // Plugins // diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index bf3017d39..e321fe78f 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -276,6 +276,10 @@ class Updates extends Controller $manager->extractCore(post('hash'), post('build')); break; + case 'setBuild': + $manager->setBuild(post('build'), post('hash')); + break; + case 'downloadPlugin': $manager->downloadPlugin(post('name'), post('hash')); break; @@ -603,6 +607,13 @@ class Updates extends Controller 'hash' => $coreHash, 'build' => $coreBuild ]; + + $updateSteps[] = [ + 'code' => 'setBuild', + 'label' => Lang::get('system::lang.updates.core_set_build'), + 'hash' => $coreHash, + 'build' => $coreBuild + ]; } foreach ($themes as $name => $hash) { diff --git a/modules/system/lang/en/lang.php b/modules/system/lang/en/lang.php index 4e75cb430..8dd22edca 100644 --- a/modules/system/lang/en/lang.php +++ b/modules/system/lang/en/lang.php @@ -256,6 +256,7 @@ return [ 'core_build_help' => 'Latest build is available.', 'core_downloading' => 'Downloading application files', 'core_extracting' => 'Unpacking application files', + 'core_set_build' => 'Setting build number', 'plugins' => 'Plugins', 'themes' => 'Themes', 'disabled' => 'Disabled',