diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index c65da98d7f31..068eb0a7d53c 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -379,6 +379,16 @@ class ThemeSettingsForm extends ConfigFormBase { } } + // When intending to use the default logo, unset the logo_path. + if ($form_state->getValue('default_logo')) { + $form_state->unsetValue('logo_path'); + } + + // When intending to use the default favicon, unset the favicon_path. + if ($form_state->getValue('default_favicon')) { + $form_state->unsetValue('favicon_path'); + } + // If the user provided a path for a logo or favicon file, make sure a file // exists at that path. if ($form_state->getValue('logo_path')) { diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index 30bd9a2ee9a3..e01f28a44f27 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -201,6 +201,18 @@ class ThemeTest extends WebTestBase { $this->assertLink($theme_handler->getName('stable')); $this->drupalGet('admin/appearance/settings/stable'); $this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.'); + + // Ensure default logo and favicons are not triggering custom path + // validation errors if their custom paths are set on the form. + $edit = [ + 'default_logo' => TRUE, + 'logo_path' => 'public://whatever.png', + 'default_favicon' => TRUE, + 'favicon_path' => 'public://whatever.ico', + ]; + $this->drupalPostForm('admin/appearance/settings', $edit, 'Save configuration'); + $this->assertNoText('The custom logo path is invalid.'); + $this->assertNoText('The custom favicon path is invalid.'); } /**