Commit 50ea22de authored by catch's avatar catch

Issue #3187433 by alexpott, quietone, Pooja Ganjage, huzooka, daffie:...

Issue #3187433 by alexpott, quietone, Pooja Ganjage, huzooka, daffie: Eliminate parent::prepareRow() calls with ignored return value from all migrate source plugins

(cherry picked from commit 8a57d1e8)
parent 34516495
......@@ -64,6 +64,7 @@ public function prepareRow(Row $row) {
}
$row->setSourceProperty('aid', $label);
}
return parent::prepareRow($row);
}
}
......@@ -56,7 +56,9 @@ public function query() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
parent::prepareRow($row);
if (!parent::prepareRow($row)) {
return FALSE;
}
// Set the i18n string table for use in I18nQueryTrait.
$this->i18nStringTable = static::I18N_STRING_TABLE;
// Save the translation for this property.
......
......@@ -55,7 +55,9 @@ public function query() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
parent::prepareRow($row);
if (!parent::prepareRow($row)) {
return FALSE;
}
// Save the translation for this property.
$property_in_row = $row->getSourceProperty('property');
......
......@@ -44,7 +44,9 @@ public function query() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
parent::prepareRow($row);
if (!parent::prepareRow($row)) {
return FALSE;
}
// Put the language on the row as 'language'.
$row->setSourceProperty('language', $row->getSourceProperty('lt_language'));
......
name: 'Migrate module prepareRow tests'
type: module
description: 'Support module for source plugin prepareRow testing.'
package: Testing
version: VERSION
<?php
/**
* @file
* Test module for testing the migration source plugin prepareRow() exception
* handling.
*/
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;
/**
* Implements hook_migrate_prepare_row().
*/
function migrate_skip_all_rows_test_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
if (\Drupal::state()->get('migrate_skip_all_rows_test_migrate_prepare_row')) {
throw new MigrateSkipRowException();
}
}
......@@ -16,7 +16,7 @@ abstract class MigrateSourceTestBase extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['migrate'];
protected static $modules = ['migrate', 'migrate_skip_all_rows_test'];
/**
* The mocked migration.
......@@ -146,6 +146,7 @@ protected function getPlugin(array $configuration) {
*/
public function testSource(array $source_data, array $expected_data, $expected_count = NULL, array $configuration = [], $high_water = NULL) {
$plugin = $this->getPlugin($configuration);
$clone_plugin = clone $plugin;
// All source plugins must define IDs.
$this->assertNotEmpty($plugin->getIds());
......@@ -194,6 +195,12 @@ public function testSource(array $source_data, array $expected_data, $expected_c
// foreach loop was entered if the expected count is greater than 0.
if ($expected_count > 0) {
$this->assertGreaterThan(0, $i);
// Test that we can skip all rows.
\Drupal::state()->set('migrate_skip_all_rows_test_migrate_prepare_row', TRUE);
foreach ($clone_plugin as $row) {
$this->fail('Row not skipped');
}
}
}
......
......@@ -35,6 +35,7 @@ public function query() {
*/
public function prepareRow(Row $row) {
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
return parent::prepareRow($row);
}
/**
......
......@@ -67,7 +67,7 @@ public function prepareRow(Row $row) {
$row->setSourceProperty('revision_uid', $row->getSourceProperty('etr_uid'));
$row->setSourceProperty('source_langcode', $row->getSourceProperty('source'));
}
parent::prepareRow($row);
return parent::prepareRow($row);
}
/**
......
......@@ -78,7 +78,7 @@ public function prepareRow(Row $row) {
$row->setSourceProperty($other_property . '_translated', NULL);
}
parent::prepareRow($row);
return parent::prepareRow($row);
}
/**
......
......@@ -55,6 +55,7 @@ public function prepareRow(Row $row) {
// the language.
$language = $row->getSourceProperty('ltlanguage');
$row->setSourceProperty('language', $language);
return parent::prepareRow($row);
}
/**
......
......@@ -50,7 +50,9 @@ public function query() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
parent::prepareRow($row);
if (!parent::prepareRow($row)) {
return FALSE;
}
// Override language with ltlanguage.
$language = $row->getSourceProperty('ltlanguage');
......
......@@ -35,7 +35,9 @@ public function query() {
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
parent::prepareRow($row);
if (!parent::prepareRow($row)) {
return FALSE;
}
$row->setSourceProperty('language', $row->getSourceProperty('td_language'));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment