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
Comment | File | Size | Author |
---|---|---|---|
#12 | upload_field_not-2829274-3.patch | 2.16 KB | mr.baileys |
#7 | upload_field_not_2829274-7-test-only.patch | 963 bytes | mr.baileys |
#3 | upload_field_not-2829274-3.patch | 2.16 KB | mr.baileys |
#3 | interdiff.txt | 957 bytes | mr.baileys |
migrate-d6-d8-upload.patch | 1.23 KB | mr.baileys | |
Comments
Comment #3
mr.baileysThe 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).
Comment #4
mr.baileysComment #5
mikeryanComment #6
mikeryanLooks good eyeballing it, but could you post a "test-only" (really, fixture-only) test to demonstrate that the bug is being tested?
Thanks.
Comment #7
mr.baileysSure, attached is the fixture-only-portion of the patch.
Comment #9
mikeryanLooks good, thanks!
Comment #10
alexpottDon't we have to remove one of ones where it is set to TRUE to test all possibilities - NULL, FALSE TRUE...
Or maybe explicitly set it to NULL so
'value' => '"N;"',
Comment #11
mr.baileys@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.
Comment #12
mr.baileysRe-uploading the patch from #3 to avoid confusion, since #7 is a test-only patch.
Comment #13
mikeryanComment #14
mikeryanYep, I think it's good to go.
Comment #16
catchFails are unrelated random js test failures. Committed/pushed to 8.3.x, thanks!