diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml index 57e55472555e8958abcda3a67c2c5b53e8b6cd55..81c03dbca0745d79ff4933e90796e52363201a68 100644 --- a/core/config/schema/core.entity.schema.yml +++ b/core/config/schema/core.entity.schema.yml @@ -379,3 +379,33 @@ block.settings.field_block:*:*:*: action.configuration.entity:*:*: type: action_configuration_default label: 'Entity action' + +action.configuration.action_send_email_action: + type: mapping + label: 'Send email configuration' + mapping: + recipient: + type: string + label: 'Recipient' + subject: + type: label + label: 'Subject' + message: + type: text + label: 'Message' + +action.configuration.action_goto_action: + type: mapping + label: 'Redirect to URL configuration' + mapping: + url: + type: string + label: 'URL' + +action.configuration.action_message_action: + type: mapping + label: 'Display a message to the user configuration' + mapping: + message: + type: text + label: 'Message' diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php similarity index 99% rename from core/modules/action/src/Plugin/Action/EmailAction.php rename to core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php index 0791a3f99889a7ec438826f106933cbc7d3b41f8..0f8a4575febf396bd50a798824f753c24889e31b 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php @@ -1,6 +1,6 @@ update($sandbox, 'action', function (ActionConfigEntityInterface $action) use ($resave_ids) { + // Save entity to recalculate dependencies. + return $action->isConfigurable() && in_array($action->getPlugin()->getPluginId(), $resave_ids, TRUE); + }); +} diff --git a/core/modules/action/config/schema/action.schema.yml b/core/modules/action/config/schema/action.schema.yml index 421e05fd18297352d440f597045226e7b4f21349..934df120f4734cabb2201e9e3fb7dc4c9b011ab4 100644 --- a/core/modules/action/config/schema/action.schema.yml +++ b/core/modules/action/config/schema/action.schema.yml @@ -7,34 +7,3 @@ action.settings: recursion_limit: type: integer label: 'Recursion limit for actions' - - -action.configuration.action_send_email_action: - type: mapping - label: 'Send email configuration' - mapping: - recipient: - type: string - label: 'Recipient' - subject: - type: label - label: 'Subject' - message: - type: text - label: 'Message' - -action.configuration.action_goto_action: - type: mapping - label: 'Redirect to URL configuration' - mapping: - url: - type: string - label: 'URL' - -action.configuration.action_message_action: - type: mapping - label: 'Display a message to the user configuration' - mapping: - message: - type: text - label: 'Message' diff --git a/core/modules/system/tests/fixtures/update/drupal-8.actions-2815379.php b/core/modules/system/tests/fixtures/update/drupal-8.actions-2815379.php new file mode 100644 index 0000000000000000000000000000000000000000..c76a840fcb3604406b1e7ef595f1df9706a62925 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.actions-2815379.php @@ -0,0 +1,47 @@ +insert('config') + ->fields([ + 'collection', + 'name', + 'data', + ]) + ->values([ + 'collection' => '', + 'name' => 'system.action.' . $action['id'], + 'data' => serialize($action), + ]) + ->execute(); +} + +// Enable action module. +$extensions = $connection->select('config') + ->fields('config', ['data']) + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); +$extensions = unserialize($extensions); +$connection->update('config') + ->fields([ + 'data' => serialize(array_merge_recursive($extensions, ['module' => ['action' => 0]])), + ]) + ->condition('name', 'core.extension') + ->execute(); diff --git a/core/modules/system/tests/fixtures/update/system.action.goto_2815379.yml b/core/modules/system/tests/fixtures/update/system.action.goto_2815379.yml new file mode 100644 index 0000000000000000000000000000000000000000..1186ec9472893a9249da8f640c1febfb830be6ef --- /dev/null +++ b/core/modules/system/tests/fixtures/update/system.action.goto_2815379.yml @@ -0,0 +1,12 @@ +uuid: 2573293e-c7b6-4f53-905a-10ec7c55f3d0 +langcode: en +status: true +dependencies: + module: + - action +id: goto_2815379 +label: 'Goto action' +type: system +plugin: action_goto_action +configuration: + url: /user diff --git a/core/modules/system/tests/fixtures/update/system.action.message_2815379.yml b/core/modules/system/tests/fixtures/update/system.action.message_2815379.yml new file mode 100644 index 0000000000000000000000000000000000000000..01b51cee7027cf9f40e15474969ed61b91777642 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/system.action.message_2815379.yml @@ -0,0 +1,12 @@ +uuid: e34302d4-3afc-40ec-bdf0-cbd23e2f7f52 +langcode: en +status: true +dependencies: + module: + - action +id: message_2815379 +label: 'Display message' +type: system +plugin: action_message_action +configuration: + message: 'Test message' diff --git a/core/modules/system/tests/fixtures/update/system.action.send_email_2815379.yml b/core/modules/system/tests/fixtures/update/system.action.send_email_2815379.yml new file mode 100644 index 0000000000000000000000000000000000000000..7651bcafdd97beca04659a72cf64969c343447b5 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/system.action.send_email_2815379.yml @@ -0,0 +1,14 @@ +uuid: 741d330c-9260-45f8-8a81-67d2cd430f4a +langcode: en +status: true +dependencies: + module: + - action +id: send_email_2815379 +label: 'Send email' +type: system +plugin: action_send_email_action +configuration: + recipient: drupal@example.com + subject: Subject + message: Message diff --git a/core/modules/system/tests/src/Functional/Update/MoveActionsToCoreTest.php b/core/modules/system/tests/src/Functional/Update/MoveActionsToCoreTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4d191994b8834075dde3b37dfc266fd0c4e9d795 --- /dev/null +++ b/core/modules/system/tests/src/Functional/Update/MoveActionsToCoreTest.php @@ -0,0 +1,56 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz', + __DIR__ . '/../../../../tests/fixtures/update/drupal-8.actions-2815379.php', + ]; + } + + /** + * Tests upgrading actions to core namespace. + * + * @see action_post_update_move_plugins() + */ + public function testUpdateActionPlugins() { + $actions = ['goto_2815379', 'message_2815379', 'send_email_2815379']; + $before = []; + + $dependencies = ['module' => ['action']]; + foreach ($actions as $key) { + $config = \Drupal::configFactory()->get('system.action.' . $key); + $this->assertSame($dependencies, $config->get('dependencies')); + $before[$key] = $config->getRawData(); + } + + $this->runUpdates(); + + foreach ($actions as $key) { + /** @var \Drupal\system\Entity\Action $key */ + $action = Action::load($key); + $this->assertSame([], $action->getDependencies()); + // Tests that other properties remains the same. + $config = \Drupal::configFactory()->get('system.action.' . $key); + $after = $before[$key]; + $after['dependencies'] = []; + $this->assertSame($after, $config->getRawData()); + } + } + +} diff --git a/core/modules/action/tests/src/Kernel/Plugin/Action/EmailActionTest.php b/core/tests/Drupal/KernelTests/Core/Action/EmailActionTest.php similarity index 93% rename from core/modules/action/tests/src/Kernel/Plugin/Action/EmailActionTest.php rename to core/tests/Drupal/KernelTests/Core/Action/EmailActionTest.php index a47f9b35f74e5aaa70f4f7f92db6fac8def2f26d..22bd3bbe3071eaf31590cedfbbc9718665e7dc12 100644 --- a/core/modules/action/tests/src/Kernel/Plugin/Action/EmailActionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Action/EmailActionTest.php @@ -1,6 +1,6 @@