Closed (fixed)
Project:
Feeds
Version:
8.x-3.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Reporter:
Created:
18 May 2018 at 14:18 UTC
Updated:
7 Jun 2018 at 08:14 UTC
Jump to comment: Most recent, Most recent file
When not selecting any source for a target, importing breaks with something like the following error:
TypeError: Argument 4 passed to Drupal\feeds\Plugin\Type\Target\FieldTargetBase::setTarget() must be of the type array, null given, called in /Websites/drupal/drupalsites/ukkb8/web/modules/contrib/feeds/src/Feeds/Processor/EntityProcessorBase.php on line 817 in Drupal\feeds\Plugin\Type\Target\FieldTargetBase->setTarget() (line 95 of modules/contrib/feeds/src/Plugin/Type/Target/FieldTargetBase.php).
Drupal\feeds\Plugin\Type\Target\FieldTargetBase->setTarget(Object, Object, 'field_omschrijving', NULL) (Line: 843)
Drupal\feeds\Feeds\Processor\EntityProcessorBase->map(Object, Object, Object) (Line: 155)
Drupal\feeds\Feeds\Processor\EntityProcessorBase->process(Object, Object, Object) (Line: 94)
Drupal\feeds\EventSubscriber\LazySubscriber->Drupal\feeds\EventSubscriber\{closure}(Object, 'feeds.process', Object)
call_user_func(Object, Object, 'feeds.process', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('feeds.process', Object) (Line: 37)
Drupal\feeds\Plugin\QueueWorker\FeedQueueWorkerBase->dispatchEvent('feeds.process', Object) (Line: 194)
Drupal\feeds\Plugin\QueueWorker\FeedRefresh->doProcess(Object, Object) (Line: 93)
Drupal\feeds\Plugin\QueueWorker\FeedRefresh->processItem(Array) (Line: 179)
Drupal\Core\Cron->processQueues() (Line: 144)
Drupal\Core\Cron->run() (Line: 75)
Drupal\Core\ProxyClass\Cron->run() (Line: 65)
Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object, 'kernel.terminate', Object)
call_user_func(Array, Object, 'kernel.terminate', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.terminate', Object) (Line: 88)
Symfony\Component\HttpKernel\HttpKernel->terminate(Object, Object) (Line: 32)
Stack\StackedHttpKernel->terminate(Object, Object) (Line: 642)
Drupal\Core\DrupalKernel->terminate(Object, Object) (Line: 22)
See my configured mappings:

The reason that this happens is that field values are not generated for targets without sources.
On ± line 783 of EntityProcessorBase an empty source is skipped:
if ($source === '') {
// Skip empty sources.
continue;
}Before calling setTarget() method, check if field values for the target in question were generated first.
Patch will follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff-2973836-4-7.txt | 870 bytes | megachriz |
| #7 | feeds-empty-source-2973836-7.patch | 5.63 KB | megachriz |
| #4 | interdiff-2973836-2-3.txt | 1 KB | megachriz |
| #4 | feeds-empty-source-2973836-3.patch | 5.31 KB | megachriz |
| #4 | feeds-empty-source-2973836-3-tests-only.patch | 4.57 KB | megachriz |
Comments
Comment #2
megachrizA tests only patch to demonstrate the issue and another patch that hopefully fixes it.
Comment #4
megachrizI forgot to include changes to FeedTypeInterface.
Comment #7
megachrizFixing docs and coding standards in FeedTypeInterface.
Comment #9
megachrizCommitted #7.