Files migrations silently fail / migrate should use custom error handler rather than hide errors

Created on 16 January 2014, over 11 years ago
Updated 21 June 2025, about 1 month ago

I have spent the better part of a week trying out different scenarios with my files migrations. Initially we were getting a lot of failed file imports but as we have narrowed the list down it has become apparent that some of the files do exist, but fail for no known reason.

Upon looking into things further I noticed that migrate is using @copy() to do the transfer and the @ symbol overrides the default error handling, hiding it and making it unusable for the error message that is generated. It would be nice if rather than doing this that we could specify the error handler and get return values from it for the error message.

While working through this I put a curl request to get the headers into the "if (!@copy($this->sourcePath, $destination))" block and appended the result to the error messages. Surprisingly some were 200 OK, while some were legitimately 404. Interesting.

When I bring that same file (that showed 200 OK in curl) into /devel/php running php copy() I get a 404 the first time, and a 200 OK the second time. Obviously we have a local problem!

It would be nice if we defined a custom error handler rather than simply hiding the errors. There is a D8 issue for doing this across the board here: https://drupal.org/node/1247666.

Yes, I'm aware that it is better to use a local file source than a remote one, but I'm dealing with *many* dev/staging/production environments in this case. For us that will only work in the production environment... so we have an override for that case, but ideally dev and staging would work too.

Feature request
Status

Closed: outdated

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇰Denmark ressa Copenhagen

    In my case, it was due to malformed JSON. So as soon as I found and removed the lingering commas, the migration worked as expected.

Production build 0.71.5 2024