A previous custom logo path is validated (and fails) when default logo is set. The path became meanwhile invalid and now I cannot save the settings changes any more. When the default logo is used, no custom path validation should take place.

Comments

markhalliwell’s picture

Title: custom logo path validated when default is set » Theme's "Path to custom logo" always validated even if "Use the default logo" is set
Project: Bootstrap » Drupal core
Version: 7.x-3.x-dev » 8.0.x-dev
Component: Code » theme system
Issue tags: +Needs backport to D7

Here's a rather "easy fix": Uncheck "Use the default logo", remove the custom logo path and then recheck "Use the default logo".

This is actually a Drupal core bug in system_theme_settings_validate() which always invokes _system_theme_settings_validate_path():
if (!empty($form_state['values']['logo_path'])) {

It should instead probably check:
if (!empty($form_state['values']['default_logo']) && !empty($form_state['values']['logo_path'])) {

We should also probably do the same fix for the custom favicon path as well.

Moving over to core IQ, should be checked against 8.0.x first and then backported to 7.x.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

Status: Active » Needs review
StatusFileSize
new727 bytes

Thanks for the issue report. Here's one idea to resolve this. I just during validation check if the default checkbox is set and unset the value before the path is validated.

joelpittet’s picture

Issue tags: +Novice, +Needs manual testing

Give it a try and let us know if this will work for you.

Status: Needs review » Needs work

The last submitted patch, 3: theme_s_path_to_custom-2285311-3.patch, failed testing.

BSpeel’s picture

Tested the above patch in Bartik. Confirmed it did not work beforehand and did work after the patch was applied. +1 RTBC

lauriii’s picture

Issue tags: +Needs tests

I think we want to add automated test coverage for this since this is a bug.

cytherion’s picture

Version: 8.1.x-dev » 8.2.x-dev
Issue tags: -Needs backport to D7, -Novice, -Needs manual testing, -Needs tests

Confirmed that the patch is working in 8.2.0-Dev / Bartik

cytherion’s picture

Version: 8.2.x-dev » 8.1.x-dev
Issue tags: +Needs tests, +Needs backport to D7, +Novice, +Needs manual testing

Re-adding tags.

kay_v’s picture

@susannecoats - nice! useful to have confirmed the issue existed before applying the patch, and that the patch fixed it. I think I understood you plan(ned) to review the code for compliance with Drupal Code Standards. Is that a next step? (check this page for information about writing tests and other Contributor Tasks).

tomatkins’s picture

I am working on the "same fix for the custom favicon path" as listed in #1.

tomatkins’s picture

StatusFileSize
new920 bytes

Added "default-favicon" update from the validation that was missing from last patch.

tomatkins’s picture

Status: Needs work » Needs review
cytherion’s picture

I think the test for this probably involves checking if the "Use the default logo supplied by the theme" or "Use the default shortcut icon supplied by the theme" is checked and looking at whether an error message was generated following submit. e.g.

If (box_checked and error) THEN fail; 
ELSE box_checked and no_error THEN pass;

However, I don't now how to check these things from a test, so someone else will need to implement this.

tomatkins’s picture

StatusFileSize
new778 bytes
joelpittet’s picture

Assigned: Unassigned » joelpittet
Issue tags: -Novice, -Needs manual testing

Thank you @tomatkins and @susannecoates for tackling this issue at the sprint yesterday.

@susannecoates I'll see if I can write up a similar test to your pseudo test code in #14. Thank you for thinking through the problem and confirming with me this approach seems to be on the right track as a solution to the problem.

joelpittet’s picture

Assigned: joelpittet » Unassigned
Issue tags: -Needs tests
StatusFileSize
new1.08 KB
new1.98 KB

My local testing is not quite working at the moment so to expediate I'm just going to expect this to work first time:)

I've got a test only patch that should fail, and a combined fix and test patch that should pass.

*crosses fingers*

Status: Needs review » Needs work

The last submitted patch, 17: theme_s_path_to_custom-2285311-17.patch, failed testing.

The last submitted patch, 17: theme_s_path_to_custom-2285311-17-tests-only.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review

Retested the patch because the test was a migrate random failure(has been happening all week randomly)

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

The change itself including tests looks good for me.

I also tested this manually by trying to save theme settings with invalid path for logo and favicon. The bug seems to still exist and it's fixed after this patch.

star-szr’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/src/Form/ThemeSettingsForm.php
@@ -379,6 +379,16 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
+        $form_state->setValue('logo_path', '');
...
+        $form_state->setValue('favicon_path', '');

I think these should use unsetValue().

joelpittet’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new920 bytes
new1.98 KB

Thanks for teaching me we have a module API for that;)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 429f46a and pushed to 8.1.x and 8.2.x. Thanks!

The new backport policy means that we should open a new issue for this against D7 if we want to fix it there.

  • alexpott committed 5fa8126 on 8.2.x
    Issue #2285311 by joelpittet, tomatkins, susannecoates: Theme's "Path to...

  • alexpott committed 429f46a on 8.1.x
    Issue #2285311 by joelpittet, tomatkins, susannecoates: Theme's "Path to...

Status: Fixed » Needs work

The last submitted patch, 23: theme_s_path_to_custom-2285311-23.patch, failed testing.

star-szr’s picture

Status: Needs work » Fixed
David_Rothstein’s picture

Issue tags: -Needs backport to D7

Try not to mark issues fixed before the backport issue has been created. Otherwise the backport tends to get lost.

I went ahead and created #2741243: Theme's "Path to custom logo" always validated even if "Use the default logo" is set as a child issue now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.