Commit 73e12cc4 authored by yched's avatar yched
Browse files

Issue #1369658 by SangersDrupalDude, jenlampton: Fixed 'Integrity constraint...

Issue #1369658 by SangersDrupalDude, jenlampton: Fixed 'Integrity constraint violation - Column 'uid' cannot be null' if unknown file during filefield/imagefield migration
parent 236e9d5d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
/** /**
* Implements hook_content_migrate_field_alter(). * Implements hook_content_migrate_field_alter().
* *
* Use this to tweak the conversion of field settings * Use this to tweak the conversion of field settings
* from the D6 style to the D7 style for specific * from the D6 style to the D7 style for specific
* situations not handled by basic conversion, * situations not handled by basic conversion,
...@@ -40,7 +40,7 @@ function content_migrate_filefield_field_alter(&$field_value, $instance_value) { ...@@ -40,7 +40,7 @@ function content_migrate_filefield_field_alter(&$field_value, $instance_value) {
/** /**
* Implements hook_content_migrate_instance_alter(). * Implements hook_content_migrate_instance_alter().
* *
* Use this to tweak the conversion of instance or widget settings * Use this to tweak the conversion of instance or widget settings
* from the D6 style to the D7 style for specific * from the D6 style to the D7 style for specific
* situations not handled by basic conversion, as when * situations not handled by basic conversion, as when
...@@ -95,7 +95,7 @@ function content_migrate_filefield_instance_alter(&$instance_value, $field_value ...@@ -95,7 +95,7 @@ function content_migrate_filefield_instance_alter(&$instance_value, $field_value
// Translate the original imagefield and fielfield widgets. // Translate the original imagefield and fielfield widgets.
switch ($instance_value['widget']['module']) { switch ($instance_value['widget']['module']) {
case 'imagefield': case 'imagefield':
// Module names and types changed. // Module names and types changed.
$instance_value['widget']['module'] = 'image'; $instance_value['widget']['module'] = 'image';
...@@ -128,7 +128,7 @@ function content_migrate_filefield_instance_alter(&$instance_value, $field_value ...@@ -128,7 +128,7 @@ function content_migrate_filefield_instance_alter(&$instance_value, $field_value
unset($instance_value['widget']['settings']['alt']); unset($instance_value['widget']['settings']['alt']);
unset($instance_value['widget']['settings']['max_filesize_per_node']); unset($instance_value['widget']['settings']['max_filesize_per_node']);
unset($instance_value['widget']['settings']['title_type']); unset($instance_value['widget']['settings']['title_type']);
// default_image is now a field setting. // default_image is now a field setting.
unset($instance_value['widget']['settings']['default_image']); unset($instance_value['widget']['settings']['default_image']);
break; break;
...@@ -200,7 +200,16 @@ function content_migrate_filefield_data_record_alter(&$record, $field, $instance ...@@ -200,7 +200,16 @@ function content_migrate_filefield_data_record_alter(&$record, $field, $instance
return; return;
}; };
$file = db_select('files', 'f')->fields('f', array('fid', 'uid', 'filename', 'filepath', 'filemime', 'filesize', 'timestamp', 'status'))->condition('fid', $fid)->execute()->fetchObject(); $file = db_select('files', 'f')
->fields('f', array('fid', 'uid', 'filename', 'filepath', 'filemime', 'filesize', 'timestamp', 'status'))
->condition('fid', $fid)
->execute()
->fetchObject();
// In case of unknown file, just abort.
if (!is_object($file)) {
return;
}
$basename = variable_get('file_directory_path', conf_path() . '/files'); $basename = variable_get('file_directory_path', conf_path() . '/files');
$scheme = file_default_scheme() . '://'; $scheme = file_default_scheme() . '://';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment