From a01ae26312d6352f1c82514916255c36f3aa3cde Mon Sep 17 00:00:00 2001 From: "sws-developers@lists.stanford.edu" Date: Wed, 20 Oct 2021 16:52:20 +0000 Subject: [PATCH 1/5] Back to dev --- stanford_migrate.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stanford_migrate.info.yml b/stanford_migrate.info.yml index a59855e..19c4b90 100755 --- a/stanford_migrate.info.yml +++ b/stanford_migrate.info.yml @@ -3,7 +3,7 @@ description: 'Adds more functionality to migrate and migrate plus modules' type: module core_version_requirement: ^8.8 || ^9 package: 'Stanford' -version: 8.x-1.18 +version: 8.x-1.19-dev dependencies: - drupal:migrate - migrate_plus:migrate_plus From 8dcebdb7f44eab6cf16869b2566f8393015cde3c Mon Sep 17 00:00:00 2001 From: pookmish Date: Wed, 3 Nov 2021 13:54:25 -0700 Subject: [PATCH 2/5] If the last name is empty, but a first name is parsed, move the first name to the last name. (#41) --- src/Plugin/migrate/process/NameField.php | 8 ++++++-- tests/src/Unit/Plugin/migrate/process/NameFieldTest.php | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Plugin/migrate/process/NameField.php b/src/Plugin/migrate/process/NameField.php index 0610bbb..2ba9cbb 100644 --- a/src/Plugin/migrate/process/NameField.php +++ b/src/Plugin/migrate/process/NameField.php @@ -29,12 +29,16 @@ class NameField extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $name = FullNameParser::parse($value); - return [ + $name = [ 'title' => $name['salutation'], 'given' => !empty($name['fname']) ? $name['fname'] : $name['initials'], 'family' => trim($name['lname'] . ' ' . $name['suffix']), ]; - + if (empty($name['family']) && $name['given']) { + $name['family'] = $name['given']; + $name['given'] = ''; + } + return $name; } } diff --git a/tests/src/Unit/Plugin/migrate/process/NameFieldTest.php b/tests/src/Unit/Plugin/migrate/process/NameFieldTest.php index f8a46b4..340616f 100644 --- a/tests/src/Unit/Plugin/migrate/process/NameFieldTest.php +++ b/tests/src/Unit/Plugin/migrate/process/NameFieldTest.php @@ -51,6 +51,14 @@ public function testTranform() { 'family' => 'Doe', ]; $this->assertEquals($expected, $name_info); + + $name_info = $plugin->transform('Drupal', $migrate_executable, $row, 'field_stuff'); + $expected = [ + 'title' => '', + 'given' => '', + 'family' => 'Drupal', + ]; + $this->assertEquals($expected, $name_info); } } From cd6a003ec511f19da688ba7f7591f81e2c672fda Mon Sep 17 00:00:00 2001 From: pookmish Date: Wed, 17 Nov 2021 08:29:21 -0800 Subject: [PATCH 3/5] D8CORE-4677 Migrate process plugin to get the OAuth token for use CAP (#42) --- .../migrate/process/ImageDimensionSkip.php | 2 +- .../migrate/process/OauthAccessToken.php | 84 +++++++++++++++++++ .../migrate/process/OauthAccessTokenTest.php | 53 ++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/Plugin/migrate/process/OauthAccessToken.php create mode 100644 tests/src/Unit/Plugin/migrate/process/OauthAccessTokenTest.php diff --git a/src/Plugin/migrate/process/ImageDimensionSkip.php b/src/Plugin/migrate/process/ImageDimensionSkip.php index eb76413..6a8ec1b 100644 --- a/src/Plugin/migrate/process/ImageDimensionSkip.php +++ b/src/Plugin/migrate/process/ImageDimensionSkip.php @@ -99,7 +99,7 @@ protected function isImageBigger($value) { return FALSE; } try { - [$width, $height] = getimagesize($value); + [$width, $height] = @getimagesize($value); } catch (\Exception $e) { return FALSE; diff --git a/src/Plugin/migrate/process/OauthAccessToken.php b/src/Plugin/migrate/process/OauthAccessToken.php new file mode 100644 index 0000000..1c8d4ed --- /dev/null +++ b/src/Plugin/migrate/process/OauthAccessToken.php @@ -0,0 +1,84 @@ +get('plugin.manager.migrate_plus.authentication') + ); + } + + /** + * {@inheritDoc} + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, AuthenticationPluginManager $auth_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->authPluginManager = $auth_manager; + } + + /** + * {@inheritDoc} + */ + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { + $this->configuration += $row->getSource(); + $options = $this->getAuthenticationPlugin()->getAuthenticationOptions(); + preg_match('/ .*$/', $options['headers']['Authorization'], $bearer_match); + return trim(reset($bearer_match)); + } + + /** + * Returns the initialized authentication plugin. + * + * @return \Drupal\migrate_plus\AuthenticationPluginInterface + * The authentication plugin. + */ + public function getAuthenticationPlugin() { + if (!isset($this->authenticationPlugin)) { + $this->authenticationPlugin = $this->authPluginManager->createInstance($this->configuration['authentication']['plugin'], $this->configuration['authentication']); + } + return $this->authenticationPlugin; + } + +} diff --git a/tests/src/Unit/Plugin/migrate/process/OauthAccessTokenTest.php b/tests/src/Unit/Plugin/migrate/process/OauthAccessTokenTest.php new file mode 100644 index 0000000..fa0764f --- /dev/null +++ b/tests/src/Unit/Plugin/migrate/process/OauthAccessTokenTest.php @@ -0,0 +1,53 @@ + ['Authorization' => 'Bearer foo-bar-baz']]; + $auth_plugin = $this->createMock(AuthenticationPluginInterface::class); + $auth_plugin->method('getAuthenticationOptions')->willReturn($auth_headers); + + $auth_manager = $this->createMock(AuthenticationPluginManager::class); + $auth_manager->method('createInstance')->willReturn($auth_plugin); + $container = new ContainerBuilder(); + $container->set('plugin.manager.migrate_plus.authentication', $auth_manager); + $this->processPlugin = OauthAccessToken::create($container, [], '', []); + } + + /** + * The process plugin returns the correct string. + */ + public function testTransform() { + $migration = $this->createMock(MigrateExecutableInterface::class); + $row = new Row(); + $row->setSourceProperty('authentication', ['plugin' => 'oauth2']); + $this->assertEquals('foo-bar-baz', $this->processPlugin->transform('', $migration, $row, '')); + } + +} From 9a198a9daf2a71a26f1929922cdad481577530b3 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Wed, 17 Nov 2021 08:46:23 -0800 Subject: [PATCH 4/5] Removed migrate_tools patch that has been fixed --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index d62ae5a..1c3c58c 100755 --- a/composer.json +++ b/composer.json @@ -26,9 +26,6 @@ "drupal/migrate_plus": { "https://www.drupal.org/project/migrate_plus/issues/2837684": "https://www.drupal.org/files/issues/2837684-8-migrate-plus-xml-return-as-xml.patch", "https://www.drupal.org/project/migrate_plus/issues/3050058": "https://www.drupal.org/files/issues/2019-05-17/migrate_plus-no_selector-3050058-3.patch" - }, - "drupal/migrate_tools": { - "https://www.drupal.org/project/migrate_tools/issues/2894708": "https://www.drupal.org/files/issues/2019-02-28/disabled-migrations-list-2894708-17.patch" } } }, From 6422fcab37157f8aef28cdc9918c3627d4800b14 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Thu, 18 Nov 2021 12:52:52 -0800 Subject: [PATCH 5/5] 8.1.19 --- CHANGELOG.md | 9 +++++++++ stanford_migrate.info.yml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f420e18..4e27a0a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Stanford Migrate +8.x-1.19 +-------------------------------------------------------------------------------- +_Release Date: 2021-11-18_ + +- Removed migrate_tools patch that has been fixed +- D8CORE-4677 Migrate process plugin to get the OAuth token for use CAP (#42) +- If the last name is empty, but a first name is parsed, move the first name to the last name. (#41) + + 8.x-1.18 -------------------------------------------------------------------------------- _Release Date: 2021-10-20_ diff --git a/stanford_migrate.info.yml b/stanford_migrate.info.yml index 19c4b90..3d064ac 100755 --- a/stanford_migrate.info.yml +++ b/stanford_migrate.info.yml @@ -3,7 +3,7 @@ description: 'Adds more functionality to migrate and migrate plus modules' type: module core_version_requirement: ^8.8 || ^9 package: 'Stanford' -version: 8.x-1.19-dev +version: 8.x-1.19 dependencies: - drupal:migrate - migrate_plus:migrate_plus