Commit message:

Migrate Drupal 6 roles and permissions #2150407 by andypost, chx

This patch introduces the entity destination in a very minimal state. Our first two migration specific process plugins also show up. We get the role source as well (this is unit tested). And then the migration (this is integration tested).

Entity will get unit tests later when it does something. In its current state unit testing is pointless. The integration test suffices.

I do not plan writing unit tests for the one off process plugins.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Issue summary: View changes
eliza411’s picture

Issue summary: View changes

Updating the issue to reflect that map has been renamed to static_map

eliza411’s picture

I'm trying to sort out the "getting started" steps for writing migrations. Uploading my work-in-progress on the config file.

eliza411’s picture

After much patient explaining from chx and some excellent new docs at https://drupal.org/node/2135345#scalar_list, here's a revised migration config file.

We still need tests and the two migration-specific plugins.

eliza411’s picture

I'm not sure how the attachment got lost - here it is.

bdone’s picture

Assigned: Unassigned » bdone

going to try some work on this.

bdone’s picture

Status: Active » Needs work
FileSize
12.5 KB

here is an as-is first pass, still needing much work...

bdone’s picture

Assigned: bdone » Unassigned
chx’s picture

FileSize
13.31 KB

I have added the missing two plugins. Note how SystemUpdate7000 processes a string while NodeUpdate7008 processes the array -- as instructed by the handle_multiples key in their respective class annotation. This is absolutely untested. What we need at this point is a dump which has several roles with permissions that the pipeline changes.

chx’s picture

FileSize
13.37 KB
chx’s picture

FileSize
16.57 KB

This passes for me but it won't pass the bot without the related issue and it needs more tests so I am keeping it at needs work.

chx’s picture

bdone’s picture

Assigned: Unassigned » bdone

going to update the test to assert the mapped permissions...

bdone’s picture

Assigned: bdone » Unassigned
FileSize
4.91 KB

this updates the asserts, including the mapped permissions from the permissions key in config. patch #12 is against HEAD from the imp sandbox. i wasn't quite sure how to re-roll this, amidst the imp sandbox to core issue queue transition.

chx’s picture

Thanks, I will reroll once all the dependencies are in. It's very helpful to see it this cleanly -- a few more permissions are necessary still but I can add those now now that it's this cleanly visible what adding permissions mean, like 'administer nodes' (to test NodeUpdate7008) and something to test SystemUpdate7000.

chx’s picture

Issue summary: View changes
FileSize
21.64 KB
chx’s picture

Issue summary: View changes
Status: Needs work » Needs review
chx’s picture

FileSize
21.81 KB

I recall webchick protesting the transform() @inheritdoc stating it's a lie. I can't argue that... so documented them.

