Problem/Motivation

Running migrate-import using drush/drush:^10 from a drupal 6 site to drupal 8.8. The drupal 6 site has core search enabled.

An exception is thrown from Drupal\search\Plugin\ConfigurableSearchPluginBase::setConfiguration()

TypeError: Argument 1 passed to Drupal\search\Plugin\ConfigurableSearchPluginBase::setConfiguration() must be of the type array, null given, called in /var/www/sites/abcdef/web/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php on line 106 in Drupal\search\Plugin\ConfigurableSearchPluginBase->setConfiguration() (line 46 of /var/www/sites/abcdef/web/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php)

Proposed resolution

Modify the migration so that there is always a configuration array that is, by default, empty. These are plugins and plugins have a configuration array, so let't make sure one is available.

Remaining tasks

Review
Commit

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bgprior created an issue. See original summary.

mattpainter’s picture

Same issue here, upgrading from a Drupal 6.38 install - which includes a whole tonne of old, unmaintained modules - to a fresh Drupal 8.7.10 install.

TypeError: Argument 1 passed to Drupal\search\Plugin\ConfigurableSearchPluginBase::setConfiguration() must be of the type array, null given, called in /var/www/html/drupal-8.7.10/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php on line 106 in Drupal\search\Plugin\ConfigurableSearchPluginBase->setConfiguration() (line 46 of /var/www/html/drupal-8.7.10/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php) #0 /var/www/html/drupal-8.7.10/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php(106): Drupal\search\Plugin\ConfigurableSearchPluginBase->setConfiguration(NULL) #1 /var/www/html/drupal-8.7.10/core/modules/migrate/src/Plugin/migrate/destination/Entity.php(173): Drupal\search\Plugin\migrate\destination\EntitySearchPage->updateEntity(Object(Drupal\search\Entity\SearchPage), Object(Drupal\migrate\Row)) #2 /var/www/html/drupal-8.7.10/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php(140): Drupal\migrate\Plugin\migrate\destination\Entity->getEntity(Object(Drupal\migrate\Row), Array) #3 /var/www/html/drupal-8.7.10/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php(86): Drupal\migrate\Plugin\migrate\destination\EntityConfigBase->import(Object(Drupal\migrate\Row), Array) #4 /var/www/html/drupal-8.7.10/core/modules/migrate/src/MigrateExecutable.php(226): Drupal\search\Plugin\migrate\destination\EntitySearchPage->import(Object(Drupal\migrate\Row), Array) #5 /var/www/html/drupal-8.7.10/core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php(133): Drupal\migrate\MigrateExecutable->import() #6 /var/www/html/drupal-8.7.10/core/includes/batch.inc(295): Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch::run(Array, Array, Array) #7 /var/www/html/drupal-8.7.10/core/includes/batch.inc(137): _batch_process() #8 /var/www/html/drupal-8.7.10/core/includes/batch.inc(93): _batch_do() #9 /var/www/html/drupal-8.7.10/core/modules/system/src/Controller/BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request)) #10 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request)) #11 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #12 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #13 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #14 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #15 /var/www/html/drupal-8.7.10/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #16 /var/www/html/drupal-8.7.10/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #17 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/html/drupal-8.7.10/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/html/drupal-8.7.10/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/html/drupal-8.7.10/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/html/drupal-8.7.10/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /var/www/html/drupal-8.7.10/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #26 {main}.

Not sure if this is of any relevance, but when I tried again but didn't specify the static files path, the migration worked - however, of course, wasn't that useful.

yookoala’s picture

I just encountered the same problem on Drupal 8.8.1. Had to disable the Search module on Drupal 6 in order to successfully migrate.

HongPong’s picture

fwiw i had to remove drush/drush drush v10 from the vendor folder and fall back to drush 8 in my local user bin and then it worked (from drupal 6)

geerlingguy’s picture

I'm getting the former notices (Field discovery failed for Drupal core version 7.) before the following migrations:

  • upgrade_d7_field
  • upgrade_d7_field_instance
  • upgrade_d7_user
  • upgrade_d7_comment
  • upgrade_d7_field_formatter_settings
  • upgrade_d7_field_instance_widget_settings

Tracking this issue here: Getting 'Field discovery failed for Drupal core version 7.' when migrating

mradcliffe’s picture

Issue summary: View changes

I ran into this issue as well. I edited the issue summary to contain only the back trace and the exception.

RdeBoer’s picture

