diff --git a/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php b/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php new file mode 100644 index 000000000000..1a15213d72a0 --- /dev/null +++ b/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php @@ -0,0 +1,64 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php', + ]; + } + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ + $theme_handler = \Drupal::service('theme_handler'); + $theme_handler->refreshInfo(); + } + + /** + * Tests that local actions/tasks are being converted into blocks. + */ + public function testUpdateHookN() { + $this->runUpdates(); + + /** @var \Drupal\block\BlockInterface $block_storage */ + $block_storage = \Drupal::entityManager()->getStorage('block'); + + // Disable maintenance mode. + // @todo Can be removed once maintenance mode is automatically turned off + // after updates in https://www.drupal.org/node/2435135. + \Drupal::state()->set('system.maintenance_mode', FALSE); + + // We finished updating so we can login the user now. + $this->drupalLogin($this->rootUser); + + // Local actions are visible on the content listing page. + $this->drupalGet('admin/structure/block'); + $action_link = $this->cssSelect('#secondary-tabs-title'); + $this->assertTrue($action_link); + } + +} diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 86a924a8a919..6ece8ce7bad8 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1440,6 +1440,7 @@ function system_update_8005() { ] + $tabs_default_settings; _system_update_create_block($name, $theme_name, $values); + $name = 'block.block.seven_secondary_local_tasks'; $values = [ 'region' => 'pre_content', 'id' => 'seven_secondary_local_tasks', @@ -1784,6 +1785,28 @@ function system_update_8010() { return $message; } +/** + * Add secondary local tasks block to Seven (fixes system_update_8005). + */ +function system_update_8011() { + $langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId(); + $theme_name = 'seven'; + $name = 'block.block.seven_secondary_local_tasks'; + $values = [ + 'plugin' => 'local_tasks_block', + 'region' => 'pre_content', + 'id' => 'seven_secondary_local_tasks', + 'settings.label' => 'Secondary tabs', + 'settings.label_display' => 0, + 'settings.primary' => FALSE, + 'settings.secondary' => TRUE, + 'visibility' => [], + 'weight' => 0, + 'langcode' => $langcode, + ]; + _system_update_create_block($name, $theme_name, $values); +} + /** * @} End of "addtogroup updates-8.0.0-beta". */ diff --git a/core/modules/system/tests/fixtures/update/block.block.testfor2569529.yml b/core/modules/system/tests/fixtures/update/block.block.testfor2569529.yml new file mode 100644 index 000000000000..33391991c7db --- /dev/null +++ b/core/modules/system/tests/fixtures/update/block.block.testfor2569529.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + theme: + - seven +id: seven_secondary_local_tasks +theme: seven +region: pre_content +weight: 0 +provider: null +plugin: local_tasks_block +settings: + id: local_tasks_block + label: 'Secondary tabs' + provider: core + label_display: '0' + primary: false + secondary: true +visibility: { } diff --git a/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php b/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php new file mode 100644 index 000000000000..474a08526089 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php @@ -0,0 +1,46 @@ +insert('config') + ->fields([ + 'collection', + 'name', + 'data', + ]) + ->values([ + 'collection' => '', + 'name' => 'block.block.' . $block_config['id'], + 'data' => serialize($block_config), + ]) + ->execute(); +} + +// Update the config entity query "index". +$existing_blocks = $connection->select('key_value') + ->fields('key_value', ['value']) + ->condition('collection', 'config.entity.key_store.block') + ->condition('name', 'theme:seven') + ->execute() + ->fetchField(); +$existing_blocks = unserialize($existing_blocks); + +$connection->update('key_value') + ->fields([ + 'value' => serialize(array_merge($existing_blocks, ['block.block.seven_secondary_local_tasks'])) + ]) + ->condition('collection', 'config.entity.key_store.block') + ->condition('name', 'theme:seven') + ->execute();