dawehner’s picture

  1. +++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Plugin/migrate/process/d6/NodeUpdate7008.php
    @@ -0,0 +1,34 @@
    +class NodeUpdate7008 extends ProcessPluginBase {
    
    +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php
    @@ -0,0 +1,88 @@
    +    $this->pluginManager = $plugin_manager;
    

    This variable name is not really helpful to understand what this plugin manager does. what about using migrateEntityField(Plugin)Manager ?
    As the documentation of __construct as well as properties are missing, I had to go all the way down to the container call to figure out what this could mean.

  2. +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php
    @@ -0,0 +1,88 @@
    +    /*
    ...
    +    */
    

    If we don't really need it, let's try to not add it now?

dawehner’s picture

  1. +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php
    @@ -0,0 +1,88 @@
    +/**
    + * @PluginId("entity")
    + */
    
    +++ b/core/modules/migrate_drupal/tests/Drupal/migrate_drupal/Tests/source/d6/RoleSourceTest.php
    @@ -0,0 +1,145 @@
    + *
    + * @group migrate_drupal
    

    Again ... please add @group Drupal

  2. +++ b/core/modules/migrate_drupal/tests/Drupal/migrate_drupal/Tests/source/d6/RoleSourceTest.php
    @@ -0,0 +1,145 @@
    +namespace Drupal\migrate_drupal\Tests\source\d6;
    ...
    +class TestRole extends Role {
    ...
    +use Drupal\Core\Database\Connection;
    +use Drupal\Core\Extension\ModuleHandlerInterface;
    +use Drupal\migrate_drupal\Plugin\migrate\source\d6\Role;
    

    I try to figure out why we need a seperate namespace here?

chx’s picture

I will reroll tomorrow for plugin manager but I am not going to remove the commented out parts from Entity. It'd make the sandbox a must to keep around and that's superb inconvenient. Such parts are the price for small, parallel patches instead of a two megabytes patch, and good luck reviewing. I have relented on everything, making the docs impeccable on the first go even at the cost of velocity but I am not relenting on this one -- getting Entity complete would require to add the field and field instance migrations so we can test fielded entities being migrated but those are entities so they would need to be in the same patch. So we would end up with entity, field settings migration, field instance settings migration and then either node or user (those will become fielded entities) all in a single patch.

chx’s picture

FileSize
22.75 KB
2.94 KB

Fixed those that need fixing. We need a separate namespace cos this allows you to specify the real plugin class and then the preg_replace in MigrateSqlSourceTestCase::setUp derives the test clas.

chx’s picture

Issue summary: View changes
FileSize
23.4 KB
3.87 KB

This contains andypost's fixes to Entity.php and my tests asserting that id map saving worked. Will need to add this to the guide on gdo...

chx’s picture

FileSize
1.78 KB
22.41 KB

Discussed with webchick, moved commented out code into followups but linked them from code this way interested parties can see them / contribute / not forget / etc.

andypost’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
843 bytes
22.42 KB

That's enough for the scope, another follow-up should be to add stub entities.
RTBC with small comment change

chx’s picture

FileSize
21.37 KB
3.09 KB
chx’s picture

Status: Reviewed & tested by the community » Needs review
chx’s picture

Status: Needs review » Reviewed & tested by the community
chx’s picture

Title: Migrate D6 roles and permissions » [MIGRATE BLOCKED] Migrate D6 roles and permissions
Priority: Normal » Critical
alexpott’s picture

Title: [MIGRATE BLOCKED] Migrate D6 roles and permissions » Migrate D6 roles and permissions
Status: Reviewed & tested by the community » Fixed

Committed c2e68a5 and pushed to 8.x. Thanks!

Cleaned up some very minor things during commit.

diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php
index 3c6a38c..5c6526b 100644
--- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Tests/d6/MigrateUserRoleTest.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Contains \Drupal\migrate\Tests\MigrateD6UserRoleTest.
+ * Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserRoleTest.
  */
 
 namespace Drupal\migrate_drupal\Tests\d6;
@@ -37,11 +37,11 @@ function testUserRole() {
     $rid = 'migrate_test_role_1';
     $migrate_test_role_1 = entity_load('user_role', $rid);
     $this->assertEqual($migrate_test_role_1->id(), $rid);
-    $this->assertEqual($migrate_test_role_1->permissions, array(0 => 'migrate test role 1 test permission'));
+    $this->assertEqual($migrate_test_role_1->getPermissions(), array(0 => 'migrate test role 1 test permission'));
     $this->assertEqual(array($rid), $migration->getIdMap()->lookupDestinationID(array(3)));
     $rid = 'migrate_test_role_2';
     $migrate_test_role_2 = entity_load('user_role', $rid);
-    $this->assertEqual($migrate_test_role_2->permissions, array(
+    $this->assertEqual($migrate_test_role_2->getPermissions(), array(
       'migrate test role 2 test permission',
       'use PHP for settings',
       'administer contact forms',
diff --git a/core/modules/migrate_drupal/tests/Drupal/migrate_drupal/Tests/source/d6/RoleSourceTest.php b/core/modules/migrate_drupal/tests/Drupal/migrate_drupal/Tests/source/d6/RoleSourceTest.php
index 20b1ac0..0e0bf9a 100644
--- a/core/modules/migrate_drupal/tests/Drupal/migrate_drupal/Tests/source/d6/RoleSourceTest.php
+++ b/core/modules/migrate_drupal/tests/Drupal/migrate_drupal/Tests/source/d6/RoleSourceTest.php
@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Contains \Drupal\migrate\Tests\source\d6\RoleSourceTest.
+ * Contains \Drupal\migrate_drupal\Tests\source\d6\RoleSourceTest.
  */
 
-namespace Drupal\migrate_drupal\Tests;
+namespace Drupal\migrate_drupal\Tests\source\d6;
 
 use Drupal\migrate\Tests\MigrateSqlSourceTestCase;
 
@@ -130,8 +130,6 @@ public function setUp() {
 
 }
 
-namespace Drupal\migrate_drupal\Tests\source\d6;
-
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\migrate_drupal\Plugin\migrate\source\d6\Role;

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.