Unverified Commit b9e1ed7c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3219140 by danflanagan8, huzooka, quietone, Wim Leers:...

Issue #3219140 by danflanagan8, huzooka, quietone, Wim Leers: d7_language_content_comment_settings triggers MigrateException if the source bundle is longer than 32 chars: use migration_lookup

(cherry picked from commit 0acc2f33)
parent 0865322d
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -8,22 +8,17 @@ source:
  plugin: d7_language_content_settings
  constants:
    target_type: comment
    id_prefix: comment_node_
    label_suffix: comment
process:
  target_bundle:
    -
      plugin: concat
      plugin: migration_lookup
      migration: d7_comment_type
      no_stub: true
      source:
        - constants/id_prefix
        - type
    -
      plugin: static_map
      bypass: true
      # The Forum module provides its own comment type (comment_forum), which we
      # want to reuse if it exists.
      map:
        comment_node_forum: comment_forum
      plugin: skip_on_empty
      method: row
  target_entity_type_id: constants/target_type
  default_langcode:
    -
+13 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ class MigrateLanguageContentCommentSettingsNoEntityTranslationTest extends Migra
   */
  protected function setUp(): void {
    parent::setUp();
    $this->startCollectingMessages();
    $this->migrateCommentTypes();
    $this->executeMigrations([
      'language',
@@ -57,6 +58,9 @@ public static function migrateDumpAlter(KernelTestBase $test) {
   * Tests migration of content language settings.
   */
  public function testLanguageCommentSettings() {
    // Confirm there is no message about a missing bundle.
    $this->assertEmpty($this->migrateMessages, $this->migrateMessages['error'][0] ?? '');

    // Article and Blog content type have multilingual settings of 'Enabled,
    // with Translation'. Assert that comments are translatable and the default
    // language is 'current_interface'.
@@ -88,6 +92,15 @@ public function testLanguageCommentSettings() {
    $this->assertTrue($config->isLanguageAlterable());
    $this->assertSame($third_party_settings, $config->get('third_party_settings'));

    // The content type with a long name has multilingual settings of 'Enabled'.
    $config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_a_thirty_two_char');
    $this->assertFalse($config->isNew());
    $this->assertSame('comment', $config->getTargetEntityTypeId());
    $this->assertSame('comment_node_a_thirty_two_char', $config->getTargetBundle());
    $this->assertSame('current_interface', $config->getDefaultLangcode());
    $this->assertTrue($config->isLanguageAlterable());
    $this->assertSame($third_party_settings, $config->get('third_party_settings'));

    // Test content type has multilingual settings of 'Enabled, with field
    // translation'.
    $config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_test_content_type');
+13 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ class MigrateLanguageContentCommentSettingsTest extends MigrateDrupal7TestBase {
   */
  protected function setUp(): void {
    parent::setUp();
    $this->startCollectingMessages();
    $this->migrateCommentTypes();
    $this->executeMigrations([
      'language',
@@ -39,6 +40,9 @@ protected function setUp(): void {
   * Tests migration of content language settings.
   */
  public function testLanguageCommentSettings() {
    // Confirm there is no message about a missing bundle.
    $this->assertEmpty($this->migrateMessages, $this->migrateMessages['error'][0] ?? '');

    // Article and Blog content type have multilingual settings of 'Enabled,
    // with Translation'. Assert that comments are translatable and the default
    // language is 'current_interface'.
@@ -70,6 +74,15 @@ public function testLanguageCommentSettings() {
    $this->assertTrue($config->isLanguageAlterable());
    $this->assertSame($third_party_settings, $config->get('third_party_settings'));

    // The content type with a long name has multilingual settings of 'Enabled'.
    $config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_a_thirty_two_char');
    $this->assertFalse($config->isNew());
    $this->assertSame('comment', $config->getTargetEntityTypeId());
    $this->assertSame('comment_node_a_thirty_two_char', $config->getTargetBundle());
    $this->assertSame('current_interface', $config->getDefaultLangcode());
    $this->assertTrue($config->isLanguageAlterable());
    $this->assertSame($third_party_settings, $config->get('third_party_settings'));

    // Test content type has multilingual settings of 'Enabled, with field
    // translation'.
    $config = ContentLanguageSettings::loadByEntityTypeBundle('comment', 'comment_node_test_content_type');
+4 −0
Original line number Diff line number Diff line
@@ -59872,6 +59872,10 @@
  'name' => 'language_content_type_article',
  'value' => 's:1:"2";',
))
->values(array(
  'name' => 'language_content_type_a_thirty_two_character_type_name',
  'value' => 's:1:"1";',
))
->values(array(
  'name' => 'language_content_type_blog',
  'value' => 's:1:"2";',
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ protected function getEntityCounts() {
      'file' => 3,
      'filter_format' => 7,
      'image_style' => 7,
      'language_content_settings' => 22,
      'language_content_settings' => 24,
      'node' => 7,
      'node_type' => 8,
      'rdf_mapping' => 8,