If the source path for files contains a query string (which is typical when remote images are being migrated), and the destination_file is not specified, the destination filename gets the query string suffixed without all the special characters.

For example, http://example.com/images/large-image.jpg?cb=1 gets saved as large-image.jpgcb1.

The problem is this block of code in \MigrateFileUri::processFile:

    if (empty($this->destinationFile)) {
      $this->destinationFile = basename($this->sourcePath);
    }

The basename function does not strip out the query string from an URL. We have to do that ourselves.

I think it is safe to do this in MigrateFileUri without checking if it is actually a remote URI as ? is not typically a valid character for filenames.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hussainweb created an issue. See original summary.

hussainweb’s picture

Status: Active » Needs review
FileSize
540 bytes

This patch should fix the problem.

pifagor’s picture

Status: Needs review » Reviewed & tested by the community

  • pifagor committed 7e537fd on 7.x-2.x
    Issue #2757501 by hussainweb, pifagor: File URL's with query string do...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joseph.olstad’s picture