2c2 < index cfdfa89..a4af25b 100644 --- > index 3e74521..b68d81f 100644 5c5 < @@ -344,14 +344,11 @@ function theme_get_setting($setting_name, $theme = NULL) { --- > @@ -325,14 +325,11 @@ function theme_get_setting($setting_name, $theme = NULL) { 25c25 < @@ -1310,7 +1307,6 @@ function template_preprocess_html(&$variables) { --- > @@ -1294,7 +1291,6 @@ function template_preprocess_html(&$variables) { 33c33 < @@ -1324,9 +1320,6 @@ function template_preprocess_page(&$variables) { --- > @@ -1308,9 +1304,6 @@ function template_preprocess_page(&$variables) { 38c38 < - $variables['site_name'] = (theme_get_setting('features.name') ? SafeMarkup::checkPlain($site_config->get('name')) : ''); --- > - $variables['site_name'] = (theme_get_setting('features.name') ? $site_config->get('name') : ''); 43c43 < @@ -1439,6 +1432,13 @@ function template_preprocess_maintenance_page(&$variables) { --- > @@ -1423,6 +1416,13 @@ function template_preprocess_maintenance_page(&$variables) { 115a116,170 > diff --git a/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php b/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php > index f4d5acb..79ed24c 100644 > --- a/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php > +++ b/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php > @@ -23,7 +23,11 @@ class ConfigLanguageOverrideWebTest extends WebTestBase { > * > * @var array > */ > - public static $modules = array('language', 'system'); > + public static $modules = [ > + 'block', > + 'language', > + 'system' > + ]; > > /** > * {@inheritdoc} > @@ -54,6 +58,9 @@ function testSiteNameTranslation() { > ->set('name', 'XX site name') > ->save(); > > + // Place branding block with site name into header region. > + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); > + > $this->drupalLogout(); > > // The home page in English should not have the override. > diff --git a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php > index 688d867..0a382e2 100644 > --- a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php > +++ b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php > @@ -22,7 +22,11 @@ class ConfigSingleImportExportTest extends WebTestBase { > * > * @var array > */ > - public static $modules = array('config', 'config_test'); > + public static $modules = [ > + 'block', > + 'config', > + 'config_test' > + ]; > > /** > * Tests importing a single configuration file. > @@ -126,6 +130,10 @@ public function testImport() { > public function testImportSimpleConfiguration() { > $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); > $config = $this->config('system.site')->set('name', 'Test simple import'); > + > + // Place branding block with site name into header region. > + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); > + > $edit = array( > 'config_type' => 'system.simple', > 'config_name' => $config->getName(), 117c172 < index a05f7e7..532226b 100644 --- > index f220d1a..e679be0 100644 291a347,518 > diff --git a/core/modules/system/src/Tests/Update/SiteBrandingConvertedIntoBlockUpdateTest.php b/core/modules/system/src/Tests/Update/SiteBrandingConvertedIntoBlockUpdateTest.php > new file mode 100644 > index 0000000..8d749b6 > --- /dev/null > +++ b/core/modules/system/src/Tests/Update/SiteBrandingConvertedIntoBlockUpdateTest.php > @@ -0,0 +1,64 @@ > + + > +/** > + * @file > + * Contains \Drupal\system\Tests\Update\LocalActionsAndTasksConvertedIntoBlocksUpdateTest. > + */ > + > +namespace Drupal\system\Tests\Update; > + > +use Drupal\node\Entity\Node; > + > +/** > + * Tests the upgrade path for local actions/tasks being converted into blocks. > + * > + * @see https://www.drupal.org/node/507488 > + * > + * @group system > + */ > +class SiteBrandingConvertedIntoBlockUpdateTest extends UpdatePathTestBase { > + > + /** > + * {@inheritdoc} > + */ > + protected function setUp() { > + $this->databaseDumpFiles = [ > + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', > + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php', > + ]; > + parent::setUp(); > + } > + > + /** > + * Tests that site branding elements are being converted into blocks. > + */ > + public function testUpdateHookN() { > + $this->runUpdates(); > + > + /** @var \Drupal\block\BlockInterface $block_storage */ > + $block_storage = \Drupal::entityManager()->getStorage('block'); > + > + $this->assertRaw('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.'); > + > + // 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); > + > + // Site branding is visible on the home page. > + $this->drupalGet('/node'); > + $this->assertRaw('site-branding__logo'); > + $this->assertRaw('site-branding__name'); > + $this->assertNoRaw('site-branding__slogan'); > + > + $this->drupalGet('admin/structure/block/list/bartik'); > + > + /** @var \Drupal\Core\Config\StorageInterface $config_storage */ > + $config_storage = \Drupal::service('config.storage'); > + $this->assertTrue($config_storage->exists('block.block.test_theme_branding'), 'Site branding block has been created for the custom theme.'); > + } > + > +} > diff --git a/core/modules/system/system.install b/core/modules/system/system.install > index f7c1b39..584784e 100644 > --- a/core/modules/system/system.install > +++ b/core/modules/system/system.install > @@ -1247,3 +1247,97 @@ function system_update_8003() { > ] > ); > } > + > + > +/** > + * Place branding blocks in every theme. > + */ > +function system_update_8004() { > + // When block module is not installed, there is nothing that could be done > + // except showing a warning. > + if (!\Drupal::moduleHandler()->moduleExists('block')) { > + return t('Block module is not enabled so site branding elements, which have been converted to a block, are not visible anymore.'); > + } > + /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ > + $theme_handler = \Drupal::service('theme_handler'); > + $custom_themes_installed = FALSE; > + $message = NULL; > + $langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId(); > + > + $site_branding_default_settings = [ > + 'plugin' => 'system_branding_block', > + 'region' => 'content', > + 'settings.label' => 'Site Branding', > + 'settings.label_display' => 0, > + 'settings.cache.max_age' => 0, > + 'visibility' => [], > + 'weight' => 0, > + 'langcode' => $langcode, > + ]; > + foreach ($theme_handler->listInfo() as $theme) { > + $theme_name = $theme->getName(); > + switch ($theme_name) { > + case 'bartik': > + $name = 'block.block.bartik_branding'; > + $values = [ > + 'id' => 'bartik_branding', > + 'region' => 'header', > + ] + $site_branding_default_settings; > + _system_update_create_block($name, $theme_name, $values); > + break; > + > + case 'stark': > + $name = 'block.block.stark_branding'; > + $values = [ > + 'id' => 'stark_branding', > + 'region' => 'header', > + ] + $site_branding_default_settings; > + _system_update_create_block($name, $theme_name, $values); > + break; > + > + case 'seven': > + case 'classy': > + // Don't place any blocks or trigger custom themes installed warning. > + break; > + default: > + $custom_themes_installed = TRUE; > + $name = sprintf('block.block.%s_branding', $theme_name); > + $values = [ > + 'id' => sprintf('%s_branding', $theme_name), > + 'region' => 'content', > + 'weight' => '-50', > + ] + $site_branding_default_settings; > + _system_update_create_block($name, $theme_name, $values); > + break; > + } > + } > + > + if ($custom_themes_installed) { > + $message = t('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.'); > + } > + > + return $message; > +} > + > +/** > + * Helper function to create block configuration objects for an update. > + * > + * @param string $name > + * The name of the config object. > + * @param string $theme_name > + * The name of the theme the block is associated with. > + * @param array $values > + * The block config values. > + */ > +function _system_update_create_block($name, $theme_name, array $values) { > + if (!\Drupal::service('config.storage')->exists($name)) { > + $block = \Drupal::configFactory()->getEditable($name); > + $values['uuid'] = \Drupal::service('uuid')->generate(); > + $values['theme'] = $theme_name; > + $values['dependencies.theme'] = [$theme_name]; > + foreach ($values as $key => $value) { > + $block->set($key, $value); > + } > + $block->save(); > + } > +} 293c520 < index 027ba8b..b990697 100644 --- > index 865e101..cef2e47 100644 296c523 < @@ -1067,10 +1067,7 @@ function system_rebuild_module_data() { --- > @@ -1068,10 +1068,7 @@ function system_rebuild_module_data() { 362a590,686 > diff --git a/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml b/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml > new file mode 100644 > index 0000000..4396c75 > --- /dev/null > +++ b/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml > @@ -0,0 +1,25 @@ > +uuid: b299258f-6fb5-47f8-b42f-473787d02e22 > +langcode: en > +status: true > +dependencies: > + module: > + - system > + theme: > + - bartik > +id: bartik_branding > +theme: bartik > +region: header > +weight: 0 > +provider: null > +plugin: system_branding_block > +settings: > + id: system_branding_block > + label: 'Site Branding' > + provider: system > + label_display: '0' > + cache: > + max_age: -1 > + use_site_logo: true > + use_site_name: true > + use_site_slogan: true > +visibility: { } > diff --git a/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php b/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php > new file mode 100644 > index 0000000..576762d > --- /dev/null > +++ b/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php > @@ -0,0 +1,60 @@ > + + > +/** > + * @file > + * Contains database additions to drupal-8.bare.standard.php.gz for testing the > + * upgrade path of https://www.drupal.org/node/2005546. > + */ > + > +use Drupal\Core\Database\Database; > + > +$connection = Database::getConnection(); > + > +// Structure of a custom block with visibility settings. > +$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml')); > + > +foreach ($block_configs as $block_config) { > + $connection->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:bartik') > + ->execute() > + ->fetchField(); > +$existing_blocks = unserialize($existing_blocks); > + > +$connection->update('key_value') > + ->fields([ > + 'value' => serialize(array_merge($existing_blocks, ['block.block.bartik_branding'])) > + ]) > + ->condition('collection', 'config.entity.key_store.block') > + ->condition('name', 'theme:bartik') > + ->execute(); > + > +// Enable test theme. > +$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, ['theme' => ['test_theme' => 0]])) > + ]) > + ->condition('name', 'core.extension') > + ->execute(); 412c736 < index 009a67f..ae1eacb 100644 --- > index 9c1a33c..6b8936a 100644 415c739 < @@ -32,6 +32,7 @@ global-styling: --- > @@ -37,6 +37,7 @@ global-styling: 759c1083 < index 9a08d04..ffe0a61 100644 --- > index fffa02c..dd473d4 100644 787c1111 < .maintenance-page h1#page-title { --- > .maintenance-page .page-title { 822c1146 < index d1ba506..4f3c5a2 100644 --- > index b5d9c08..bf95c7a 100644