I just had this too on a D7 to D8 migration. I patched the code to fix this.

File core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php, change function updateEntity() (line 100) to read like this:

  protected function updateEntity(EntityInterface $entity, Row $row) {
    parent::updateEntity($entity, $row);
    $entity->setPlugin($row->getDestinationProperty('plugin'));
    // The user_search plugin does not have a setConfiguration() method.
    $plugin = $entity->getPlugin();
    if ($plugin instanceof ConfigurableSearchPluginBase) {
      if ($config = $row->getDestinationProperty('configuration')) {
        $plugin->setConfiguration($config);
      }
    }
  }

This for me resulted in the migration going through without an errors or warnings.

jpdw’s picture

I encountered the same issue on another D7 to D8 (8.9) migration.

RdeBoer's patch (#7) appeared to work for me too, albeit path to file was slightly different core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php

RdeBoer’s picture

@jpdw Thanks -- typo on my behalf. I've corrected the file path in #7.

vistree’s picture

#7 seems to fix the warnings for a D6 to D8 migration also ;-)

heddn’s picture

Project: Migrate Upgrade » Drupal core
Version: 8.x-3.x-dev » 9.2.x-dev
Component: Code » migration system

Given the solution in #7 is in core, not migrate upgrade module, moving queues.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Shrutidkadam’s picture

#7 seems to be working, i have added its patch file for the same

quietone’s picture

Title: TypeError: Argument 1 passed to ConfigurableSearchPluginBase::setConfiguration() must be of the type array, null given » Ensure SearcPlugin configuration must be an array
Issue summary: View changes
Status: Active » Needs review
Issue tags: +Bug Smash Initiative, +migrate-d6-d8, +migrate-d7-d8
FileSize
1.46 KB
3.23 KB

@bgprior, Thanks for reporting the error, and to RdeBoer and shrutidkadam for the fix and patch.

I think the better solution is to alter the migration to make sure that there is always a configuration array on the row. That is because the destination is a plugin, which has a configuration array. It seems to me that the migration should be providing that. Therefor, the migration yamls are modified to ensure that there is a configuration array.

Attached is a fail and success path. I have update the title to focus on the fix (and be shorter) and updated the IS.

quietone’s picture

Title: Ensure SearcPlugin configuration must be an array » Ensure SearchPlugin has a configuration array

Fix title

quietone’s picture

Oops, wrong fail patch. Let's start over.

The last submitted patch, 16: 3092430-16-fail.patch, failed testing. View results

danflanagan8’s picture

Status: Needs review » Reviewed & tested by the community

@quietone, that is an elegant fix! And the test looks great. It produces exactly the error message we were looking for. And it even has nice comments.

I tested this by deleting all of the node_rank_% rows manually from the drupal7 fixture. Then I spun up a D7 with that fixture. Then I used migrate_drupal_ui to upgrade that D7 site to a D9 site. I quickly received the following error:

TypeError: Drupal\search\Plugin\ConfigurableSearchPluginBase::setConfiguration(): Argument #1 ($configuration) must be of type array, null given, called in /var/www/html/core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php on line 106 in Drupal\search\Plugin\ConfigurableSearchPluginBase->setConfiguration() (line 46 of /var/www/html/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php)

Just like in the IS and in your test.

After that I applied the patch and repeated the steps. This time the migration was smooth. The node search page on the D9 site looks great. It ends up with the following yml (with uuid stuff removed) which looks totally healthy:

langcode: en
status: true
dependencies:
  module:
    - node
id: node_search
label: Content
path: node
weight: -10
plugin: node_search
configuration:
  rankings: {  }

And the search page works after I index. This looks great.

benjifisher’s picture

For some reason, the patch in #16 is not being tested automatically even though this issue is RTBC. I just queued a retest.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexpott’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 331e284ef00 to 10.0.x and 62dc0bc471e to 9.4.x and d764daae297 to 9.3.x. Thanks!

  • alexpott committed 331e284 on 10.0.x
    Issue #3092430 by quietone, shrutidkadam, RdeBoer, bgprior, danflanagan8...

  • alexpott committed 62dc0bc on 9.4.x
    Issue #3092430 by quietone, shrutidkadam, RdeBoer, bgprior, danflanagan8...

  • alexpott committed d764daa on 9.3.x
    Issue #3092430 by quietone, shrutidkadam, RdeBoer, bgprior, danflanagan8...

Status: Fixed » Closed (fixed)

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