ERROR
preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated StreamWrapperManager.php:294

CONTEXT

I am building a custom migrate module in a DDEV environment trying to import files to a local development site
My source plugin returns valid values for the files as
uri
The files exist and van be found in the container
f.i. ls  web/sites/default/files/sourcefiles/2017-10/Cover-voorkant.jpg
gives me the file
The value of the uri in the preparerow is
public://sourcefiles/2017-10/Cover-voorkant.jpg

I also tried the local path to the file and using file:// but I keep getting this error

preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated StreamWrapperManager.php:294

public static function getScheme($uri) {
  if (preg_match('/^([\w\-]+):\/\/|^(data):/', $uri, $matches)) {
    // The scheme will always be the last element in the matches array.
    return array_pop($matches);
  }

  return FALSE;
}

and 

file_exists(): Passing null to parameter #1 ($filename) of type string is deprecated FileCopy.php:135

YAML

id: publicatie_files
label: 'Publicatie Files'
migration_group: default
source:
  plugin: thishereplugin
  key: migrate

process:
  fid: fid
  filename: filename
  uri:
    plugin: skip_on_empty
    method: row
    source:
      plugin: callback
      callable: strval
      source: uri

  uri:
    plugin: file_copy
    source: uri
    destination: 'public://targetfiles'
    file_exists: use_existing

destination:
  plugin: 'entity:file'

migration_dependencies: {}

QUESTION
anybody had this weird problem befor or can point me towards a solution.
Breaking my head over this for days now.
Need it to construct migration modules that will merge two sites into a new one.

Comments

jaypan’s picture

At a quick glance, I can see that you are not doing two passes for URI, but rather overwriting the first with the second. Maybe try this:

  uri:
    -
      plugin: skip_on_empty
      method: row
      source:
        plugin: callback
        callable: strval
        source: uri
    - 
      plugin: file_copy
      destination: 'public://targetfiles'
      file_exists: use_existing

IIRC this will pass the results of the first pass to the second.

Or you might try:

  file_uri:
    plugin: skip_on_empty
    method: row
      source:
      plugin: callback
      callable: strva
      source: uri
  uri:
    plugin: file_copy
    source: @file_uri
    destination: 'public://targetfiles'
    file_exists: use_existing

Also, makes sure the directory public://targetfiles exists.

Contact me to contract me for D7 -> D10/11 migrations.