From 0fdb7f37aa4f7ce47558920fc69228da2554cf96 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 13 Mar 2017 13:02:17 +0000 Subject: [PATCH] Issue #2846002 by Jo Fitzgerald, joachim: Pipeline failure exceptions should say which plugin they failed at (cherry picked from commit 2421ca249150ae6712b3452fcea99c6ebb07528a) --- .../modules/migrate/src/MigrateExecutable.php | 2 +- .../tests/src/Unit/MigrateExecutableTest.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index 9d48618f58c9..e8316e4129a0 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -358,7 +358,7 @@ public function processRow(Row $row, array $process = NULL, $value = NULL) { if ($multiple && !$definition['handle_multiples']) { $new_value = []; if (!is_array($value)) { - throw new MigrateException(sprintf('Pipeline failed for destination %s: %s got instead of an array,', $destination, $value)); + throw new MigrateException(sprintf('Pipeline failed at %s plugin for destination %s: %s received instead of an array,', $plugin->getPluginId(), $destination, $value)); } $break = FALSE; foreach ($value as $scalar_value) { diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php index ff320df6c4ee..5e7cbaca4ca0 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\migrate\Unit; use Drupal\Component\Utility\Html; +use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrateIdMapInterface; use Drupal\migrate\MigrateException; @@ -419,6 +420,25 @@ public function testProcessRowEmptyPipeline() { $this->assertSame($row->getDestination(), []); } + /** + * Tests the processRow pipeline exception. + */ + public function testProcessRowPipelineException() { + $row = new Row(); + $plugin = $this->prophesize(MigrateProcessInterface::class); + $plugin->getPluginDefinition()->willReturn(['handle_multiples' => FALSE]); + $plugin->transform(NULL, $this->executable, $row, 'destination_id') + ->willReturn('transform_return_string'); + $plugin->multiple()->willReturn(TRUE); + $plugin->getPluginId()->willReturn('plugin_id'); + $plugin = $plugin->reveal(); + $plugins['destination_id'] = [$plugin, $plugin]; + $this->migration->method('getProcessPlugins')->willReturn($plugins); + + $this->setExpectedException(MigrateException::class, 'Pipeline failed at plugin_id plugin for destination destination_id: transform_return_string received instead of an array,'); + $this->executable->processRow($row); + } + /** * Returns a mock migration source instance. * -- GitLab