diff --git a/core/modules/language/migration_templates/default_language.yml b/core/modules/language/migration_templates/default_language.yml index f7c3cfe..9c1ac63 100644 --- a/core/modules/language/migration_templates/default_language.yml +++ b/core/modules/language/migration_templates/default_language.yml @@ -4,13 +4,25 @@ migration_tags: - Drupal 6 - Drupal 7 source: - plugin: language_default + plugin: variable + variables: + - language_default process: default_langcode: - + plugin: default_value + source: language_default + default_value: + 'language': 'en' + - + plugin: callback + callable: json_encode + - + plugin: callback + callable: json_decode + - plugin: callback callable: get_object_vars - source: language_default - plugin: extract index: diff --git a/core/modules/language/src/Plugin/migrate/source/LanguageDefault.php b/core/modules/language/src/Plugin/migrate/source/LanguageDefault.php deleted file mode 100644 index 4a44446..0000000 --- a/core/modules/language/src/Plugin/migrate/source/LanguageDefault.php +++ /dev/null @@ -1,71 +0,0 @@ -values())); - } - - /** - * Return the value of the language_default variable. - * - * @return array - * An associative array where the key is the variable name and the value is - * the value found in the database. If the variable does not exists, return - * English instead of nothing. - */ - protected function values() { - // Create an ID field so we can record migration in the map table. - $values['id'] = 'language_default'; - $results = $this->prepareQuery()->execute()->fetchAllKeyed(); - - // If the variable does not exist, we still need to return an object since - // it will be passed to the callback process plugin with get_object_vars() - // as callable and then the Extract process plugin. - if (empty($results)) { - $results['language_default'] = 'O:8:"stdClass":1:{s:8:"language";s:2:"en";}'; - } - - return $values + array_map('unserialize', $results); - } - - /** - * {@inheritdoc} - */ - public function fields() { - return ['language_default' => 'language_default']; - } - - /** - * {@inheritdoc} - */ - public function query() { - return $this->getDatabase() - ->select('variable', 'v') - ->fields('v', array('name', 'value')) - ->condition('name', 'language_default'); - } - - /** - * {@inheritdoc} - */ - public function getIds() { - $ids['id']['type'] = 'string'; - return $ids; - } - -} diff --git a/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php b/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php index 0f97698..14c2a7c 100644 --- a/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php +++ b/core/modules/language/tests/src/Kernel/Migrate/MigrateDefaultLanguageTrait.php @@ -38,7 +38,7 @@ protected function doTestMigration($langcode, $existing = TRUE) { // default_langcode config should be set. $default_language = ConfigurableLanguage::load($langcode); $this->assertNotNull($default_language); - $this->assertIdentical($langcode, $this->config('system.site')->get('default_langcode')); + $this->assertSame($langcode, $this->config('system.site')->get('default_langcode')); } else { // Otherwise, the migration log should contain an error message. @@ -46,10 +46,10 @@ protected function doTestMigration($langcode, $existing = TRUE) { $count = 0; foreach ($messages as $message) { $count++; - $this->assertEqual($message->message, "The language '$langcode' does not exist on this site."); - $this->assertEqual($message->level, MigrationInterface::MESSAGE_ERROR); + $this->assertSame($message->message, "The language '$langcode' does not exist on this site."); + $this->assertSame((int) $message->level, MigrationInterface::MESSAGE_ERROR); } - $this->assertEqual($count, 1); + $this->assertSame($count, 1); } } @@ -70,7 +70,7 @@ protected function doTestMigrationWithUnsetVariable() { $this->assertEmpty($messages); // Make sure the default langcode is 'en', since it was the default on D6 & D7. - $this->assertIdentical('en', $this->config('system.site')->get('default_langcode')); + $this->assertSame('en', $this->config('system.site')->get('default_langcode')); } }