Problem/Motivation

D6 image field widget settings stored the min and max resolution in one string and if nothing was specified then a simple 0 was stored. In Drupal 8, however, a single 0 causes a form error when trying to submit ImageItem::fieldSettingsForm.

The file directory setting in D6 is not imported at all, but instead hardcoded as public://, which clearly is wrong since the help text for the D8 file directory field says

Do not include preceding or trailing slashes.

Proposed resolution

Change 0 to '', and public:// to $widget_settings['file_path'] in FieldInstanceSetting::transform.

Add a test for image field settings in MigrateFieldInstanceTest.php

Remaining tasks

Review patch.

User interface changes

API changes

Data model changes

Original report

Just trying our very first D8 site and noticed this after running the import (where all files failed to migrate).

Drupal 8.0.0 and Drupal Upgrade Dev snapshot from today. No other modules installed.

Original settings

So:

1) File directory:
This gets mapped to public:// schema correctly, but the schema ends up being used as the directory too.

2) Resolution
This is pulled through as 0. 0 should be blanked out (this causes a validation error on save)

Luckily, small site, so we'll just manually upload, but reporting anyways :)

Comments

Alan D. created an issue. See original summary.

mikeryan’s picture

Title: Drupal 6 image file directory & resolution settings errors » Drupal 6 image field settings incorrect after migration
Project: Migrate Upgrade » Drupal core
Version: 8.x-1.x-dev » 8.0.x-dev
Component: Code » migration system

Moving to the core issue queue - as a general rule of thumb, if the results of a migration are incorrect, the problem is usually going to be in the core framework, not in the UI.

shaundychko’s picture

Assigned: Unassigned » shaundychko
chx’s picture

Issue tags: +SprintWeekend2016
chx’s picture

Issue summary: View changes
shaundychko’s picture

Attached is a patch with only a test. It should fail since the d6 widget settings are by default 0, but D8 expects the default to be an empty string. The second patch with both a fix and tests makes 0 turn into an empty string when migrating.

Status: Needs review » Needs work
shaundychko’s picture

Assigned: shaundychko » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.23 KB
new3.71 KB

A patch which intentionally fails is posted here, along with a second patch that includes the fix. There is also a one line comment added to MigrateFieldTest.php which I noticed was missing while browsing to make this patch.

shaundychko’s picture

Issue summary: View changes
shaundychko’s picture

Just a bit of code cleanup. Wrap the comment, and remove an extraneous comment.

The last submitted patch, 10: test.patch, failed testing.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @ShaunDychko that looks great and makes sense the changes made for this migration. Thanks for the test only patch.

shaundychko’s picture

Just a note for the committers: @chx mentored and @joelpittet reviewed code during the Vancouver Code sprint, so they should be mentioned in the git commit message.

alan d.’s picture

StatusFileSize
new5.06 KB

Nice work all, I feel lazy not even attempting to look into it myself ;)

Should a secondary issue be added about the file schema? The small site only used public images, but I would assume that private storage would also cause issues. The migration completely failed, possibly due to either validation fails on the resolution, but more likely imho, (a windows machine), failed to create the base folder "public://" due to the use of invalid characters for this operating system.

In fact, there was no validation when I added "public://" as part of the file storage directory, and the upload failed (Running 8.0.0)

i.e. I could do this:

and the field is unusable as the file path is invalid and the upload fails.

joelpittet’s picture

@Alan D. the schema shouldn't be added to the file directory, there is a place for the storage Upload destination under "Field Settings"

alan d.’s picture

Hi Joel, that is the second part of the settings issue I reported, the file schema was set to public (correctly migrated or was simply the site default) and the file destination folder was set to "public://" too. I had not touched these settings.

However... using the latest dev snapshot, I have run the update again with the patch, but no issue seen with the folder settings this time. :)

So rtbtc from a real D6 system perspective regarding the original report.

Still only 48 of the 213 files were imported, better than none, but there is still something fishy going on & have spent 4 hours trying to debug. If I find the reason, I'll create a new thread and ping back.

joelpittet’s picture

@Alan D. I don't think I'm following. The patch also removes the hardcoded public://.

alan d.’s picture

Sorry missed that line, but as I said above, with the patch no issue with either settings, rtbtc from me as per above :)

There are still issues with both file system (48 files from 248) & domain (67 files from 248) based migrations I'm trying but they are unrelated :(

joelpittet’s picture

@Alan D. ah maybe a stub a follow-up issue for that and once you can flush out some details we can look into resolving that problem there?

  • catch committed 80821af on
    Issue #2621794 by ShaunDychko, Alan D., joelpittet, chx: Drupal 6 image...

  • catch committed 2194a17 on
    Issue #2621794 by ShaunDychko, Alan D., joelpittet, chx: Drupal 6 image...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.1.x and cherry-picked to 8.0.x, thanks!

Status: Fixed » Closed (fixed)

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