Commit 35af6480 authored by catch's avatar catch

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,34 +428,32 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -428,34 +428,32 @@ 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 (!empty($values['favicon_upload'])) {
if ($file = $values['favicon_upload']) { $filename = file_unmanaged_copy($values['favicon_upload']->getFileUri());
$filename = file_unmanaged_copy($file->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; }
} unset($values['logo_upload']);
unset($values['logo_upload']); unset($values['favicon_upload']);
unset($values['favicon_upload']);
// If the user entered a path relative to the system files directory for // If the user entered a path relative to the system files directory for
// a logo or favicon, store a public:// URI so the theme system can handle it. // a logo or favicon, store a public:// URI so the theme system can handle it.
if (!empty($values['logo_path'])) { if (!empty($values['logo_path'])) {
$values['logo_path'] = $this->validatePath($values['logo_path']); $values['logo_path'] = $this->validatePath($values['logo_path']);
} }
if (!empty($values['favicon_path'])) { if (!empty($values['favicon_path'])) {
$values['favicon_path'] = $this->validatePath($values['favicon_path']); $values['favicon_path'] = $this->validatePath($values['favicon_path']);
} }
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