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:
- @plugin
- delta
- settings
visibility:
plugin: d6_block_visibility
source:
- pages
- roles
- visibility
'settings/visibility/request_path/pages': pages
'settings/visibility/user_role/roles': roles
destination:
plugin: entity:block
migration_dependencies:
......
......@@ -11,7 +11,7 @@ process:
entity_type: 'constants/entity_type'
bundle: type
field_name: 'constants/field_name'
default_value: 'options/promote'
'default_value/0/value': 'options/promote'
destination:
plugin: entity:base_field_override
migration_dependencies:
......
......@@ -11,7 +11,7 @@ process:
entity_type: 'constants/entity_type'
bundle: type
field_name: 'constants/field_name'
default_value: 'options/status'
'default_value/0/value': 'options/status'
destination:
plugin: entity:base_field_override
migration_dependencies:
......
......@@ -11,7 +11,7 @@ process:
entity_type: 'constants/entity_type'
bundle: type
field_name: 'constants/field_name'
default_value: 'options/sticky'
'default_value/0/value': 'options/sticky'
destination:
plugin: entity:base_field_override
migration_dependencies:
......
......@@ -9,8 +9,8 @@ source:
- cron_threshold_error
- cron_last
process:
'threshold/warning': cron_threshold_warning
'threshold/error': cron_threshold_error
'threshold/requirements_warning': cron_threshold_warning
'threshold/requirements_error': cron_threshold_error
destination:
plugin: config
config_name: system.cron
......@@ -5,10 +5,8 @@ migration_groups:
source:
plugin: variable
variables:
- site_offline
- site_offline_message
process:
enable: site_offline
message: site_offline_message
destination:
plugin: config
......
......@@ -11,7 +11,6 @@ source:
name: upload
type: file_generic
options:
label: hidden
settings:
progress_indicator: throbber
process:
......
......@@ -11,7 +11,6 @@ source:
name: user_picture
type: image_image
options:
label: hidden
settings:
progress_indicator: throbber
preview_image_style: thumbnail
......
......@@ -9,8 +9,6 @@ source:
entity_type: user
bundle: user
form_mode: default
options:
label: hidden
process:
entity_type: 'constants/entity_type'
bundle: 'constants/bundle'
......
......@@ -24,9 +24,8 @@ class BlockSettings extends ProcessPluginBase {
* Set the block configuration.
*/
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['visibility']['request_path']['negate'] = !$visibility;
switch ($plugin) {
case 'aggregator_feed_block':
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 @@
*/
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.
*
......
......@@ -91,7 +91,7 @@ public function testBlockMigration() {
$this->assertEqual('sidebar_first', $test_block_user->get('region'));
$this->assertEqual('bartik', $test_block_user->get('theme'));
$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);
$test_block_user_1 = $blocks['user_1'];
......@@ -99,7 +99,7 @@ public function testBlockMigration() {
$this->assertEqual('sidebar_first', $test_block_user_1->get('region'));
$this->assertEqual('bartik', $test_block_user_1->get('theme'));
$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);
// Check system block
......@@ -108,7 +108,7 @@ public function testBlockMigration() {
$this->assertEqual('footer', $test_block_system->get('region'));
$this->assertEqual('bartik', $test_block_system->get('theme'));
$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);
// Check menu blocks
......@@ -117,7 +117,7 @@ public function testBlockMigration() {
$this->assertEqual('header', $test_block_menu->get('region'));
$this->assertEqual('bartik', $test_block_menu->get('theme'));
$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);
// Check custom blocks
......@@ -126,7 +126,7 @@ public function testBlockMigration() {
$this->assertEqual('content', $test_block_block->get('region'));
$this->assertEqual('bartik', $test_block_block->get('theme'));
$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);
$test_block_block_1 = $blocks['block_1'];
......@@ -134,7 +134,7 @@ public function testBlockMigration() {
$this->assertEqual('right', $test_block_block_1->get('region'));
$this->assertEqual('bluemarine', $test_block_block_1->get('theme'));
$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);
$test_block_block_2 = $blocks['block_2'];
......@@ -142,7 +142,7 @@ public function testBlockMigration() {
$this->assertEqual('right', $test_block_block_2->get('region'));
$this->assertEqual('test_theme', $test_block_block_2->get('theme'));
$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);
$test_block_block_3 = $blocks['block_3'];
......@@ -150,7 +150,7 @@ public function testBlockMigration() {
$this->assertEqual('left', $test_block_block_3->get('region'));
$this->assertEqual('test_theme', $test_block_block_3->get('theme'));
$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);
}
}
......@@ -37,8 +37,8 @@ protected function setUp() {
*/
public function testSystemCron() {
$config = \Drupal::config('system.cron');
$this->assertIdentical($config->get('threshold.warning'), 172800);
$this->assertIdentical($config->get('threshold.error'), 1209600);
$this->assertIdentical($config->get('threshold.requirements_warning'), 172800);
$this->assertIdentical($config->get('threshold.requirements_error'), 1209600);
}
}
......@@ -37,7 +37,6 @@ protected function setUp() {
*/
public function testSystemMaintenance() {
$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.');
}
......
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