Commit b06eee20 authored by webchick's avatar webchick

Issue #2353679 by quietone, densolis, phenaproxima, ultimike: D6->D8 Migration...

Issue #2353679 by quietone, densolis, phenaproxima, ultimike: D6->D8 Migration missing variable: date_default_timezone
parent 3a38bef3
...@@ -251,12 +251,12 @@ public function load() { ...@@ -251,12 +251,12 @@ public function load() {
'access' => '1391259674', 'access' => '1391259674',
'login' => '1391152255', 'login' => '1391152255',
'status' => '1', 'status' => '1',
'timezone' => '3600', 'timezone' => '-28800',
'language' => 'en', 'language' => 'en',
'picture' => '', 'picture' => '',
'init' => 'bloggs@example.com', 'init' => 'bloggs@example.com',
'data' => 'a:0:{}', 'data' => 'a:0:{}',
'timezone_name' => NULL, 'timezone_name' => 'America/Anchorage',
'pass_plain' => 'joe.bloggs_pass', 'pass_plain' => 'joe.bloggs_pass',
'expected_timezone' => NULL, 'expected_timezone' => NULL,
'timezone_id' => '0', 'timezone_id' => '0',
...@@ -275,12 +275,12 @@ public function load() { ...@@ -275,12 +275,12 @@ public function load() {
'access' => '1391259574', 'access' => '1391259574',
'login' => '1391162255', 'login' => '1391162255',
'status' => '1', 'status' => '1',
'timezone' => '3600', 'timezone' => '0',
'language' => 'en', 'language' => 'en',
'picture' => '', 'picture' => '',
'init' => 'sal.saraniti@example.com', 'init' => 'sal.saraniti@example.com',
'data' => 'a:0:{}', 'data' => 'a:0:{}',
'timezone_name' => NULL, 'timezone_name' => 'UTC',
'pass_plain' => 'sal.saraniti', 'pass_plain' => 'sal.saraniti',
'expected_timezone' => NULL, 'expected_timezone' => NULL,
'timezone_id' => '0', 'timezone_id' => '0',
...@@ -299,7 +299,7 @@ public function load() { ...@@ -299,7 +299,7 @@ public function load() {
'access' => '1390259574', 'access' => '1390259574',
'login' => '1390162255', 'login' => '1390162255',
'status' => '1', 'status' => '1',
'timezone' => '3600', 'timezone' => NULL,
'language' => 'en', 'language' => 'en',
'picture' => '', 'picture' => '',
'init' => 'terry.saraniti@example.com', 'init' => 'terry.saraniti@example.com',
...@@ -312,4 +312,4 @@ public function load() { ...@@ -312,4 +312,4 @@ public function load() {
} }
} }
#ce6d7264b7ef5ed1ffe854326893e1e0 #4a42570fa3c819b0b84e9552d689e2e7
...@@ -172,6 +172,9 @@ public function load() { ...@@ -172,6 +172,9 @@ public function load() {
))->values(array( ))->values(array(
'name' => 'comment_subject_field_story', 'name' => 'comment_subject_field_story',
'value' => 's:1:"0";', 'value' => 's:1:"0";',
))->values(array(
'name' => 'configurable_timezones',
'value' => 's:1:"0";',
))->values(array( ))->values(array(
'name' => 'contact_default_status', 'name' => 'contact_default_status',
'value' => 'i:1;', 'value' => 'i:1;',
...@@ -379,6 +382,12 @@ public function load() { ...@@ -379,6 +382,12 @@ public function load() {
))->values(array( ))->values(array(
'name' => 'date_api_version', 'name' => 'date_api_version',
'value' => 's:3:"5.2";', 'value' => 's:3:"5.2";',
))->values(array(
'name' => 'date_default_timezone',
'value' => 's:4:"3600";',
))->values(array(
'name' => 'date_first_day',
'value' => 's:1:"4";',
))->values(array( ))->values(array(
'name' => 'date_format_long', 'name' => 'date_format_long',
'value' => 's:24:"\L\O\N\G l, F j, Y - H:i";', 'value' => 's:24:"\L\O\N\G l, F j, Y - H:i";',
...@@ -725,4 +734,4 @@ public function load() { ...@@ -725,4 +734,4 @@ public function load() {
} }
} }
#32b72a0543c243804368c7bc10b05be5 #dd0717c35d3b181c80e5ad74ea2ed2f7
...@@ -117,6 +117,7 @@ class MigrateDrupal6Test extends MigrateFullDrupalTestBase { ...@@ -117,6 +117,7 @@ class MigrateDrupal6Test extends MigrateFullDrupalTestBase {
'd6_statistics_settings', 'd6_statistics_settings',
'd6_syslog_settings', 'd6_syslog_settings',
'd6_system_cron', 'd6_system_cron',
'd6_system_date',
'd6_system_file', 'd6_system_file',
'd6_system_image', 'd6_system_image',
'd6_system_image_gd', 'd6_system_image_gd',
......
id: d6_system_date
label: Drupal 6 system date configuration
migration_tags:
- Drupal 6
source:
plugin: variable
variables:
- configurable_timezones
- date_first_day
- date_default_timezone
process:
'timezone/user/configurable': configurable_timezones
first_day: date_first_day
'timezone/default':
plugin: timezone
source: date_default_timezone
destination:
plugin: config
config_name: system.date
<?php
/**
* @file
* Contains \Drupal\systeml\Plugin\migrate\process\d6\TimeZone.
*/
namespace Drupal\system\Plugin\migrate\process\d6;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Process the D6 Timezone offset into a D8 compatible timezone name.
*
* @MigrateProcessPlugin(
* id = "timezone"
* )
*/
class TimeZone extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$offset = $value;
// Convert the integer value of the offset (which can be either
// negative or positive) to a timezone name.
// Note: Daylight saving time is not to be used.
$timezone_name = timezone_name_from_abbr('', intval($offset), 0);
if (!$timezone_name) {
$timezone_name = 'UTC';
}
return $timezone_name;
}
}
<?php
/**
* @file
* Contains \Drupal\system\Tests\Migrate\d6\MigrateSystemDateTest.
*/
namespace Drupal\system\Tests\Migrate\d6;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade date time variables to system.date config
*
* @group migrate_drupal_6
*/
class MigrateSystemDateTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_system_date');
}
/**
* Tests migration of user variables to system_date.yml.
*/
public function testSystemDate() {
$config = $this->config('system.date');
$this->assertIdentical(4, $config->get('first_day'));
$this->assertIdentical(FALSE, $config->get('timezone.user.configurable'));
$this->assertIdentical("Europe/Paris", $config->get('timezone.default'));
}
}
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row; use Drupal\migrate\Row;
use Drupal\Core\Config\Config;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Converts user time zones from time zone offsets to time zone names. * Converts user time zones from time zone offsets to time zone names.
...@@ -18,7 +21,7 @@ ...@@ -18,7 +21,7 @@
* id = "user_update_7002" * id = "user_update_7002"
* ) * )
*/ */
class UserUpdate7002 extends ProcessPluginBase { class UserUpdate7002 extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/** /**
* System timezones. * System timezones.
...@@ -27,16 +30,35 @@ class UserUpdate7002 extends ProcessPluginBase { ...@@ -27,16 +30,35 @@ class UserUpdate7002 extends ProcessPluginBase {
*/ */
protected static $timezones; protected static $timezones;
/**
* Contains the system.theme configuration object.
*
* @var \Drupal\Core\Config\Config
*/
protected $dateConfig;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, array $plugin_definition) { public function __construct(array $configuration, $plugin_id, array $plugin_definition, Config $date_config) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->dateConfig = $date_config;
if (!isset(static::$timezones)) { if (!isset(static::$timezones)) {
static::$timezones = system_time_zones(); static::$timezones = system_time_zones();
} }
} }
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('config.factory')->get('system.date')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -54,6 +76,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable ...@@ -54,6 +76,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
} }
} }
if ($timezone === NULL) {
$timezone = $this->dateConfig->get('timezone.default');
}
return $timezone; return $timezone;
} }
......
...@@ -151,8 +151,8 @@ public function testUser() { ...@@ -151,8 +151,8 @@ public function testUser() {
// user preferred language is not configured on the site. We just want to // user preferred language is not configured on the site. We just want to
// test if the value was imported correctly. // test if the value was imported correctly.
$this->assertIdentical($source->language, $user->preferred_langcode->value); $this->assertIdentical($source->language, $user->preferred_langcode->value);
$time_zone = $source->expected_timezone ?: $this->config('system.date')->get('timezone.default'); $expected_timezone_name = $source->timezone_name ?: $this->config('system.date')->get('timezone.default');
$this->assertIdentical($time_zone, $user->getTimeZone()); $this->assertIdentical($expected_timezone_name, $user->getTimeZone());
$this->assertIdentical($source->init, $user->getInitialEmail()); $this->assertIdentical($source->init, $user->getInitialEmail());
$this->assertIdentical($roles, $user->getRoles()); $this->assertIdentical($roles, $user->getRoles());
......
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