Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
color.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Anonymous (not verified)
Created:
19 Nov 2015 at 18:19 UTC
Updated:
23 Jun 2021 at 18:43 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedw1Nz0r created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedComment #3
jmarkel commentedI was able to reproduce this - with some additional nuances.
(see initial state image https://www.drupal.org/files/issues/2619332_Original-Color.jpg)
Comment #4
jmarkel commentedIn testing further, I found that the site logo is also going away when changing theme colors.
I seem to have narrowed things down to color.module, in color_scheme_form_submit(), where colors.css, logo.svg, and the palette values in the config store are being deleted. (lines 418 - 433)
I'll see if I can narrow down further and, hopefully, learn enough to craft a useful patch.
Comment #5
star-szrThank you both, just changing the component.
Comment #6
jjgw commentedI have a similar problem, except that the colors are not gone.
I can switch between all the preselections in the dropdown box without any problem, but when I select the default Blue Lagoon color, then the last selected color (example Ice) is shown.
Comment #7
jmarkel commentedYes that seems to be the same issue I saw in comment #3 Test 2, when CSS aggregation is turned on.
Comment #8
joelpittetYes this quite reproducible thank you fro the steps in #3.
I tried to introduce some metadata to the branding block and page at least and that wouldn't work. (I'm an amatur cacheability metadata user)
Here's a patch... though it doesn't work, it show's the theory I was testing out.
Comment #9
joelpittetThis combo seemed to fix it for me. Could you two try this patch out?
Comment #11
joelpittetBecause I added new cache tags to the page, cache tag integration tests are why the failed test, easy fix, please test that it fixes your problem.
Comment #12
jmarkel commentedYes - I verified that the patch in #9 resolves the issue for me.
Comment #13
joelpittetThanks for confirming, here's the extra cache tags in the integration test for the tests to pass.
Comment #14
berdirYou want to use the config object as a cacheable dependency. That way, you also get cache contexts/max age if applicable. (E.g. if someon has crazy use cases like changing the color based on the organic group or language or time of time).
Untested code for that:
$config = \Drupal::config(...);
$cacheability_metadata = CacheableMetadata::createFromRenderArray($build);
$cacheable_metadata->addCacheableDependency($config);
$cacheable_metadata->applyTo($build);
It's a bit convoluted but takes care of all the cache things and you don't have to figure out and hardcode cache tag names and things like that.
The problem with this is that it only works when you do a manual save in the UI and not when you e.g. deploy configuration.
For that to work, you need to implement a Cache save (or in your case delete event). See Drupal\system\EventSubscriber\ConfigCacheTag for examples.
We should probably some specific functional tests that assert that changing a setting actually updates the output?
Comment #15
joelpittetThanks @Berdir
#14.1 I can tackle unless someone wants to jump on it before this evening.
re #14.2 I'd like to do this, but may be out of my understanding at the moment. Though event subscribers sound cool.
Adding needs tests, tag for #14.3 And yes we should be able to reproduce this bug in a functional test, though could take a bit to get right as it did when I was manually testing.
Comment #16
joelpittetI think this covers all 3 points from #14
Comment #18
Jeff Burnz commentedIm not sure what the bug here is but will this also fix #2415663: Default color scheme selected returns early, fails to invalidateTags, if so can we mark the other one as a dupe and fix it here?
Comment #19
berdirNice, looks good to me.
Comment #20
wim leersLooks good :) An actual bug in the patch, and a bunch of nits.
Why this change? Seems out of scope at best.
I think this was removed by accident in response to @Berdir's review in #14.2. See the #16 interdiff.
Nit: s/Login/Log in/
Nit: s/scheme to slate/color scheme to 'slate'/
Nit: s/bartik//
Nit: s/Login/Log in/
Nit: s/scheme/color scheme/
Nit: s/Logout/Log out/
Comment #21
berdir1. Not really an accident. This issue added a second cache tag invalidation call to that function and I said that's not correct and should use a event subscriber. It's a bit scope creep but it just requires a single line in the new event subscriber (register for delete *and* save event) to make it work for both cases with the same code.
Comment #22
joelpittetCompletely on purpose to confirm Berdir's reply. It covers more cases and doesn't need duplicate code/calls. Cleaner way of dealing with config changes.
I will fix nits when I get to work in an hour. Thanks for reviews @Wim Leers and @Jeff burnz.
Comment #23
wim leersI see :) That makes sense!
One more thing that's kinda nitpicky, but less so than the ones in #20:
This can also be simplified to:
Comment #24
joelpittetNice, +1 to that clean up:)
Comment #25
joelpittetI'm trying to get people from #2415663: Default color scheme selected returns early, fails to invalidateTags to comment on this issue. Please give credit to @netsensei and @chintan.vyas as well if they don't post here if possible.
Comment #26
joelpittetTest nits have been picked from #20 and removed the variable with method chaining from #23
Comment #27
joelpittetComment #28
wim leersThis class name is a bit strange. But no idea currently for a better one.
Comment is quite unclear.
What about:
Comment #29
chintan.vyas commentedThere is an issue resolved https://www.drupal.org/node/2415663 related to #28 comment.
Comment #30
joelpittetre #28.1
ConfigCacheTag -> ColorConfigCacheInvalidator?#28.2 Sounds good to me, will fix in next patch
Comment #31
joelpittetName change and comment fix from #28
Comment #32
lauriiiShould we change the id of the service also?
Otherwise RTBC!
Comment #33
joelpittetThanks nice catch. I still prefer
CacheZapperbut I'll settle;)Comment #34
lauriiiRTBC if this is green
Comment #37
wim leersLooks great :)
Comment #38
jmarkel commentedAwesome work, all!
Comment #39
wim leersCommitter, please also give issue credit + commit credit to @jmarkel, his extensive research in #3 + #4 were instrumental.
Comment #40
alexpottCommitted 66a3cc3 and pushed to 8.0.x and 8.1.x. Thanks!
In future please try not to make unrelated and unnecessary changes in issues - it makes more work for reviewers.