Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
288
Merge Requests
288
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
82284fa0
Commit
82284fa0
authored
Aug 18, 2017
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2669030
by maxocub, sbogner: D6 Forum vocabulary is migrated to the wrong D8 field name
parent
a47d8c49
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
309 additions
and
8 deletions
+309
-8
core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php
...m/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php
+1
-1
core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php
...es/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php
+77
-0
core/modules/migrate_drupal/migrate_drupal.module
core/modules/migrate_drupal/migrate_drupal.module
+9
-1
core/modules/migrate_drupal/tests/fixtures/drupal6.php
core/modules/migrate_drupal/tests/fixtures/drupal6.php
+156
-2
core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
...drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
+4
-4
core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml
...nomy/migration_templates/d6_vocabulary_entity_display.yml
+5
-0
core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml
...migration_templates/d6_vocabulary_entity_form_display.yml
+5
-0
core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml
...ules/taxonomy/migration_templates/d6_vocabulary_field.yml
+5
-0
core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml
...nomy/migration_templates/d6_vocabulary_field_instance.yml
+5
-0
core/modules/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php
...s/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php
+34
-0
core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
...ules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
+8
-0
No files found.
core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumConfigsTest.php
View file @
82284fa0
...
...
@@ -36,7 +36,7 @@ public function testForumSettings() {
$this
->
assertIdentical
(
15
,
$config
->
get
(
'topics.hot_threshold'
));
$this
->
assertIdentical
(
25
,
$config
->
get
(
'topics.page_limit'
));
$this
->
assertIdentical
(
1
,
$config
->
get
(
'topics.order'
));
$this
->
assertIdentical
(
'
vocabulary_1_i_0_
'
,
$config
->
get
(
'vocabulary'
));
$this
->
assertIdentical
(
'
forums
'
,
$config
->
get
(
'vocabulary'
));
// This is 'forum_block_num_0' in D6, but block:active:limit' in D8.
$this
->
assertSame
(
3
,
$config
->
get
(
'block.active.limit'
));
// This is 'forum_block_num_1' in D6, but 'block:new:limit' in D8.
...
...
core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateForumTest.php
0 → 100644
View file @
82284fa0
<?php
namespace
Drupal\Tests\forum\Kernel\Migrate\d6
;
use
Drupal\Core\Entity\Entity\EntityFormDisplay
;
use
Drupal\Core\Entity\Entity\EntityViewDisplay
;
use
Drupal\field\Entity\FieldConfig
;
use
Drupal\field\Entity\FieldStorageConfig
;
use
Drupal\node\Entity\Node
;
use
Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeTestBase
;
/**
* Tests forum migration from Drupal 6 to Drupal 8.
*
* @group migrate_drupal_6
*/
class
MigrateForumTest
extends
MigrateNodeTestBase
{
/**
* {@inheritdoc}
*/
public
static
$modules
=
[
'comment'
,
'forum'
,
'menu_ui'
,
'taxonomy'
,
];
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
installEntitySchema
(
'comment'
);
$this
->
installSchema
(
'comment'
,
[
'comment_entity_statistics'
]);
$this
->
installSchema
(
'forum'
,
[
'forum'
,
'forum_index'
]);
$this
->
installConfig
([
'comment'
,
'forum'
]);
$this
->
migrateContent
();
$this
->
migrateTaxonomy
();
$this
->
executeMigrations
([
'd6_comment_type'
,
'd6_comment_field'
,
'd6_comment_field_instance'
,
'd6_comment_entity_display'
,
'd6_comment_entity_form_display'
,
'd6_comment'
,
'd6_term_node'
,
]);
}
/**
* Tests forum migration.
*/
public
function
testForumMigration
()
{
// Tests that the taxonomy_forums field storage config exists.
$field_storage_config
=
FieldStorageConfig
::
load
(
'node.taxonomy_forums'
);
$this
->
assertInstanceOf
(
FieldStorageConfig
::
class
,
$field_storage_config
);
// Tests that the taxonomy_forums field config exists.
$field_config
=
FieldConfig
::
load
(
'node.forum.taxonomy_forums'
);
$this
->
assertInstanceOf
(
FieldConfig
::
class
,
$field_config
);
// Tests that the taxonomy_forums entity view display component exists.
$entity_view_display
=
EntityViewDisplay
::
load
(
'node.forum.default'
)
->
getComponent
(
'taxonomy_forums'
);
$this
->
assertTrue
(
is_array
(
$entity_view_display
));
// Tests that the taxonomy_forums entity form display component exists.
$entity_form_display
=
EntityFormDisplay
::
load
(
'node.forum.default'
)
->
getComponent
(
'taxonomy_forums'
);
$this
->
assertTrue
(
is_array
(
$entity_form_display
));
// Test that the taxonomy_forums field has the right value.
$node
=
Node
::
load
(
19
);
$this
->
assertEquals
(
8
,
$node
->
taxonomy_forums
->
target_id
);
}
}
core/modules/migrate_drupal/migrate_drupal.module
View file @
82284fa0
...
...
@@ -58,7 +58,15 @@ function migrate_drupal_migration_plugins_alter(&$definitions) {
foreach
(
$plugin_ids
as
$plugin_id
)
{
// Match the field name derivation in d6_vocabulary_field.yml.
$field_name
=
substr
(
'field_'
.
$row
->
getDestinationProperty
(
'vid'
),
0
,
32
);
$definitions
[
$plugin_id
][
'process'
][
$field_name
]
=
'tid'
;
// The Forum module is expecting 'taxonomy_forums' as the field name
// for the forum nodes. The 'forum_vocabulary' source property is
// evaluated in Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
// and is set to true if the vocabulary vid being migrated is the
// same as the one in the 'forum_nav_vocabulary' variable on the
// source site.
$destination_vid
=
$row
->
getSourceProperty
(
'forum_vocabulary'
)
?
'taxonomy_forums'
:
$field_name
;
$definitions
[
$plugin_id
][
'process'
][
$destination_vid
]
=
'tid'
;
}
}
}
...
...
core/modules/migrate_drupal/tests/fixtures/drupal6.php
View file @
82284fa0
...
...
@@ -1942,6 +1942,54 @@
'mail' => 'comment3@example.com',
'homepage' => 'https://www.drupal.org',
))
->values(array(
'cid' => '4',
'pid' => '0',
'nid' => '19',
'uid' => '1',
'subject' => 'Subject 1',
'comment' => 'Comment 1',
'hostname' => '127.0.0.1',
'timestamp' => '1501955780',
'status' => '0',
'format' => '1',
'thread' => '01/',
'name' => 'root',
'mail' => '',
'homepage' => '',
))
->values(array(
'cid' => '5',
'pid' => '4',
'nid' => '19',
'uid' => '1',
'subject' => 'Subject 2',
'comment' => 'Comment 2',
'hostname' => '127.0.0.1',
'timestamp' => '1501955792',
'status' => '0',
'format' => '1',
'thread' => '01.00/',
'name' => 'root',
'mail' => '',
'homepage' => '',
))
->values(array(
'cid' => '6',
'pid' => '5',
'nid' => '19',
'uid' => '1',
'subject' => 'Subject 3',
'comment' => 'Comment 3',
'hostname' => '127.0.0.1',
'timestamp' => '1501955803',
'status' => '0',
'format' => '1',
'thread' => '01.00.00/',
'name' => 'root',
'mail' => '',
'homepage' => '',
))
->execute();
$connection->schema()->createTable('config', array(
...
...
@@ -8345,6 +8393,19 @@
'mysql_character_set' => 'utf8',
));
$connection->insert('forum')
->fields(array(
'nid',
'vid',
'tid',
))
->values(array(
'nid' => '19',
'vid' => '22',
'tid' => '8',
))
->execute();
$connection->schema()->createTable('history', array(
'fields' => array(
'uid' => array(
...
...
@@ -8424,6 +8485,11 @@
'nid' => '18',
'timestamp' => '1493066711',
))
->values(array(
'uid' => '1',
'nid' => '19',
'timestamp' => '1501955803',
))
->execute();
$connection->schema()->createTable('i18n_blocks', array(
...
...
@@ -9566,6 +9632,14 @@
'objectindex' => '6',
'format' => '0',
))
->values(array(
'lid' => '1673',
'objectid' => '7',
'type' => 'vocabulary',
'property' => 'name',
'objectindex' => '7',
'format' => '0',
))
->execute();
$connection->schema()->createTable('i18n_variable', array(
...
...
@@ -22025,6 +22099,13 @@
'source' => 'Type',
'version' => '1',
))
->values(array(
'lid' => '1673',
'location' => 'vocabulary:7:name',
'textgroup' => 'taxonomy',
'source' => 'Forums',
'version' => '1',
))
->execute();
$connection->schema()->createTable('locales_target', array(
...
...
@@ -43185,6 +43266,23 @@
'tnid' => '0',
'translate' => '0',
))
->values(array(
'nid' => '19',
'vid' => '22',
'type' => 'forum',
'language' => '',
'title' => 'New Forum Topic',
'uid' => '1',
'status' => '1',
'created' => '1501955771',
'changed' => '1501955771',
'comment' => '2',
'promote' => '0',
'moderate' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
))
->execute();
$connection->schema()->createTable('node_access', array(
...
...
@@ -43384,6 +43482,13 @@
'last_comment_uid' => '1',
'comment_count' => '0',
))
->values(array(
'nid' => '19',
'last_comment_timestamp' => '1501955803',
'last_comment_name' => '',
'last_comment_uid' => '1',
'comment_count' => '3',
))
->execute();
$connection->schema()->createTable('node_counter', array(
...
...
@@ -43459,6 +43564,12 @@
'daycount' => '1',
'timestamp' => '1493066711',
))
->values(array(
'nid' => '19',
'totalcount' => '4',
'daycount' => '4',
'timestamp' => '1501955803',
))
->execute();
$connection->schema()->createTable('node_revisions', array(
...
...
@@ -43765,6 +43876,17 @@
'timestamp' => '1494966544',
'format' => '1',
))
->values(array(
'nid' => '19',
'vid' => '22',
'uid' => '1',
'title' => 'New Forum Topic',
'body' => 'New Forum Body',
'teaser' => 'New Forum Body',
'log' => '',
'timestamp' => '1501955771',
'format' => '1',
))
->execute();
$connection->schema()->createTable('node_type', array(
...
...
@@ -46041,6 +46163,15 @@
'language' => 'fr',
'trid' => '0',
))
->values(array(
'tid' => '8',
'vid' => '7',
'name' => 'General discussion',
'description' => '',
'weight' => '0',
'language' => '',
'trid' => '0',
))
->execute();
$connection->schema()->createTable('term_hierarchy', array(
...
...
@@ -46088,6 +46219,10 @@
'tid' => '7',
'parent' => '0',
))
->values(array(
'tid' => '8',
'parent' => '0',
))
->values(array(
'tid' => '3',
'parent' => '2',
...
...
@@ -46173,6 +46308,11 @@
'vid' => '2',
'tid' => '5',
))
->values(array(
'nid' => '19',
'vid' => '22',
'tid' => '8',
))
->execute();
$connection->schema()->createTable('term_relation', array(
...
...
@@ -47651,7 +47791,7 @@
))
->values(array(
'name' => 'forum_nav_vocabulary',
'value' => 's:1:"
1
";',
'value' => 's:1:"
7
";',
))
->values(array(
'name' => 'forum_order',
...
...
@@ -48255,6 +48395,20 @@
'weight' => '0',
'language' => '',
))
->values(array(
'vid' => '7',
'name' => 'Forums',
'description' => '',
'help' => '',
'relations' => '1',
'hierarchy' => '0',
'multiple' => '0',
'required' => '0',
'tags' => '0',
'module' => 'taxonomy',
'weight' => '0',
'language' => '',
))
->execute();
$connection->schema()->createTable('vocabulary_node_types', array(
...
...
@@ -48290,7 +48444,7 @@
'type' => 'article',
))
->values(array(
'vid' => '
1
',
'vid' => '
7
',
'type' => 'forum',
))
->values(array(
core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php
View file @
82284fa0
...
...
@@ -39,19 +39,19 @@ protected function getEntityCounts() {
'block'
=>
35
,
'block_content'
=>
2
,
'block_content_type'
=>
1
,
'comment'
=>
3
,
'comment'
=>
6
,
'comment_type'
=>
3
,
'contact_form'
=>
5
,
'configurable_language'
=>
5
,
'editor'
=>
2
,
'field_config'
=>
7
3
,
'field_config'
=>
7
2
,
'field_storage_config'
=>
48
,
'file'
=>
7
,
'filter_format'
=>
7
,
'image_style'
=>
5
,
'language_content_settings'
=>
2
,
'migration'
=>
105
,
'node'
=>
1
6
,
'node'
=>
1
7
,
'node_type'
=>
13
,
'rdf_mapping'
=>
7
,
'search_page'
=>
2
,
...
...
@@ -59,7 +59,7 @@ protected function getEntityCounts() {
'shortcut_set'
=>
1
,
'action'
=>
23
,
'menu'
=>
8
,
'taxonomy_term'
=>
7
,
'taxonomy_term'
=>
8
,
'taxonomy_vocabulary'
=>
7
,
'tour'
=>
4
,
'user'
=>
7
,
...
...
core/modules/taxonomy/migration_templates/d6_vocabulary_entity_display.yml
View file @
82284fa0
...
...
@@ -44,6 +44,11 @@ process:
-
plugin
:
substr
length
:
32
-
# This plugin checks if the vocabulary being migrated is the one used for
# forums. If it is, the field name is set to 'taxonomy_forums' as it is
# what the Forum module is expecting. Otherwise, it is left unchanged.
plugin
:
forum_vocabulary
destination
:
plugin
:
component_entity_display
migration_dependencies
:
...
...
core/modules/taxonomy/migration_templates/d6_vocabulary_entity_form_display.yml
View file @
82284fa0
...
...
@@ -48,6 +48,11 @@ process:
-
plugin
:
substr
length
:
32
-
# This plugin checks if the vocabulary being migrated is the one used for
# forums. If it is, the field name is set to 'taxonomy_forums' as it is
# what the Forum module is expecting. Otherwise, it is left unchanged.
plugin
:
forum_vocabulary
destination
:
plugin
:
component_entity_form_display
migration_dependencies
:
...
...
core/modules/taxonomy/migration_templates/d6_vocabulary_field.yml
View file @
82284fa0
...
...
@@ -32,6 +32,11 @@ process:
-
plugin
:
substr
length
:
32
-
# This plugin checks if the vocabulary being migrated is the one used for
# forums. If it is, the field name is set to 'taxonomy_forums' as it is
# what the Forum module is expecting. Otherwise, it is left unchanged.
plugin
:
forum_vocabulary
'
settings/target_type'
:
'
constants/target_entity_type'
cardinality
:
cardinality
destination
:
...
...
core/modules/taxonomy/migration_templates/d6_vocabulary_field_instance.yml
View file @
82284fa0
...
...
@@ -39,6 +39,11 @@ process:
-
plugin
:
substr
length
:
32
-
# This plugin checks if the vocabulary being migrated is the one used for
# forums. If it is, the field name is set to 'taxonomy_forums' as it is
# what the Forum module is expecting. Otherwise, it is left unchanged.
plugin
:
forum_vocabulary
label
:
name
'
settings/handler'
:
'
constants/selection_handler'
'
settings/handler_settings/target_bundles/0'
:
'
@field_name'
...
...
core/modules/taxonomy/src/Plugin/migrate/process/ForumVocabulary.php
0 → 100644
View file @
82284fa0
<?php
namespace
Drupal\taxonomy\Plugin\migrate\process
;
use
Drupal\migrate\MigrateExecutableInterface
;
use
Drupal\migrate\ProcessPluginBase
;
use
Drupal\migrate\Row
;
/**
* Checks if the vocabulary being migrated is the one used for forums.
*
* The forum module is expecting 'taxonomy_forums' as the field name for the
* forum nodes. The 'forum_vocabulary' source property is evaluated in
* Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary and is set to true if
* the vocabulary vid being migrated is the same as the one in the
* 'forum_nav_vocabulary' variable on the source site.
*
* @MigrateProcessPlugin(
* id = "forum_vocabulary"
* )
*/
class
ForumVocabulary
extends
ProcessPluginBase
{
/**
* {@inheritdoc}
*/
public
function
transform
(
$value
,
MigrateExecutableInterface
$migrate_executable
,
Row
$row
,
$destination_property
)
{
if
(
$row
->
getSourceProperty
(
'forum_vocabulary'
))
{
$value
=
'taxonomy_forums'
;
}
return
$value
;
}
}
core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
View file @
82284fa0
...
...
@@ -69,6 +69,14 @@ public function prepareRow(Row $row) {
->
fetchCol
();
$row
->
setSourceProperty
(
'node_types'
,
$node_types
);
$row
->
setSourceProperty
(
'cardinality'
,
(
$row
->
getSourceProperty
(
'tags'
)
==
1
||
$row
->
getSourceProperty
(
'multiple'
)
==
1
)
?
FieldStorageDefinitionInterface
::
CARDINALITY_UNLIMITED
:
1
);
// If the vid of the vocabulary being migrated is equal to the vid in the
// 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
// property to true so we can know this is the vocabulary used for forums.
if
(
$this
->
variableGet
(
'forum_nav_vocabulary'
,
0
)
==
$row
->
getSourceProperty
(
'vid'
))
{
$row
->
setSourceProperty
(
'forum_vocabulary'
,
TRUE
);
}
return
parent
::
prepareRow
(
$row
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment