Commit 2bb91de3 authored by xjm's avatar xjm

Issue #2450251 by alexpott, xjm, sasanikolic, Berdir: Bundle cache is not...

Issue #2450251 by alexpott, xjm, sasanikolic, Berdir: Bundle cache is not invalidated after changing translation settings
parent 1f9eabbd
......@@ -293,10 +293,6 @@ function content_translation_form_language_content_settings_submit(array $form,
$entity_types = $form_state->getValue('entity_types');
$settings = &$form_state->getValue('settings');
// Ensure entity and menu router information are correctly rebuilt.
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->setRebuildNeeded();
// If an entity type is not translatable all its bundles and fields must be
// marked as non-translatable. Similarly, if a bundle is made non-translatable
// all of its fields will be not translatable.
......@@ -344,4 +340,8 @@ function content_translation_form_language_content_settings_submit(array $form,
}
}
}
// Ensure entity and menu router information are correctly rebuilt.
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->setRebuildNeeded();
}
......@@ -9,7 +9,6 @@
use Drupal\Component\Serialization\Json;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
......@@ -72,20 +71,12 @@ protected function setUp() {
$this->bundle = $this->randomMachineName();
$this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
// Enable translation for the current entity type and ensure the change is
// picked up.
\Drupal::service('content_translation.manager')->setEnabled('node', $this->bundle, TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedBundles();
\Drupal::service('router.builder')->rebuild();
// Add a translatable field to the content type.
// Add a field to the content type. The field is not yet translatable.
entity_create('field_storage_config', array(
'field_name' => 'field_test_text',
'entity_type' => 'node',
'type' => 'text',
'cardinality' => 1,
'translatable' => TRUE,
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
......@@ -100,11 +91,6 @@ protected function setUp() {
))
->save();
// Enable content translation.
ContentLanguageSettings::loadByEntityTypeBundle('node', $this->bundle)
->setLanguageAlterable(TRUE)
->setDefaultLangcode(\Drupal::languageManager()->getDefaultLanguage()->getId())
->save();
// Create a translator user.
$permissions = array(
'access contextual links',
......@@ -124,6 +110,18 @@ public function testContentTranslationContextualLinks() {
$this->drupalCreateNode(array('type' => $this->bundle, 'title' => $title, 'langcode' => 'en'));
$node = $this->drupalGetNodeByTitle($title);
// Use a UI form submission to make the node type and field translatable.
// This tests that caches are properly invalidated.
$this->drupalLogin($this->rootUser);
$edit = array(
'entity_types[node]' => TRUE,
'settings[node][' . $this->bundle . '][settings][language][language_alterable]' => TRUE,
'settings[node][' . $this->bundle . '][translatable]' => TRUE,
'settings[node][' . $this->bundle . '][fields][field_test_text]' => TRUE,
);
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$this->drupalLogout();
// Check that the translate link appears on the node page.
$this->drupalLogin($this->translator);
$translate_link = 'node/' . $node->id() . '/translations';
......
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