diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ActionUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ActionUpgradePathTest.php new file mode 100644 index 0000000..aa9f268 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ActionUpgradePathTest.php @@ -0,0 +1,42 @@ + 'Action upgrade test', + 'description' => 'Upgrade tests with action data.', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + // Path to the database dump files. + $this->databaseDumpFiles = array( + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.minimal.database.php.gz', + ); + parent::setUp(); + } + + /** + * Tests to see if actions were upgrade. + */ + public function testActionUpgrade() { + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + + $this->drupalGet('admin/people'); + $elements = $this->xpath('//select[@name="operation"]/option'); + $this->assertTrue(!empty($elements), 'The user actions were upgraded.'); + } + +} diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 2c493fb..4a64a66 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2194,6 +2194,32 @@ function system_update_8056() { } /** + * Convert actions to configuration. + * + * @ingroup config_upgrade + */ +function system_update_8057() { + $actions = db_query("SELECT * FROM {actions}")->fetchAllAssoc('aid', PDO::FETCH_ASSOC); + $action_plugins = Drupal::service('plugin.manager.action')->getDefinitions(); + foreach ($actions as $action) { + if (isset($action_plugins[$action['callback']])) { + if (is_numeric($action['aid'])) { + $action['aid'] = $action['callback'] . '_' . $action['aid']; + } + $configuration = unserialize($action['parameters']) ?: array(); + config('action.action.' . $action['aid']) + ->set('id', $action['aid']) + ->set('label', $action['label']) + ->set('status', '1') + ->set('type', $action['type']) + ->set('plugin', $action['callback']) + ->set('configuration', $configuration) + ->save(); + } + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */