Issue #3096969 by quietone, gabesullice, Wim Leers, mikelutz: migrate_drupal's Variable source plugin always returns a row for processing, even if none of the variables for a migration are set on the source site

merge-requests/2419/head
webchick 2019-12-20 17:31:21 -08:00
parent 92a0b41fa2
commit fb65f06c61
2 changed files with 38 additions and 1 deletions

View File

@ -60,7 +60,8 @@ class Variable extends DrupalSqlBase {
* {@inheritdoc}
*/
public function count($refresh = FALSE) {
return intval($this->query()->countQuery()->execute()->fetchField() > 0);
// Variable always returns a single row with at minimum an 'id' property.
return 1;
}
/**

View File

@ -48,6 +48,42 @@ class VariableTest extends MigrateSqlSourceTestBase {
'bar',
];
// Tests getting one of two variables.
$tests[1]['source_data']['variable'] = [
['name' => 'foo', 'value' => 'i:1;'],
['name' => 'bar', 'value' => 'b:0;'],
];
$tests[1]['expected_data'] = [
[
'id' => 'foo',
'foo' => 1,
],
];
$tests[1]['expected_count'] = NULL;
$tests[1]['configuration']['variables'] = [
'foo',
'bar0',
];
// Tests requesting mis-spelled variable names.
$tests[2]['source_data']['variable'] = [
['name' => 'foo', 'value' => 'i:1;'],
['name' => 'bar', 'value' => 'b:0;'],
];
$tests[2]['expected_data'] = [
[
'id' => 'foo0',
],
];
$tests[2]['expected_count'] = NULL;
$tests[2]['configuration']['variables'] = [
'foo0',
'bar0',
];
return $tests;
}