Commit 35af6480 authored by catch's avatar catch
Browse files

Issue #1006266 by alexpott, ryanissamson, Tor Arne Thune, CrookedNumber:...

Issue #1006266 by alexpott, ryanissamson, Tor Arne Thune, CrookedNumber: Saving theme-specific theme settings with no logo creates Undefined index error when file module enabled
parent c3b76edf
...@@ -428,15 +428,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -428,15 +428,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// If the user uploaded a new logo or favicon, save it to a permanent location // If the user uploaded a new logo or favicon, save it to a permanent location
// and use it in place of the default theme-provided file. // and use it in place of the default theme-provided file.
if ($this->moduleHandler->moduleExists('file')) { if (!empty($values['logo_upload'])) {
if ($file = $values['logo_upload']) { $filename = file_unmanaged_copy($values['logo_upload']->getFileUri());
$filename = file_unmanaged_copy($file->getFileUri());
$values['default_logo'] = 0; $values['default_logo'] = 0;
$values['logo_path'] = $filename; $values['logo_path'] = $filename;
$values['toggle_logo'] = 1; $values['toggle_logo'] = 1;
} }
if ($file = $values['favicon_upload']) { if (!empty($values['favicon_upload'])) {
$filename = file_unmanaged_copy($file->getFileUri()); $filename = file_unmanaged_copy($values['favicon_upload']->getFileUri());
$values['default_favicon'] = 0; $values['default_favicon'] = 0;
$values['favicon_path'] = $filename; $values['favicon_path'] = $filename;
$values['toggle_favicon'] = 1; $values['toggle_favicon'] = 1;
...@@ -456,7 +455,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -456,7 +455,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
if (empty($values['default_favicon']) && !empty($values['favicon_path'])) { if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
$values['favicon_mimetype'] = $this->mimeTypeGuesser->guess($values['favicon_path']); $values['favicon_mimetype'] = $this->mimeTypeGuesser->guess($values['favicon_path']);
} }
}
theme_settings_convert_to_config($values, $config)->save(); theme_settings_convert_to_config($values, $config)->save();
} }
......
...@@ -184,6 +184,12 @@ function testThemeSettings() { ...@@ -184,6 +184,12 @@ 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->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'));
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment