Fixes #452 - New config item disableCoreUpdates

This commit is contained in:
Sam Georges 2014-07-24 18:55:03 +10:00
parent 0bd7180941
commit 9b85038203
4 changed files with 50 additions and 4 deletions

View File

@ -2,6 +2,7 @@
- Added new Theme picker to the backend via Settings > Front-end theme
- New shorthand method for `$this->getClassExtension('Backend.Behaviors.FormController')` becomes `$this->asExtension('FormController')`.
- Buttons inside a popup support new `data-popup-load-indicator` attribute.
- Added a new config item to disable core updates completely (see config cms.disableCoreUpdates).
* **Build 124** (2014-07-17)
- Improvements to Twig functions and filters.

View File

@ -33,6 +33,20 @@ return array(
*/
'disablePlugins' => [],
/*
|--------------------------------------------------------------------------
| Prevents application updates
|--------------------------------------------------------------------------
|
| If using composer or git to download updates to the core files, set this
| value to 'true' to prevent the update gateway from trying to download
| these files again as part of the application update process. Plugins
| and themes will still be downloaded.
|
*/
'disableCoreUpdates' => false,
/*
|--------------------------------------------------------------------------
| Back-end URI prefix

View File

@ -1,6 +1,7 @@
<?php namespace System\Console;
use Str;
use Config;
use Illuminate\Console\Command;
use System\Classes\UpdateManager;
use Symfony\Component\Console\Input\InputOption;
@ -35,9 +36,29 @@ class OctoberUpdate extends Command
$this->output->writeln('<info>Updating October...</info>');
$manager = UpdateManager::instance()->resetNotes();
$forceUpdate = $this->option('force');
$pluginsOnly = $this->option('plugins');
$coreOnly = $this->option('core');
/*
* Check for disabilities
*/
$disableCore = $disablePlugins = $disableThemes = false;
if ($this->option('plugins')) {
$disableCore = true;
$disableThemes = true;
}
if ($this->option('core')) {
$disablePlugins = true;
$disableThemes = true;
}
if (Config::get('cms.disableCoreUpdates', false)) {
$disableCore = true;
}
/*
* Perform update
*/
$updateList = $manager->requestUpdateList($forceUpdate);
$updates = (int)array_get($updateList, 'update', 0);
@ -49,7 +70,7 @@ class OctoberUpdate extends Command
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
}
$coreHash = $pluginsOnly ? null : array_get($updateList, 'core.hash');
$coreHash = $disableCore ? null : array_get($updateList, 'core.hash');
$coreBuild = array_get($updateList, 'core.build');
if ($coreHash) {
@ -57,7 +78,7 @@ class OctoberUpdate extends Command
$manager->downloadCore($coreHash);
}
$plugins = $coreOnly ? [] : array_get($updateList, 'plugins');
$plugins = $disablePlugins ? [] : array_get($updateList, 'plugins');
foreach ($plugins as $code => $plugin) {
$pluginName = array_get($plugin, 'name');
$pluginHash = array_get($plugin, 'hash');

View File

@ -4,6 +4,7 @@ use Str;
use Lang;
use File;
use Flash;
use Config;
use Backend;
use Redirect;
use BackendMenu;
@ -31,6 +32,11 @@ 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();
@ -38,6 +44,8 @@ class Updates extends Controller
$this->addCss('/modules/system/assets/css/updates.css', 'core');
BackendMenu::setContext('October.System', 'system', 'updates');
$this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false);
}
/**
@ -98,10 +106,12 @@ 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;