Problem/Motivation

On a D6 site with the upload module enabled, file attachments are considered enabled by default if the upload_[node_type] is not set. Ran into an issue with a custom D6 to D8 migration, where one content type had file attachments enabled on the D6 instance, but the upload field was missing after migration on the D8 site (two other content types with file attachments enabled did have the upload-field on D8 after migration.)

Relevant code snippet in D6's upload module:

function upload_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
    $form['workflow']['upload'] = array(
      '#type' => 'radios',
      '#title' => t('Attachments'),
      '#default_value' => variable_get('upload_'. $form['#node_type']->type, 1),
      '#options' => array(t('Disabled'), t('Enabled')),
    );
  }

  if (isset($form['type']) && isset($form['#node'])) {
    $node = $form['#node'];
    if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) {
      // Attachments fieldset
      $form['attachments'] = array(
...

Proposed resolution

Since the "File attachments" field(set) is showing up on the original D6 site when the "upload_[type]" variable is not explicitly set, that content type should be considered as having file attachments enabled. Migrate the upload-field for all content types where it is either explicitly enabled, or where the variable is not set.

Remaining tasks

- Review
- Commit

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr.baileys created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, migrate-d6-d8-upload.patch, failed testing.

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
957 bytes
2.16 KB

The Drupal 6 test fixture does not have the "upload_[node_type]" variable set for the following content types: employee, event, sponsor, test_page, test_event, test_planet and test_story. As per issue summary, under a standard Drupal 6 installation these content types would have attachments enabled. Migrate (before the patch in this issue) considered attachments to be disabled for those content types, hence the difference in expected (63) versus real (70) field_config entities.

Updated the patch so that the attachments are disabled explicitly for those content types, and removed upload_page (which does have attachments enabled) to test that this content type does get an upload field (since attachments are implicitly enabled by not setting the variable).

mr.baileys’s picture

Issue tags: +#drupalironcamp
mikeryan’s picture

Assigned: Unassigned » mikeryan
mikeryan’s picture

Assigned: mikeryan » Unassigned
Status: Needs review » Needs work

Looks good eyeballing it, but could you post a "test-only" (really, fixture-only) test to demonstrate that the bug is being tested?

Thanks.

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
963 bytes

Sure, attached is the fixture-only-portion of the patch.

Status: Needs review » Needs work

The last submitted patch, 7: upload_field_not_2829274-7-test-only.patch, failed testing.

mikeryan’s picture

Status: Needs work » Reviewed & tested by the community

Looks good, thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Don't we have to remove one of ones where it is set to TRUE to test all possibilities - NULL, FALSE TRUE...

 ->values(array(
  'name' => 'upload_company',
  'value' => 's:1:"1";',
))

Or maybe explicitly set it to NULL so 'value' => '"N;"',

mr.baileys’s picture

@alexpott: we did, the patch converts the 'upload_page' content type from explicit true to implicit true by removing it from the fixture, so we have true, false and missing covered. We could also include NULL, but as far as I'm aware you will not encounter that as a value for upload_[type] on a D6 site.

mr.baileys’s picture

Re-uploading the patch from #3 to avoid confusion, since #7 is a test-only patch.

mikeryan’s picture

Assigned: Unassigned » mikeryan
mikeryan’s picture

Assigned: mikeryan » Unassigned
Status: Needs review » Reviewed & tested by the community

Yep, I think it's good to go.

  • catch committed 92c6114 on 8.3.x
    Issue #2829274 by mr.baileys: Upload-field not migrated if not...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Fails are unrelated random js test failures. Committed/pushed to 8.3.x, thanks!

  • catch committed 92c6114 on 8.4.x
    Issue #2829274 by mr.baileys: Upload-field not migrated if not...

  • catch committed 92c6114 on 8.4.x
    Issue #2829274 by mr.baileys: Upload-field not migrated if not...

Status: Fixed » Closed (fixed)

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