diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 8aaac3b..26a1793 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -117,11 +117,10 @@ public function offsetSet($name, $value) { * An AttributeValueBase representation of the attribute's value. */ protected function createAttributeValue($name, $value) { - // If the value is already an AttributeValueBase object, - // return a new instance of the same class, but with the new name. + // If the value is already an AttributeValueBase object, return it + // straight away. if ($value instanceof AttributeValueBase) { - $class = get_class($value); - return new $class($name, $value->value()); + return $value; } // An array value or 'class' attribute name are forced to always be an // AttributeArray value for consistency. diff --git a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php index 9235903..bddfc27 100644 --- a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php +++ b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php @@ -40,7 +40,7 @@ public function query() { public function fields() { return array( 'field_name' => $this->t('The machine name of field.'), - 'type_name' => $this->t('Content type where this field is in use.'), + 'type_name' => $this->t('Content type where is used this field.'), 'weight' => $this->t('Weight.'), 'label' => $this->t('A name to show.'), 'widget_type' => $this->t('Widget type.'), diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index 094713d..3ed050d 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -320,10 +320,10 @@ protected function getProcessNormalized(array $process) { * {@inheritdoc} */ public function getDestinationPlugin($stub_being_requested = FALSE) { + if ($stub_being_requested && !empty($this->destination['no_stub'])) { + throw new MigrateSkipRowException; + } if (!isset($this->destinationPlugin)) { - if ($stub_being_requested && !empty($this->destination['no_stub'])) { - throw new MigrateSkipRowException; - } $this->destinationPlugin = \Drupal::service('plugin.manager.migrate.destination')->createInstance($this->destination['plugin'], $this->destination, $this); } return $this->destinationPlugin; diff --git a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php index 1e028bf..fe48cd9 100644 --- a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php +++ b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php @@ -7,6 +7,7 @@ namespace Drupal\migrate_drupal\Tests; use Drupal\migrate\Entity\Migration; +use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\Row; /** @@ -20,18 +21,36 @@ * * @param string $entity_type_id * The entity type we are stubbing. + * @param boolean $no_stub + * TRUE to prevent stub creation. */ - protected function performStubTest($entity_type_id) { - $entity_id = $this->createStub($entity_type_id); - $this->assertTrue($entity_id, 'Stub successfully created'); - if ($entity_id) { - $violations = $this->validateStub($entity_type_id, $entity_id); - if (!$this->assertIdentical(count($violations), 0, 'Stub is a valid entity')) { - foreach ($violations as $violation) { - $this->fail((string) $violation->getMessage()); + protected function performStubTest($entity_type_id, $no_stub = FALSE) { + try { + $entity_id = $this->createStub($entity_type_id, $no_stub); + if ($no_stub) { + $this->fail('Stub creation suppressed'); + } + else { + $this->assertTrue($entity_id, 'Stub successfully created'); + if ($entity_id) { + $violations = $this->validateStub($entity_type_id, $entity_id); + if (!$this->assertIdentical(count($violations), 0, 'Stub is a valid entity')) { + foreach ($violations as $violation) { + $this->fail((string) $violation->getMessage()); + } + } } } } + catch (MigrateSkipRowException $e) { + if ($no_stub) { + $this->pass('Stub creation suppressed'); + } + else { + $this->fail('Stub successfully created'); + } + } + } /** @@ -39,11 +58,13 @@ protected function performStubTest($entity_type_id) { * * @param string $entity_type_id * The entity type we are stubbing. + * @param boolean $no_stub + * TRUE to prevent stub creation. * * @return int * ID of the created entity. */ - protected function createStub($entity_type_id) { + protected function createStub($entity_type_id, $no_stub = FALSE) { // Create a dummy migration to pass to the destination plugin. $config = [ 'id' => 'dummy', @@ -52,7 +73,12 @@ protected function createStub($entity_type_id) { 'process' => [], 'destination' => ['plugin' => 'entity:' . $entity_type_id], ]; + if ($no_stub) { + $config['destination']['no_stub'] = TRUE; + } $migration = Migration::create($config); + // An initial normal fetch of the destination plugin to cache it. + $migration->getDestinationPlugin(); $destination_plugin = $migration->getDestinationPlugin(TRUE); $stub_row = new Row([], [], TRUE); $destination_ids = $destination_plugin->import($stub_row); diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php index 78651e4..c1480c1 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php @@ -41540,30 +41540,10 @@ 'value' => 'i:999;', )) ->values(array( - 'name' => 'update_check_frequency', - 'value' => 'i:1;', -)) -->values(array( - 'name' => 'update_fetch_url', - 'value' => 's:23:"http://127.0.0.1/update";', -)) -->values(array( 'name' => 'update_last_check', 'value' => 'i:1444944973;', )) ->values(array( - 'name' => 'update_max_fetch_attempts', - 'value' => 'i:3;', -)) -->values(array( - 'name' => 'update_notification_threshold', - 'value' => 's:3:"all";', -)) -->values(array( - 'name' => 'update_notify_emails', - 'value' => 'a:1:{i:0;s:19:"webmaster@127.0.0.1";}', -)) -->values(array( 'name' => 'user_admin_role', 'value' => 's:1:"3";', )) diff --git a/core/modules/node/src/Tests/Migrate/MigrateNodeStubTest.php b/core/modules/node/src/Tests/Migrate/MigrateNodeStubTest.php index 22d140b..8127942 100644 --- a/core/modules/node/src/Tests/Migrate/MigrateNodeStubTest.php +++ b/core/modules/node/src/Tests/Migrate/MigrateNodeStubTest.php @@ -45,4 +45,11 @@ public function testStub() { $this->performStubTest('node'); } + /** + * Tests suppression of node stubs. + */ + public function testNoStub() { + $this->performStubTest('node', TRUE); + } + } diff --git a/core/modules/update/migration_templates/d6_update_settings.yml b/core/modules/update/migration_templates/d6_update_settings.yml new file mode 100644 index 0000000..37e0ef1 --- /dev/null +++ b/core/modules/update/migration_templates/d6_update_settings.yml @@ -0,0 +1,21 @@ +id: d6_update_settings +label: Update configuration +migration_tags: + - Drupal 6 +source: + plugin: variable + variables: + - update_max_fetch_attempts + - update_fetch_url + - update_notification_threshold + - update_notify_emails + - update_check_frequency +process: + 'fetch/max_attempts': update_max_fetch_attempts + 'fetch/url': update_fetch_url + 'notification/threshold': update_notification_threshold + 'notification/emails': update_notify_emails + 'check/interval_days': update_check_frequency +destination: + plugin: config + config_name: update.settings diff --git a/core/modules/update/migration_templates/update_settings.yml b/core/modules/update/migration_templates/update_settings.yml deleted file mode 100644 index ad22472..0000000 --- a/core/modules/update/migration_templates/update_settings.yml +++ /dev/null @@ -1,22 +0,0 @@ -id: update_settings -label: Update configuration -migration_tags: - - Drupal 6 - - Drupal 7 -source: - plugin: variable - variables: - - update_max_fetch_attempts - - update_fetch_url - - update_notification_threshold - - update_notify_emails - - update_check_frequency -process: - 'fetch/max_attempts': update_max_fetch_attempts - 'fetch/url': update_fetch_url - 'notification/threshold': update_notification_threshold - 'notification/emails': update_notify_emails - 'check/interval_days': update_check_frequency -destination: - plugin: config - config_name: update.settings diff --git a/core/modules/update/src/Tests/Migrate/d6/MigrateUpdateConfigsTest.php b/core/modules/update/src/Tests/Migrate/d6/MigrateUpdateConfigsTest.php index 29cf502..679350a 100644 --- a/core/modules/update/src/Tests/Migrate/d6/MigrateUpdateConfigsTest.php +++ b/core/modules/update/src/Tests/Migrate/d6/MigrateUpdateConfigsTest.php @@ -29,7 +29,7 @@ class MigrateUpdateConfigsTest extends MigrateDrupal6TestBase { */ protected function setUp() { parent::setUp(); - $this->executeMigration('update_settings'); + $this->executeMigration('d6_update_settings'); } /** diff --git a/core/tests/Drupal/Tests/Core/Common/AttributesTest.php b/core/tests/Drupal/Tests/Core/Common/AttributesTest.php index 4fc57ae..1dafef9 100644 --- a/core/tests/Drupal/Tests/Core/Common/AttributesTest.php +++ b/core/tests/Drupal/Tests/Core/Common/AttributesTest.php @@ -71,20 +71,4 @@ public function testAttributeIteration() { } } - /** - * Test AttributeValueBase copy. - */ - public function testAttributeValueBaseCopy() { - $original_attributes = new Attribute([ - 'checked' => TRUE, - 'class' => ['who', 'is', 'on'], - 'id' => 'first', - ]); - $attributes['selected'] = $original_attributes['checked']; - $attributes['id'] = $original_attributes['id']; - $attributes = new Attribute($attributes); - $this->assertSame((string) $original_attributes, ' checked class="who is on" id="first"', 'Original boolean value used with original name.'); - $this->assertSame((string) $attributes, ' selected id="first"', 'Original boolean value used with new name.'); - } - }