Skip to content
Snippets Groups Projects
Commit 4baeb8d8 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

Issue #2234159 by alexpott: Fixed config importing through the UI and change...

Issue #2234159 by alexpott: Fixed config importing through the UI and change ConfigImportAll test using the UI.
parent 4ccdb414
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -540,6 +540,7 @@ public function initialize() { ...@@ -540,6 +540,7 @@ public function initialize() {
// We have extensions to process. // We have extensions to process.
if ($this->totalExtensionsToProcess > 0) { if ($this->totalExtensionsToProcess > 0) {
$sync_steps[] = 'processExtensions'; $sync_steps[] = 'processExtensions';
$sync_steps[] = 'flush';
} }
$sync_steps[] = 'processConfigurations'; $sync_steps[] = 'processConfigurations';
...@@ -549,6 +550,20 @@ public function initialize() { ...@@ -549,6 +550,20 @@ public function initialize() {
return $sync_steps; return $sync_steps;
} }
/**
* Flushes Drupal's caches.
*/
public function flush(array &$context) {
// Rebuild the container and flush Drupal's caches. If the container is not
// rebuilt first the entity types are not discovered correctly due to using
// an entity manager that has the incorrect container namespaces injected.
\Drupal::service('kernel')->rebuildContainer(TRUE);
drupal_flush_all_caches();
$this->reInjectMe();
$context['message'] = $this->t('Flushed all caches.');
$context['finished'] = 1;
}
/** /**
* Processes extensions as a batch operation. * Processes extensions as a batch operation.
* *
......
...@@ -10,11 +10,13 @@ ...@@ -10,11 +10,13 @@
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\Core\Database\SchemaObjectExistsException;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
/** /**
* Defines the Database storage. * Defines the Database storage.
*/ */
class DatabaseStorage implements StorageInterface { class DatabaseStorage implements StorageInterface {
use DependencySerializationTrait;
/** /**
* The database connection. * The database connection.
......
services:
config.config_subscriber:
class: Drupal\config\ConfigSubscriber
tags:
- { name: event_subscriber }
<?php
/**
* @file
* Contains \Drupal\config\ConfigSubscriber.
*/
namespace Drupal\config;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\ConfigImporterEvent;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
/**
* Config subscriber.
*/
class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
/**
* Checks that the Configuration module is not being uninstalled.
*
* @param ConfigImporterEvent $event
* The config import event.
*/
public function onConfigImporterValidate(ConfigImporterEvent $event) {
$importer = $event->getConfigImporter();
$core_extension = $importer->getStorageComparer()->getSourceStorage()->read('core.extension');
if (!isset($core_extension['module']['config'])) {
$importer->logError($this->t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
}
}
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20);
return $events;
}
}
...@@ -32,6 +32,13 @@ public static function getInfo() { ...@@ -32,6 +32,13 @@ public static function getInfo() {
); );
} }
public function setUp() {
parent::setUp();
$this->web_user = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->web_user);
}
/** /**
* Tests that a fixed set of modules can be installed and uninstalled. * Tests that a fixed set of modules can be installed and uninstalled.
*/ */
...@@ -82,6 +89,9 @@ public function testInstallUninstall() { ...@@ -82,6 +89,9 @@ public function testInstallUninstall() {
return TRUE; return TRUE;
}); });
// Can not uninstall config and use admin/config/development/configuration!
unset($modules_to_uninstall['config']);
$this->assertTrue(isset($modules_to_uninstall['comment']), 'The comment module will be disabled'); $this->assertTrue(isset($modules_to_uninstall['comment']), 'The comment module will be disabled');
// Uninstall all modules that can be uninstalled. // Uninstall all modules that can be uninstalled.
...@@ -94,7 +104,7 @@ public function testInstallUninstall() { ...@@ -94,7 +104,7 @@ public function testInstallUninstall() {
} }
// Import the configuration thereby re-installing all the modules. // Import the configuration thereby re-installing all the modules.
$this->configImporter()->import(); $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
// Check that there are no errors. // Check that there are no errors.
$this->assertIdentical($this->configImporter()->getErrors(), array()); $this->assertIdentical($this->configImporter()->getErrors(), array());
......
...@@ -331,6 +331,21 @@ public function testImportValidation() { ...@@ -331,6 +331,21 @@ public function testImportValidation() {
$this->assertNotEqual($new_site_name, \Drupal::config('system.site')->get('name')); $this->assertNotEqual($new_site_name, \Drupal::config('system.site')->get('name'));
} }
public function testConfigUninstallConfigException() {
$staging = $this->container->get('config.storage.staging');
$core_extension = \Drupal::config('core.extension')->get();
unset($core_extension['module']['config']);
$staging->write('core.extension', $core_extension);
$this->drupalGet('admin/config/development/configuration');
$this->assertText('core.extension');
// Import and verify that both do not appear anymore.
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.');
}
function prepareSiteNameUpdate($new_site_name) { function prepareSiteNameUpdate($new_site_name) {
$staging = $this->container->get('config.storage.staging'); $staging = $this->container->get('config.storage.staging');
// Create updated configuration object. // Create updated configuration object.
......
...@@ -78,6 +78,13 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem ...@@ -78,6 +78,13 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*/ */
public $process; public $process;
/**
* The configuration describing the load plugins.
*
* @var array
*/
public $load;
/** /**
* The cached process plugins. * The cached process plugins.
* *
...@@ -339,18 +346,4 @@ public function checkRequirements() { ...@@ -339,18 +346,4 @@ public function checkRequirements() {
return TRUE; return TRUE;
} }
/**
* {@inheritdoc}
*/
public function toArray() {
// @todo Remove once migration config entities have schema
// https://drupal.org/node/2183957.
$class_info = new \ReflectionClass($this);
foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
$properties[$name] = $this->get($name);
}
return $properties;
}
} }
...@@ -48,6 +48,12 @@ public static function create(ContainerInterface $container) { ...@@ -48,6 +48,12 @@ public static function create(ContainerInterface $container) {
*/ */
public function __construct(Connection $database) { public function __construct(Connection $database) {
$this->database = $database; $this->database = $database;
}
/**
* Builds the status image map.
*/
protected function buildStatusImageMap() {
// Initialize image mapping property. // Initialize image mapping property.
$image_pass = array( $image_pass = array(
'#theme' => 'image', '#theme' => 'image',
...@@ -96,6 +102,7 @@ public function getFormId() { ...@@ -96,6 +102,7 @@ public function getFormId() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, array &$form_state, $test_id = NULL) { public function buildForm(array $form, array &$form_state, $test_id = NULL) {
$this->buildStatusImageMap();
// Make sure there are test results to display and a re-run is not being // Make sure there are test results to display and a re-run is not being
// performed. // performed.
$results = array(); $results = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment