Project page needs to make it clear that this module migrates webforms from Drupal 6 only.

Are there any plans to enable migration from another Drupal 7 site? It would be useful, but I only have 1 or 2 webforms and don't need to preserve the submissions, so easy enough to recreate manually.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

zrhoffman’s picture

As someone who needs to migrate webforms along with their submissions, I would find it useful if this module supported Drupal 7 sources.

guardiola86’s picture

I'm having the same problem, I might end up writing my own classes and probably I'll contribute them back as it might be useful for others.

guardiola86’s picture

I couldn't make a patch for the module as it requires more changes than I thought initially and also I'm not using settings.php but a custom implementation. But I can share my class which might be useful to others and maybe anyone can integrate it into the module:

class WebformNodeMigration extends DrupalNode7Migration {
  public function __construct(array $arguments) {
    parent::__construct($arguments);
  }
  public function complete($entity, stdClass $row) {
    /**
     * Once the webform nodes are created, then update the rest of the tables
     */
    //Components
    $this->component($row->nid, $entity->nid);
    //Submissions
    $this->submissions($row->nid, $entity->nid);
    //Submitted data
    $this->submitted_data($row->nid, $entity->nid);
    //Conditional
    $this->conditional($row->nid, $entity->nid);
    //Conditional rules
    $this->conditional_rules($row->nid, $entity->nid);
    //Emails
    $this->emails($row->nid, $entity->nid);
    //Last download
    $this->last_download($row->nid, $entity->nid);
  }
  public function component($old_id, $new_id) {
    $this->set_new_values('webform_component', 'wc', $old_id, $new_id);
  }
  public function submissions($old_id, $new_id) {
    $this->set_new_values('webform_submissions', 'ws', $old_id, $new_id);
  }
  public function submitted_data($old_id, $new_id) {
    $this->set_new_values('webform_submitted_data', 'wsd', $old_id, $new_id);
  }
  public function conditional($old_id, $new_id) {
    $this->set_new_values('webform_conditional', 'wc', $old_id, $new_id);
  }
  public function conditional_rules($old_id, $new_id) {
    $this->set_new_values('webform_conditional_rules', 'wcr', $old_id, $new_id);
  }
  public function emails($old_id, $new_id) {
    $this->set_new_values('webform_emails', 'we', $old_id, $new_id);
  }
  public function last_download($old_id, $new_id) {
    $this->set_new_values('webform_last_download', 'wld', $old_id, $new_id);
  }
  //Function to set new values
  public function set_new_values($table, $alias,  $old_id, $new_id) {
    $rows = Database::getConnection('default', $this->sourceConnection)
      ->select($table, $alias)
      ->fields($alias)
      ->condition($alias . '.nid', $old_id)
      ->execute()->fetchAll();
    foreach ($rows as $row) {
      $row->nid = $new_id;
      drupal_write_record($table, $row);
    }
  }
}
guardiola86’s picture

Status: Active » Needs review
Anonymous’s picture

Interesting approach... in general there should be no need to do anything related to the webforms in the node migration.

Here is a node migration I'm using:

class hiWebform extends hiNode {
  public function __construct(array $arguments) {
    parent::__construct($arguments);

  }
}

... the hiNode class is just an abstract class I extended from DrupalNode7Migration (part of migrate_d2d). As you can see, I do not have any fields besides the basics, in fact, nothing is custom about it at all. It is just running D2D's basic node stuff.

The webform migrations are intended to run after the nodes are in place. What I mean by that is, run your migration, then go to the "Webform Migrations" and run those in order.

I'm finding that the dev branch actually works out of the box for adding the settings, email addresses, and form components. The submissions also come through but I get an error part way through the "submitted data" migration.

My guess is that to get this thing to work for D7->D7 we will need to:

1. add a select option to the configure form, and
2. update the query for the submitted_data migration.

Besides that, just encourage people to use the dev branch (for now!).

ckng’s picture

Title: Does not import webforms from Drupal 7 » Support webform migration from Drupal 7
Component: Documentation » Code
Category: Task » Feature request
FileSize
78.38 KB

Attached patch support migration from D7 webform.

Main changes are
- refactored D6 (unchanged) into the d6 subfolder and D7 support in d7
- added select option to D7
- updated D7 classes with D7 schema support
- integrated patches from
#2525780: Notice: Undefined index: default_format in __construct() (line 42 of .../migrate_webform/settings.inc), and
#2236469: Call to a member function getMap() on a non-object

beardedgeek’s picture

Hi.

Which version should this patch be applied to?

I've just tried to run it against migrate_webform-7.x-1.1 and I get the following issues:

patch -p1 < migrate_webform-d7-2279477-6.patch
patching file README.txt
patching file components.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file components.inc.rej
patching file d6/components.inc
patching file d6/emails.inc
patching file d6/lastdownload.inc
patching file d6/node.inc
patching file d6/settings.inc
patching file d6/submissions.inc
patching file d6/submitteddata.inc
patching file d6/validationrule.inc
patching file d6/validationrulecomponents.inc
patching file d7/components.inc
patching file d7/emails.inc
patching file d7/lastdownload.inc
patching file d7/node.inc
patching file d7/settings.inc
patching file d7/submissions.inc
patching file d7/submitteddata.inc
patching file d7/validationrule.inc
patching file d7/validationrulecomponents.inc
patching file emails.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file emails.inc.rej
patching file lastdownload.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file lastdownload.inc.rej
patching file migrate_webform.info
Hunk #2 FAILED at 10.
1 out of 2 hunks FAILED -- saving rejects to file migrate_webform.info.rej
patching file migrate_webform.migrate.inc
Hunk #2 FAILED at 55.
Hunk #3 succeeded at 95 (offset -1 lines).
Hunk #4 succeeded at 133 (offset -1 lines).
1 out of 4 hunks FAILED -- saving rejects to file migrate_webform.migrate.inc.rej
patching file migrate_webform.module
patching file node.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file node.inc.rej
patching file settings.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file settings.inc.rej
patching file submissions.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file submissions.inc.rej
patching file submitteddata.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file submitteddata.inc.rej
patching file validationrule.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file validationrule.inc.rej
patching file validationrulecomponents.inc
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file validationrulecomponents.inc.rej
ckng’s picture

FileSize
86.33 KB

@beardedgeek patch almost always apply only to dev.

Updated patch to import webform_conditional, webform_conditional_actions, webform_conditional_rules. Plus fixes for webform_validation_rule and webform_validation_rule_components.

Amit Dwivedi’s picture

Hi @ckng

I am not able to apply the attached patch in #8 against the latest dev version.
I want it to work for D7 to D7 migration of Webforms. Can you please post a patch again.

Thanks.

berdyshev’s picture

patched applied without any issues and works well at the moment.

@ckng, One thing. I've faced an issue with configuration page. For example, I've unchecked "Create a node migration by default" in order to specify my custom migration of nodes. But when I specified PHP Class name in the following field, I got the error "Error: Call to a member function getGroup() on null in migrate_migrations()". After debugging I've found that the migration name should be filled in this field. Can we change the wording?