I'm trying to migrate user pictures from a D6 to a D7 installation. So far, I have successfully migrated my D6 user roles. So in general, common arguments work correctly.
I used the following definition for picture migration:
$role_arguments = comm_arguments + array(
'machine_name' => 'UserPictureMapping',
'description' => t('Import D6 user pictures'),
'default_uid' => 1,
'destination_dir' => 'private://pictures',
);
Migration::registerMigration('DrupalPicture6Migration', $role_arguments['machine_name'], $role_arguments);
Migration finds all pictures to import, but running the import results in two error messages per picture:
- /path_to_webroot/old_d6_upload_folder/pictures/picture-87.jpg Error The specified file /pictures/picture-87.jpg could not be copied to private://pictures/pictures/picture-87.jpg.
- /path_to_webroot/old_d6_upload_folder/pictures/picture-87.jpg Error New object was not saved, no error provided
There are no error messages in server log and also all folder permissions seem to be fine.
As a result, pictures are not imported. However, what works is that the folder /pictures/pictures is created in my private download folder.
So what's wrong?
Comments
Comment #1
advseb commentedWe use latest 7.x-2.x commit.
Comment #2
advseb commentedI have to change that into a bug report. I don't think that the current code is able to handle migration of pictures if private download method is used on D6 source. My colleague will provide additional details how we worked around it.
Comment #3
Miro Goepel commentedI'm the colleague advseb mentioned.
Let's take a closer look at the error message advseb cited: The specified file /pictures/picture-87.jpg could not be copied to private://pictures/pictures/picture-87.jpg
The entry in the D6 database (table 'users', column 'picture') regarding this file is:
/path/to/home_directory/upload_directory/pictures/picture-87.jpg
This entry is equivalent to the absolute path of the user's picture on our server. It differs from the much shorter path mentioned in the error message: /pictures/picture-87.jpg
My workaround was to reattach the preceding part of the original path to the path, which is used in the copy function:
Once I edited 'migrate-7.x-2.5\migrate\plugins\destinations\file.inc' in this way, UserPictureMapping ran smoothly, that is all pictures were copied and all respective entries in the 'file_managed' table of the D7 database were created correctly.
I've not yet taken the time to run a backtrace to locate at which point and why the original working path got cropped. I agree with advseb however, that in this case the picture migration is not working as it's supposed to be.
Comment #4
mikeryanYou need to explicitly tell your installation where the pictures are - it has no way to automatically know anything about /path/to/home_directory/upload_directory. Add a source_dir argument:
The documentation at http://drupal.org/node/1819706 omitted this, I've added it in now.
Comment #5
Miro Goepel commentedThank you, Mike. That solved our problem.
Comment #6
mikeryanComment #7
advseb commentedThanks for directly updating the documentation!