Commit 194539a7 authored by alexpott's avatar alexpott

Issue #2358269 by Gábor Hojtsy: Migration bugs in block visibility, field...

Issue #2358269 by Gábor Hojtsy: Migration bugs in block visibility, field overrides, cron, maintenance settings and form modes found by configuration schema checking
parent e20d78e1
...@@ -78,9 +78,12 @@ process: ...@@ -78,9 +78,12 @@ process:
- @plugin - @plugin
- delta - delta
- settings - settings
visibility:
plugin: d6_block_visibility
source:
- pages
- roles
- visibility - visibility
'settings/visibility/request_path/pages': pages
'settings/visibility/user_role/roles': roles
destination: destination:
plugin: entity:block plugin: entity:block
migration_dependencies: migration_dependencies:
......
...@@ -11,7 +11,7 @@ process: ...@@ -11,7 +11,7 @@ process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
bundle: type bundle: type
field_name: 'constants/field_name' field_name: 'constants/field_name'
default_value: 'options/promote' 'default_value/0/value': 'options/promote'
destination: destination:
plugin: entity:base_field_override plugin: entity:base_field_override
migration_dependencies: migration_dependencies:
......
...@@ -11,7 +11,7 @@ process: ...@@ -11,7 +11,7 @@ process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
bundle: type bundle: type
field_name: 'constants/field_name' field_name: 'constants/field_name'
default_value: 'options/status' 'default_value/0/value': 'options/status'
destination: destination:
plugin: entity:base_field_override plugin: entity:base_field_override
migration_dependencies: migration_dependencies:
......
...@@ -11,7 +11,7 @@ process: ...@@ -11,7 +11,7 @@ process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
bundle: type bundle: type
field_name: 'constants/field_name' field_name: 'constants/field_name'
default_value: 'options/sticky' 'default_value/0/value': 'options/sticky'
destination: destination:
plugin: entity:base_field_override plugin: entity:base_field_override
migration_dependencies: migration_dependencies:
......
...@@ -9,8 +9,8 @@ source: ...@@ -9,8 +9,8 @@ source:
- cron_threshold_error - cron_threshold_error
- cron_last - cron_last
process: process:
'threshold/warning': cron_threshold_warning 'threshold/requirements_warning': cron_threshold_warning
'threshold/error': cron_threshold_error 'threshold/requirements_error': cron_threshold_error
destination: destination:
plugin: config plugin: config
config_name: system.cron config_name: system.cron
...@@ -5,10 +5,8 @@ migration_groups: ...@@ -5,10 +5,8 @@ migration_groups:
source: source:
plugin: variable plugin: variable
variables: variables:
- site_offline
- site_offline_message - site_offline_message
process: process:
enable: site_offline
message: site_offline_message message: site_offline_message
destination: destination:
plugin: config plugin: config
......
...@@ -11,7 +11,6 @@ source: ...@@ -11,7 +11,6 @@ source:
name: upload name: upload
type: file_generic type: file_generic
options: options:
label: hidden
settings: settings:
progress_indicator: throbber progress_indicator: throbber
process: process:
......
...@@ -11,7 +11,6 @@ source: ...@@ -11,7 +11,6 @@ source:
name: user_picture name: user_picture
type: image_image type: image_image
options: options:
label: hidden
settings: settings:
progress_indicator: throbber progress_indicator: throbber
preview_image_style: thumbnail preview_image_style: thumbnail
......
...@@ -9,8 +9,6 @@ source: ...@@ -9,8 +9,6 @@ source:
entity_type: user entity_type: user
bundle: user bundle: user
form_mode: default form_mode: default
options:
label: hidden
process: process:
entity_type: 'constants/entity_type' entity_type: 'constants/entity_type'
bundle: 'constants/bundle' bundle: 'constants/bundle'
......
...@@ -24,9 +24,8 @@ class BlockSettings extends ProcessPluginBase { ...@@ -24,9 +24,8 @@ class BlockSettings extends ProcessPluginBase {
* Set the block configuration. * Set the block configuration.
*/ */
public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) { public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) {
list($plugin, $delta, $old_settings, $visibility) = $value; list($plugin, $delta, $old_settings) = $value;
$settings = array(); $settings = array();
$settings['visibility']['request_path']['negate'] = !$visibility;
switch ($plugin) { switch ($plugin) {
case 'aggregator_feed_block': case 'aggregator_feed_block':
list(, $id) = explode('-', $delta); list(, $id) = explode('-', $delta);
......
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\BlockVisibility.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* @MigrateProcessPlugin(
* id = "d6_block_visibility"
* )
*/
class BlockVisibility extends ProcessPluginBase {
/**
* {@inheritdoc}
*
* Set the block visibility settings.
*/
public function transform($value, MigrateExecutable $migrate_executable, Row $row, $destination_property) {
list($pages, $roles, $old_visibility) = $value;
$visibility = array();
$visibility['request_path']['pages'] = $pages;
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = !$old_visibility;
if (!empty($roles)) {
$visibility['user_role']['roles'] = $roles;
$visibility['user_role']['id'] = 'user_role';
$visibility['user_role']['context_mapping']['user'] = 'user.current_user';
}
return $visibility;
}
}
...@@ -14,6 +14,15 @@ ...@@ -14,6 +14,15 @@
*/ */
abstract class MigrateDrupalTestBase extends MigrateTestBase { abstract class MigrateDrupalTestBase extends MigrateTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/** /**
* Modules to enable. * Modules to enable.
* *
......
...@@ -91,7 +91,7 @@ public function testBlockMigration() { ...@@ -91,7 +91,7 @@ public function testBlockMigration() {
$this->assertEqual('sidebar_first', $test_block_user->get('region')); $this->assertEqual('sidebar_first', $test_block_user->get('region'));
$this->assertEqual('bartik', $test_block_user->get('theme')); $this->assertEqual('bartik', $test_block_user->get('theme'));
$visibility = $test_block_user->getVisibility(); $visibility = $test_block_user->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertTrue(empty($visibility['request_path']['pages']));
$this->assertEqual(0, $test_block_user->weight); $this->assertEqual(0, $test_block_user->weight);
$test_block_user_1 = $blocks['user_1']; $test_block_user_1 = $blocks['user_1'];
...@@ -99,7 +99,7 @@ public function testBlockMigration() { ...@@ -99,7 +99,7 @@ public function testBlockMigration() {
$this->assertEqual('sidebar_first', $test_block_user_1->get('region')); $this->assertEqual('sidebar_first', $test_block_user_1->get('region'));
$this->assertEqual('bartik', $test_block_user_1->get('theme')); $this->assertEqual('bartik', $test_block_user_1->get('theme'));
$visibility = $test_block_user_1->getVisibility(); $visibility = $test_block_user_1->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertTrue(empty($visibility['request_path']['pages']));
$this->assertEqual(0, $test_block_user_1->weight); $this->assertEqual(0, $test_block_user_1->weight);
// Check system block // Check system block
...@@ -108,7 +108,7 @@ public function testBlockMigration() { ...@@ -108,7 +108,7 @@ public function testBlockMigration() {
$this->assertEqual('footer', $test_block_system->get('region')); $this->assertEqual('footer', $test_block_system->get('region'));
$this->assertEqual('bartik', $test_block_system->get('theme')); $this->assertEqual('bartik', $test_block_system->get('theme'));
$visibility = $test_block_system->getVisibility(); $visibility = $test_block_system->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertTrue(empty($visibility['request_path']['pages']));
$this->assertEqual(-5, $test_block_system->weight); $this->assertEqual(-5, $test_block_system->weight);
// Check menu blocks // Check menu blocks
...@@ -117,7 +117,7 @@ public function testBlockMigration() { ...@@ -117,7 +117,7 @@ public function testBlockMigration() {
$this->assertEqual('header', $test_block_menu->get('region')); $this->assertEqual('header', $test_block_menu->get('region'));
$this->assertEqual('bartik', $test_block_menu->get('theme')); $this->assertEqual('bartik', $test_block_menu->get('theme'));
$visibility = $test_block_menu->getVisibility(); $visibility = $test_block_menu->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertTrue(empty($visibility['request_path']['pages']));
$this->assertEqual(-5, $test_block_menu->weight); $this->assertEqual(-5, $test_block_menu->weight);
// Check custom blocks // Check custom blocks
...@@ -126,7 +126,7 @@ public function testBlockMigration() { ...@@ -126,7 +126,7 @@ public function testBlockMigration() {
$this->assertEqual('content', $test_block_block->get('region')); $this->assertEqual('content', $test_block_block->get('region'));
$this->assertEqual('bartik', $test_block_block->get('theme')); $this->assertEqual('bartik', $test_block_block->get('theme'));
$visibility = $test_block_block->getVisibility(); $visibility = $test_block_block->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertEqual($visibility['request_path']['pages'], '<front>');
$this->assertEqual(0, $test_block_block->weight); $this->assertEqual(0, $test_block_block->weight);
$test_block_block_1 = $blocks['block_1']; $test_block_block_1 = $blocks['block_1'];
...@@ -134,7 +134,7 @@ public function testBlockMigration() { ...@@ -134,7 +134,7 @@ public function testBlockMigration() {
$this->assertEqual('right', $test_block_block_1->get('region')); $this->assertEqual('right', $test_block_block_1->get('region'));
$this->assertEqual('bluemarine', $test_block_block_1->get('theme')); $this->assertEqual('bluemarine', $test_block_block_1->get('theme'));
$visibility = $test_block_block_1->getVisibility(); $visibility = $test_block_block_1->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertEqual($visibility['request_path']['pages'], 'node');
$this->assertEqual(-4, $test_block_block_1->weight); $this->assertEqual(-4, $test_block_block_1->weight);
$test_block_block_2 = $blocks['block_2']; $test_block_block_2 = $blocks['block_2'];
...@@ -142,7 +142,7 @@ public function testBlockMigration() { ...@@ -142,7 +142,7 @@ public function testBlockMigration() {
$this->assertEqual('right', $test_block_block_2->get('region')); $this->assertEqual('right', $test_block_block_2->get('region'));
$this->assertEqual('test_theme', $test_block_block_2->get('theme')); $this->assertEqual('test_theme', $test_block_block_2->get('theme'));
$visibility = $test_block_block_2->getVisibility(); $visibility = $test_block_block_2->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertTrue(empty($visibility['request_path']['pages']));
$this->assertEqual(-7, $test_block_block_2->weight); $this->assertEqual(-7, $test_block_block_2->weight);
$test_block_block_3 = $blocks['block_3']; $test_block_block_3 = $blocks['block_3'];
...@@ -150,7 +150,7 @@ public function testBlockMigration() { ...@@ -150,7 +150,7 @@ public function testBlockMigration() {
$this->assertEqual('left', $test_block_block_3->get('region')); $this->assertEqual('left', $test_block_block_3->get('region'));
$this->assertEqual('test_theme', $test_block_block_3->get('theme')); $this->assertEqual('test_theme', $test_block_block_3->get('theme'));
$visibility = $test_block_block_3->getVisibility(); $visibility = $test_block_block_3->getVisibility();
$this->assertTrue(empty($visibility['request_path'])); $this->assertTrue(empty($visibility['request_path']['pages']));
$this->assertEqual(-2, $test_block_block_3->weight); $this->assertEqual(-2, $test_block_block_3->weight);
} }
} }
...@@ -37,8 +37,8 @@ protected function setUp() { ...@@ -37,8 +37,8 @@ protected function setUp() {
*/ */
public function testSystemCron() { public function testSystemCron() {
$config = \Drupal::config('system.cron'); $config = \Drupal::config('system.cron');
$this->assertIdentical($config->get('threshold.warning'), 172800); $this->assertIdentical($config->get('threshold.requirements_warning'), 172800);
$this->assertIdentical($config->get('threshold.error'), 1209600); $this->assertIdentical($config->get('threshold.requirements_error'), 1209600);
} }
} }
...@@ -37,7 +37,6 @@ protected function setUp() { ...@@ -37,7 +37,6 @@ protected function setUp() {
*/ */
public function testSystemMaintenance() { public function testSystemMaintenance() {
$config = \Drupal::config('system.maintenance'); $config = \Drupal::config('system.maintenance');
$this->assertIdentical($config->get('enable'), 0);
$this->assertIdentical($config->get('message'), 'Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.'); $this->assertIdentical($config->get('message'), 'Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment