updated core to 8.6.3

This commit is contained in:
2018-11-21 12:49:46 +01:00
parent 8ca34853a3
commit c92c348eee
521 changed files with 12199 additions and 4578 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_
$config->setLanguageAlterable($form_state->getValue([$element_name, 'language_alterable']));
$config->save();
// Set the form_state languaged with the updated bundle.
// Set the form_state language with the updated bundle.
$form_state->set('language', $language);
}
}
@@ -0,0 +1,53 @@
id: d6_language_content_taxonomy_vocabulary_settings
label: Drupal 6 language taxonomy vocabulary settings
migration_tags:
- Drupal 6
- Configuration
source:
plugin: d6_language_content_settings_taxonomy_vocabulary
constants:
target_type: 'taxonomy_term'
default_langcode: 'site_default'
process:
target_bundle:
-
plugin: migration_lookup
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: skip_on_empty
method: row
# State is the value in the i18ntaxonomy_vocabulary array defined as:
# 0: No multilingual options.
# 1: Localizable terms. Run through the localization system.
# 2: Predefined language for a vocabulary and its terms.
# 3: Per-language terms, translatable (referencing terms with different
# languages) but not localizable.
language_alterable:
plugin: static_map
source: state
map:
0: false
1: true
2: false
3: true
'third_party_settings/content_translation/enabled':
plugin: static_map
source: state
map:
0: false
1: true
2: false
3: false
target_entity_type_id: 'constants/target_type'
default_langcode:
plugin: default_value
default_value: site_default
source: language
destination:
plugin: entity:language_content_settings
content_translation_update_definitions:
- taxonomy_term
migration_dependencies:
required:
- d6_taxonomy_vocabulary
@@ -75,7 +75,7 @@ class LanguageConfigFactoryOverride extends ConfigFactoryOverrideBase implements
$this->baseStorage = $storage;
$this->eventDispatcher = $event_dispatcher;
$this->typedConfigManager = $typed_config;
// Prior to negiotiation the override language should be the default
// Prior to negotiation the override language should be the default
// language.
$this->language = $default_language->get();
}
@@ -0,0 +1,65 @@
<?php
namespace Drupal\language\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 i18n vocabularies source from database.
*
* @MigrateSource(
* id = "d6_language_content_settings_taxonomy_vocabulary",
* source_module = "taxonomy"
* )
*/
class LanguageContentSettingsTaxonomyVocabulary extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
return $this->select('vocabulary', 'v')
->fields('v', ['vid', 'language']);
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'vid' => $this->t('The vocabulary ID.'),
'language' => $this->t('The default language for new terms.'),
'state' => $this->t('The i18n taxonomy translation setting.'),
];
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Get the i18n taxonomy translation setting for this vocabulary.
// 0 - No multilingual options
// 1 - Localizable terms. Run through the localization system.
// 2 - Predefined language for a vocabulary and its terms.
// 3 - Per-language terms, translatable (referencing terms with different
// languages) but not localizable.
$i18ntaxonomy_vocabulary = $this->variableGet('i18ntaxonomy_vocabulary', NULL);
$vid = $row->getSourceProperty('vid');
$state = FALSE;
if (array_key_exists($vid, $i18ntaxonomy_vocabulary)) {
$state = $i18ntaxonomy_vocabulary[$vid];
}
$row->setSourceProperty('state', $state);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['vid']['type'] = 'integer';
return $ids;
}
}
@@ -2,7 +2,9 @@
namespace Drupal\Tests\language\Functional;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationBrowser;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected;
@@ -39,6 +41,13 @@ use Drupal\block\Entity\Block;
*/
class LanguageUILanguageNegotiationTest extends BrowserTestBase {
/**
* The admin user for testing.
*
* @var \Drupal\user\Entity\User
*/
protected $adminUser;
/**
* Modules to enable.
*
@@ -53,8 +62,8 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$admin_user = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages', 'administer blocks']);
$this->drupalLogin($admin_user);
$this->adminUser = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages', 'administer blocks']);
$this->drupalLogin($this->adminUser);
}
/**
@@ -73,6 +82,17 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase {
// For setting browser language preference to some unknown.
$http_header_blah = ["Accept-Language" => "blah;q=1"];
// Create a private file for testing accessible by the admin user.
drupal_mkdir($this->privateFilesDirectory . '/test');
$filepath = 'private://test/private-file-test.txt';
$contents = "file_put_contents() doesn't seem to appreciate empty strings so let's put in some data.";
file_put_contents($filepath, $contents);
$file = File::create([
'uri' => $filepath,
'uid' => $this->adminUser->id(),
]);
$file->save();
// Setup the site languages by installing two languages.
// Set the default language in order for the translated string to be registered
// into database when seen by t(). Without doing this, our target string
@@ -242,6 +262,21 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase {
];
$this->doRunTest($test);
// Set preferred langcode for user to default langcode.
$account = $this->loggedInUser;
$account->preferred_langcode = $default_language->getId();
$account->save();
$test = [
'language_negotiation' => [LanguageNegotiationUser::METHOD_ID, LanguageNegotiationUrl::METHOD_ID],
'path' => "$langcode/admin/config",
'expect' => $default_string,
'expected_method_id' => LanguageNegotiationUser::METHOD_ID,
'http_header' => [],
'message' => 'USER > URL: User has default language as preferred user language setting, the UI language is default',
];
$this->doRunTest($test);
// Set preferred langcode for user to unknown language.
$account = $this->loggedInUser;
$account->preferred_langcode = $langcode_unknown;
@@ -359,6 +394,13 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase {
$this->drupalGet($test['path'], $test['path_options'], $test['http_header']);
$this->assertText($test['expect'], $test['message']);
$this->assertText(t('Language negotiation method: @name', ['@name' => $test['expected_method_id']]));
// Get the private file and ensure it is a 200. It is important to
// invalidate the router cache to ensure the routing system runs a full
// match.
Cache::invalidateTags(['route_match']);
$this->drupalGet('system/files/test/private-file-test.txt');
$this->assertResponse(200);
}
/**
@@ -25,6 +25,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal6TestBase {
parent::setUp();
$this->installConfig(['node']);
$this->installEntitySchema('node');
$this->executeMigrations(['d6_node_type', 'd6_language_content_settings']);
}
@@ -0,0 +1,80 @@
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d6;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Tests migration of i18ntaxonomy vocabulary settings.
*
* @group migrate_drupal_6
*/
class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'language',
'content_translation',
'taxonomy',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->executeMigrations([
'language',
'd6_taxonomy_vocabulary',
'd6_language_content_taxonomy_vocabulary_settings',
]);
}
/**
* Tests migration of 18ntaxonomy vocabulary settings.
*/
public function testLanguageContentTaxonomy() {
$target_entity = 'taxonomy_term';
// Per Language.
$this->assertLanguageContentSettings($target_entity, 'vocabulary_1_i_0_', LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE, ['enabled' => FALSE]);
// Set language to vocabulary.
$this->assertLanguageContentSettings($target_entity, 'vocabulary_2_i_1_', 'fr', FALSE, ['enabled' => FALSE]);
// Localize terms.
$this->assertLanguageContentSettings($target_entity, 'vocabulary_3_i_2_', LanguageInterface::LANGCODE_SITE_DEFAULT, TRUE, ['enabled' => TRUE]);
// None translation enabled.
$this->assertLanguageContentSettings($target_entity, 'vocabulary_name_much_longer_than', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, ['enabled' => FALSE]);
$this->assertLanguageContentSettings($target_entity, 'tags', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, ['enabled' => FALSE]);
$this->assertLanguageContentSettings($target_entity, 'forums', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, ['enabled' => FALSE]);
$this->assertLanguageContentSettings($target_entity, 'type', LanguageInterface::LANGCODE_SITE_DEFAULT, FALSE, ['enabled' => FALSE]);
}
/**
* Asserts a content language settings configuration.
*
* @param string $target_entity
* The expected target entity type.
* @param string $bundle
* The expected bundle.
* @param string $default_langcode
* The default language code.
* @param bool $language_alterable
* The expected state of language alterable.
* @param array $third_party_settings
* The content translation setting.
*/
public function assertLanguageContentSettings($target_entity, $bundle, $default_langcode, $language_alterable, array $third_party_settings) {
$config = ContentLanguageSettings::load($target_entity . "." . $bundle);
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
$this->assertSame($target_entity, $config->getTargetEntityTypeId());
$this->assertSame($bundle, $config->getTargetBundle());
$this->assertSame($default_langcode, $config->getDefaultLangcode());
$this->assertSame($language_alterable, $config->isLanguageAlterable());
$this->assertSame($third_party_settings, $config->getThirdPartySettings('content_translation'));
}
}
@@ -25,6 +25,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
parent::setUp();
$this->installConfig(['node']);
$this->installEntitySchema('node');
$this->executeMigrations(['d7_node_type', 'd7_language_content_settings']);
}
@@ -0,0 +1,81 @@
<?php
namespace Drupal\Tests\language\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests i18ntaxonomy vocabulary setting source plugin.
*
* @covers \Drupal\language\Plugin\migrate\source\d6\LanguageContentSettingsTaxonomyVocabulary
*
* @group language
*/
class LanguageContentTaxonomyVocabularySettingsTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['taxonomy', 'language', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['vocabulary'] = [
[
'vid' => 1,
'name' => 'Tags',
'description' => 'Tags description.',
'help' => 1,
'relations' => 0,
'hierarchy' => 0,
'multiple' => 0,
'required' => 0,
'tags' => 1,
'module' => 'taxonomy',
'weight' => 0,
'language' => '',
],
[
'vid' => 2,
'name' => 'Categories',
'description' => 'Categories description.',
'help' => 1,
'relations' => 1,
'hierarchy' => 1,
'multiple' => 0,
'required' => 1,
'tags' => 0,
'module' => 'taxonomy',
'weight' => 0,
'language' => 'zu',
],
];
$tests[0]['source_data']['variable'] = [
[
'name' => 'i18ntaxonomy_vocabulary',
'value' => 'a:4:{i:1;s:1:"3";i:2;s:1:"2";i:3;s:1:"3";i:5;s:1:"1";}',
],
];
$tests[0]['expected_data'] = [
[
'vid' => 1,
'language' => '',
'state' => 3,
],
[
'vid' => 2,
'language' => 'zu',
'state' => 2,
],
];
return $tests;
}
}