if $default[$base] (default color profile base color) and $chunk (e.g. original style.css background color) are the same, the style.css in /files/color contains invalid CSS (e.g. background:;).
Steps to replicate:
- Add background:#ff0000; to the original style.css
- Set the default profile base color to #ff0000 in color/color.ini
- Set a base color to anything (e.g. #0000ff) in admin/build/themes/settings/yourtheme and save (to regenerate /files/color)
- Check the style.css in /files/color... see the background;: in the /files/color/*/styles.css?
Obviously, we need valid CSS. This has to be a bug... after some investigation I determined the cause is line 275 of color.module which states:
unset($conversion['base']);
Anyone remember the purpose of this line? It's not commented...
This sets it up for the failure on lines 301-303 where the 'base' key is not matched and therefore there is no new color to output.
Temporary Fix:
By commenting-out line 275 I was able to get the desired behavior--which is the output of the exact color specified in admin/build/themes/settings/yourtheme (e.g. background:#0000ff;).
Comment | File | Size | Author |
---|---|---|---|
#29 | drupal-6_color_base-D6.patch | 596 bytes | dboulet |
#27 | drupal-6_color_base_3.patch | 627 bytes | markabur |
#24 | drupal-6_color_base_2.patch | 444 bytes | markabur |
#20 | drupal-6_color_base.patch | 597 bytes | dboulet |
#16 | drupal-HEAD_color_base.patch | 611 bytes | dboulet |
Comments
Comment #1
dvessel CreditAttribution: dvessel commentedI ran into the same behavior just now. Spent 3 hours trying to figure it out. :\
All I did was change the base color slightly making the difference almost imperceptible.
Comment #2
Senpai CreditAttribution: Senpai commentedI ran into this also, and spent a fair bit of time experimenting, only to find out by trial and error that you need to delete some rules in the original style.css if you wanna go messing about with the generated style.css file and have any amount of success.
Comment #3
dvessel CreditAttribution: dvessel commentedOkay, tried deleting the line mentioned by mikesmullin. Tested on my theme and Garland. Both seem to work fine without unsetting the base.
Here's a patch to remove it.
Comment #4
dvessel CreditAttribution: dvessel commentedAnd for d6 head. Haven't tested this one but color.module wasn't changed much.
Comment #5
Dries CreditAttribution: Dries commentedmikesmullin or senpai: can you confirm that this patch fixes your problem? Thanks.
Comment #6
Steven CreditAttribution: Steven commentedIIRC, the reason the base color is unset in $conversion is to handle the case where another color field in the palette is the same as the base color. In Garland, this worked, because the base color is just a global tint, and only derivatives of it appear in the style.css. The array_search() breaks this behaviour though, since it searches $default, not $conversion. It probably got undone in later development tweaks.
If people can live with the fact that each color in the palette must be unique (but they can differ by only +1/-1), that line can be removed.
Comment #7
dvessel CreditAttribution: dvessel commentedSo what should be done here? Blanking out the background color is definitely a bug but what would be the other behavior if the base color is the same as one of the other colors _without_ the base color being unset?
It's hard for me to tell since it's not 100% clear to me how colors are targeted in the style sheet.
Comment #8
dvessel CreditAttribution: dvessel commentedJust wanted to note that if you can use the shorthand colors in the style sheet to match the base it won't get cleared.
Comment #9
ms2011 CreditAttribution: ms2011 commented@Dries: The patch does solve the problem.
Comment #10
catchComment #11
zany CreditAttribution: zany commentedI doesn't look like the original behaviour has any effect. $conversion is only read from ($chunk = $conversion[$key]). It won't do any good to delete 'base' from that array -- no matter if it is the same color as any other color or not.
If somehow the lookup of 'base' as a color should be prevented it needs to be deleted from $default.
The patch still works (given some fuzziness on the line numbers). Can this be rolled into the next release?
Comment #12
zany CreditAttribution: zany commentedOffending line is 374 in drupal-6.10/modules/color/color.module -- please remove!
Comment #13
markabur CreditAttribution: markabur commentedjust spent a few hours figuring out this same issue for myself and can confirm that removing the line fixes the problem.
Comment #14
freelockAfter 3 years, this bug hasn't been addressed?
Came to the same conclusion as the others in this thread, that line 374 needs to be removed. This is plainly a bug -- if the base color is in the underlying stylesheet at all, the result is invalid CSS. I don't understand why you would not want to rewrite the base color in the stylesheet -- it seems like the whole point of the color module. But if leaving the base color unchanged is the goal, then surely the replacement array should not have the base color in it, so that at least you don't end up with broken CSS!
Comment #16
dboulet CreditAttribution: dboulet commentedI actually started using the color module for the first time yesterday, and ran into this bug. Looks like this bug still exists in Drupal 7, here's a patch.
Comment #17
markabur CreditAttribution: markabur commentedThis change works for me in d6. It lets color module affect the base color in my custom theme. Could be RTBC, but I haven't tested it in d7 or with a core color-enabled theme such as Garland.
Comment #18
markabur CreditAttribution: markabur commentedOk, checked Garland in d7 HEAD and it still changes colors just fine with the patch applied. I don't have a custom color-enabled theme in d7 to test with, but I can confirm that this specific change is needed in d6 in order to let color module affect the base color of my theme. I have been working with a color-enabled zen-2.x subtheme.
Comment #19
Dries CreditAttribution: Dries commentedAs far as I can tell, this is harmless bugfix. I've committed it to CVS HEAD, and I'm moving it to D6.
Comment #20
dboulet CreditAttribution: dboulet commentedThanks Dries, here's a patch for Drupal 6.
Comment #22
markabur CreditAttribution: markabur commented#20: drupal-6_color_base.patch queued for re-testing.
Comment #24
markabur CreditAttribution: markabur commentedHere's a reroll.
Comment #25
markabur CreditAttribution: markabur commentedComment #27
markabur CreditAttribution: markabur commentedOk, let's try it this way.
Comment #29
dboulet CreditAttribution: dboulet commentedSame patch, but renamed to be ignored by testbot.