Today, while trying to set up my first file migration, I had this error:
New object was not saved, no error provided.
... which later I found out there was a little more information by clicking through to see the "messages" for my migration:
The specified file /sites/default/files/mysourcedir/some_file.jpg could not be copied to public://newsubdir/some_file.jpg
It took me quite a while to get to the bottom of the problem, which I did by adding a slightly different error-handler, which provided more information. Here is how it looks now:
The specified file /sites/default/files/mysourcedir/some_file.jpg could not be copied to public://newsubdir/some_file.jpg
"copy(/sites/default/files/mysourcedir/some_file.jpg): failed to open stream: No such file or directory File /sites/all/modules/contrib/migrate/plugins/destinations/file.inc, line 358"
"No such file or directory" was much more helpful than "could not be copied".
(Incidentally, my problem was that I had specified my source_dir as "/sites/default/files". The way the migrate module magically gets everything else out of the source drupal site (this is a drupal-to-drupal migration) led me to think that it would already know my the drupal root of my source site (much as drush does). )
Patch is attached for my minor improvement.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | migrate-error_messages_more_info-2141687-8.patch | 1.47 KB | othermachines |
Comments
Comment #1
dan3h commentedHere is a patch for the improvement.
Comment #2
dan3h commentedOops... patch had a typo -- an extra 't' in one of the '%migrate_excepttion' tokens.
New and improved version attached.
Comment #3
13rac1 commentedRunning tests.
Comment #6
seemlesstaylor commentedI'm new to Drupal and it's community, so I don't have the knowledge or the time right now to write a test and make this a patch, but this code was very useful to me in 'making error messages include more information', at least for file migrations. I simply added a try/catch to the copyFile function in modules\migrate\plugins\destinations\file.inc and added the exception message to the migration message. My new function reads as follows:
As much time as various un-informative errors have cost our team, I thought it would be more helpful to the community to put this out there than to wait until I could submit it as a proper patch.
Comment #7
mikeryan@dan3h: Could you submit a proper Drupal patch? tl;dr - do a
git diffin the module directory.Thanks.
Comment #8
othermachines commentedI badly needed this to debug a WordPress import. I created a patch from @dan3h's code, but with typos and formatting fixed.
Error message before:
The specified file http://www.domain.se/wp-content/uploads/1234.png could not be copied to public://wp-content/uploads/1234.png.
Error message after:
The specified file http://www.domain.se/wp-content/uploads/1234.png could not be copied to public://wp-content/uploads/1234.png: "copy(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 File C:\wamp\www\abc\sites\all\modules\contrib\migrate\plugins\destinations\file.inc, line 410"
Comment #9
dan3h commented@othermachines: Thanks for making my patch into a proper drupal patch. Sorry, @mikeryan, for totally missing your message from a year ago!
Comment #10
mikeryanComment #12
mikeryanCommitted, thanks!