From 7d0a210fac1844d77ac85301c9ab06dc5c7ca675 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 1 Nov 2014 11:33:33 +1100 Subject: [PATCH] When cms.disableCoreUpdates is set to true the Backend will no longer display updates for the core. --- CHANGELOG.md | 1 + modules/system/classes/UpdateManager.php | 24 ++++++++++++++++++++---- modules/system/console/OctoberUpdate.php | 4 ---- modules/system/controllers/Updates.php | 13 ------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2cb7794..340643df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ * **Build 160** (2014-11-01) - Various fixes to the Backend Brand settings page. + - When `cms.disableCoreUpdates` is set to **true** the Backend will no longer display updates for the core. * **Build 158** (2014-10-23) - Fixes an issue where new Themes attached to a project were not being installed on update. diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 3ae9f728c..47aa66644 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -63,6 +63,11 @@ class UpdateManager */ protected $secret; + /** + * @var boolean If set to true, core updates will not be downloaded or extracted. + */ + protected $disableCoreUpdates = false; + /** * Initialize this singleton. */ @@ -74,6 +79,7 @@ class UpdateManager $this->repository = App::make('migration.repository'); $this->tempDirectory = Config::get('cms.tempDir', sys_get_temp_dir()); $this->baseDirectory = PATH_BASE; + $this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false); /* * Ensure temp directory exists @@ -190,6 +196,7 @@ class UpdateManager } $result = $this->requestServerData('core/update', $params); + $updateCount = (int) array_get($result, 'update', 0); /* * Inject known core build @@ -222,12 +229,21 @@ class UpdateManager $result['themes'] = $themes; /* - * There are updates if update count is empty - * or if uninstalled themes are found. + * If there is a core update and core updates are disabled, + * remove the entry and discount an update unit. */ - $result['hasUpdates'] = array_get($result, 'update') || count($themes); + if (array_get($result, 'core') && $this->disableCoreUpdates) { + $updateCount = max(0, --$updateCount); + unset($result['core']); + } - Parameters::set('system::update.count', array_get($result, 'update', 0)); + /* + * Recalculate the update counter + */ + $updateCount += count($themes); + $result['hasUpdates'] = $updateCount > 0; + $result['update'] = $updateCount; + Parameters::set('system::update.count', $updateCount); return $result; } diff --git a/modules/system/console/OctoberUpdate.php b/modules/system/console/OctoberUpdate.php index d2a3883d1..0b5c36e05 100644 --- a/modules/system/console/OctoberUpdate.php +++ b/modules/system/console/OctoberUpdate.php @@ -52,10 +52,6 @@ class OctoberUpdate extends Command $disableThemes = true; } - if (Config::get('cms.disableCoreUpdates', false)) { - $disableCore = true; - } - /* * Perform update */ diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index f4529a195..6d392390b 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -33,11 +33,6 @@ class Updates extends Controller public $listConfig = ['list' => 'config_list.yaml', 'manage' => 'config_manage_list.yaml']; - /** - * @var boolean If set to true, core updates will not be downloaded or extracted. - */ - protected $disableCoreUpdates = false; - public function __construct() { parent::__construct(); @@ -46,8 +41,6 @@ class Updates extends Controller BackendMenu::setContext('October.System', 'system', 'updates'); SettingsManager::setContext('October.System', 'updates'); - - $this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false); } /** @@ -113,16 +106,10 @@ class Updates extends Controller switch ($stepCode) { case 'downloadCore': - if ($this->disableCoreUpdates) { - return; - } $manager->downloadCore(post('hash')); break; case 'extractCore': - if ($this->disableCoreUpdates) { - return; - } $manager->extractCore(post('hash'), post('build')); break;