Skip to content
Snippets Groups Projects
Commit 94a6ce4a authored by catch's avatar catch
Browse files

Issue #2620176 by joelpittet, markcarver, hatuhay: Logo image settings form is...

Issue #2620176 by joelpittet, markcarver, hatuhay: Logo image settings form is broken, breaks per-theme overrides and can result in data loss
parent 224c447f
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -19,9 +19,12 @@ class ThemeHandler implements ThemeHandlerInterface { ...@@ -19,9 +19,12 @@ class ThemeHandler implements ThemeHandlerInterface {
* Contains the features enabled for themes by default. * Contains the features enabled for themes by default.
* *
* @var array * @var array
*
* @see _system_default_theme_features()
*/ */
protected $defaultFeatures = array( protected $defaultFeatures = array(
'favicon', 'favicon',
'logo',
'node_user_picture', 'node_user_picture',
'comment_user_picture', 'comment_user_picture',
'comment_user_verification', 'comment_user_verification',
......
...@@ -183,12 +183,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = ...@@ -183,12 +183,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme =
'#type' => 'details', '#type' => 'details',
'#title' => t('Logo image settings'), '#title' => t('Logo image settings'),
'#open' => TRUE, '#open' => TRUE,
'#states' => array(
// Hide the logo image settings fieldset when logo display is disabled.
'invisible' => array(
'input[name="toggle_logo"]' => array('checked' => FALSE),
),
),
); );
$form['logo']['default_logo'] = array( $form['logo']['default_logo'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
...@@ -430,7 +424,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -430,7 +424,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$filename = file_unmanaged_copy($values['logo_upload']->getFileUri()); $filename = file_unmanaged_copy($values['logo_upload']->getFileUri());
$values['default_logo'] = 0; $values['default_logo'] = 0;
$values['logo_path'] = $filename; $values['logo_path'] = $filename;
$values['toggle_logo'] = 1;
} }
if (!empty($values['favicon_upload'])) { if (!empty($values['favicon_upload'])) {
$filename = file_unmanaged_copy($values['favicon_upload']->getFileUri()); $filename = file_unmanaged_copy($values['favicon_upload']->getFileUri());
......
...@@ -189,10 +189,6 @@ function testThemeSettings() { ...@@ -189,10 +189,6 @@ function testThemeSettings() {
$this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename)); $this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename));
$this->container->get('theme_handler')->install(array('bartik')); $this->container->get('theme_handler')->install(array('bartik'));
$this->drupalGet('admin/appearance/settings/bartik');
// The logo field should only be present on the global theme settings form.
$this->assertNoFieldByName('logo_path');
$this->drupalPostForm(NULL, [], t('Save configuration'));
// Ensure only valid themes are listed in the local tasks. // Ensure only valid themes are listed in the local tasks.
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']); $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']);
...@@ -212,6 +208,22 @@ function testThemeSettings() { ...@@ -212,6 +208,22 @@ function testThemeSettings() {
$this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.'); $this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.');
} }
/**
* Test the theme settings logo form.
*/
function testThemeSettingsLogo() {
// Visit Bartik's theme settings page to replace the logo.
$this->container->get('theme_handler')->install(['bartik']);
$this->drupalGet('admin/appearance/settings/bartik');
$edit = [
'default_logo' => FALSE,
'logo_path' => 'core/misc/druplicon.png',
];
$this->drupalPostForm('admin/appearance/settings/bartik', $edit, t('Save configuration'));
$this->assertFieldByName('default_logo', FALSE);
$this->assertFieldByName('logo_path', 'core/misc/druplicon.png');
}
/** /**
* Test the administration theme functionality. * Test the administration theme functionality.
*/ */
......
...@@ -1062,10 +1062,13 @@ function system_rebuild_module_data() { ...@@ -1062,10 +1062,13 @@ function system_rebuild_module_data() {
/** /**
* Returns an array of default theme features. * Returns an array of default theme features.
*
* @see \Drupal\Core\Extension\ThemeHandler::$defaultFeatures
*/ */
function _system_default_theme_features() { function _system_default_theme_features() {
return array( return array(
'favicon', 'favicon',
'logo',
'node_user_picture', 'node_user_picture',
'comment_user_picture', 'comment_user_picture',
'comment_user_verification', 'comment_user_verification',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment