2

I'm working on a file migration from D6 -> D8, and in my case, all the files are already on S3, and they don't need to move, so all I need to do is migrate the URL to a new fid. Based on direction from mikeryan1 in IRC, in my config file I'm just doing

uri: uri

However, when I try to migrate, I get a 'Destination property uri not provided' error. I tracked down the code to EntityFile::getEntity():

// By default the entity key (fid) would be used, but we want to make sure
// we're loading the matching URI.
$destination = $row->getDestinationProperty('uri');
if (empty($destination)) {
  throw new MigrateException('Destination property uri not provided');
}

where getDestinationProperty() is

  public function getDestinationProperty($property) {
    return NestedArray::getValue($this->destination, explode(static::PROPERTY_SEPARATOR, $property));
  }

Tracking the code all the way through to NestedArray::getValue(), I find that the problem is my $ref array does not contain a uri key, so getValue() returns NULL.

  public static function &getValue(array &$array, array $parents, &$key_exists = NULL) {
    $ref = &$array;
    foreach ($parents as $parent) {
      if (is_array($ref) && array_key_exists($parent, $ref)) {
        $ref = &$ref[$parent];
      }
      else {
        $key_exists = FALSE;
        $null = NULL;
        return $null;
      }
    }
    $key_exists = TRUE;
    return $ref;
  }

Here is my migration config file.

id: file_s3
label: Files - S3
migration_group: file
migration_tags:
  - Drupal 6
source:
  plugin: file_s3_source
  constants:
    # source_base_path must be set by the tool configuring this migration. It
    # represents the fully qualified path relative to which URIs in the files
    # table are specified, and must end with a /. See source_full_path
    # configuration in this migration's process pipeline as an example.
    source_base_path: ''
process:
    # If you are using both this migration and d6_user_picture_file in a custom
    # migration and executing migrations incrementally, it is recommended that
    # you remove the fid mapping here to avoid potential ID conflicts.
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath
    -
      plugin: urlencode
  destination_full_path:
    plugin: file_uri
    source:
      - filepath
      - file_directory_path
      - temp_directory_path
      - is_public
  uri: uri
  filemime: filemime
  filesize: filesize
  status: status
  changed: timestamp
  uid: uid
destination:
  plugin: entity:file

So what do I need to do to my config file to avoid this error?

Thanks.

2

It turns out that the problem was that the source data from D6 doesn't have a uri field (it's filename and filepath), so just using a custom plugin to create the uri in the source row gets around it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.