Problem/Motivation
When running drush migrate:status on one of our sites, we found that we were getting the following error:
[error] TypeError: Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::openSourceUrl(): Argument #1 ($url) must be of type string, null given, called in /var/www/html/docroot/modules/contrib/migrate_plus/src/DataParserPluginBase.php on line 161 in Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json->openSourceUrl() (line 129 of /var/www/html/docroot/modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_parser/Json.php) #0 /var/www/html/docroot/modules/contrib/migrate_plus/src/DataParserPluginBase.php(161): Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json->openSourceUrl()
I believe this is something to do with the way one of our migrations is run. The migration source looks as follows:
source:
track_changes: true
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
~
We have a custom drush command that executes the migration as the source data is provided from an external source and so we need to set the source URL when the migration is going to execute.
I'm not 100% sure but I believe this is the cause of the error - in that urls key is set to null.
Steps to reproduce
- Create a migration configuration where the source URL is set to null.
- Run drush migrate:status
- Error described above should show
Proposed resolution
We should allow null values into the openSourceUrl() method but return early if the url is null.