Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This was brought up #781594: Bartik's color integration misses 'base' key but it isn't an issue with Bartik but the Color module as far as I am concerned.
Can we add some logic here to verify that $base is set before calling _color_shift()?
429 if ($is_color) {
430 $chunk = drupal_strtolower($chunk);
431 // Check if this is one of the colors in the default palette.
432 if ($key = array_search($chunk, $default)) {
433 $chunk = $conversion[$key];
434 }
435 // Not a pre-set color. Extrapolate from the base.
436 else {
437 $chunk = _color_shift($palette[$base], $default[$base], $chunk, $info['blend_target']);
438 }
439 }
I hate seeing notices like:
# Notice: Undefined index: base in _color_rewrite_stylesheet() (line 437 of /home/dm7/modules/color/color.module).
Comment | File | Size | Author |
---|
Comments
Comment #1
mgiffordAdding link to confirmation that this is a problem with core and not just the theme it was discovered in.
#781594-8: Bartik's color integration misses 'base' key
Comment #2
joachim CreditAttribution: joachim commentedAs far as I could work it out, the problem is that $base is set, but it is set to the string 'base', which happened to not be in the Bartik palette.
Comment #3
Stevel CreditAttribution: Stevel commentedI just got the same error. Looks like this happens when an extra colorable field is added in the theme. The theme settings page tries to load the 'current' (i.e. customized) palette which does not include the new field yet.
This causes the field 'base' not to be shown on the theme settings page, and thus is not submitted, which in turn causes the index not existing.
This patch merges the current version with the default palette (and thus new fields are shown with their default value).l
Comment #4
Stevel CreditAttribution: Stevel commented#3: 789554-show-added-palette-fields.patch queued for re-testing.
Comment #5
mgiffordSteve, do you have a path for others to test this? Both the bug and how to fix it.
When do folks get this notice and is it still a problem in core?
Comment #6
joachim CreditAttribution: joachim commentedIIRC and from my own earlier comments, the problem is caused by trying to change colours on a theme that does not have a palette item called 'base'.
Comment #7
Stevel CreditAttribution: Stevel commentedTo reproduce the error, add a new color to $info['fields'] and $info['schemes'][*]['colors'] in e.g. themes/bartik/color/color.inc and try saving the theme settings.
Thus the error only occurs when a theme is updated (core or contrib), adding a new color to the palette.
Comment #8
mgiffordOk, I tried to repeat the problem with:
But I couldn't get the error again so I can't verify that anything was fixed.
Comment #9
clayball CreditAttribution: clayball commentedI'm receiving this Notice after I copied over a custom Bartik sub-theme from another site.
Everything was fine until I enabled the sub-theme and modified the header colors.
The is_color check is there and I still receive this Notice.
Comment #10
clayball CreditAttribution: clayball commentedI just fixed this by setting the sub-theme to the default color scheme and then modified the sub-themes color.css file by hand. There still seems to be an issue somewhere as this work around should not be required.
Comment #11
King of Picts CreditAttribution: King of Picts commented#3: 789554-show-added-palette-fields.patch queued for re-testing.
Comment #13
sonny30 CreditAttribution: sonny30 commented#3: 789554-show-added-palette-fields.patch queued for re-testing.
Comment #15
tim.plunkettI believe this is the same issue as #1236098: Notice: Undefined index: 'base' in _color_rewrite_stylesheet()
Despite this being opened first, the other more clearly describes the problem, so marking this one as a duplicate.
Comment #16
cerr CreditAttribution: cerr commentedHi,
I'm getting this error:
Notice: Undefined index: text in _color_rewrite_stylesheet() (line 479 of /home/content/80/9693280/html/site/modules/color/color.module).
After I tried to change colors in color.css manually with Corporate Clean - how dio I fix this? Now my colors seem to be almost random... :o
Thanks!
Comment #17
geek-merlinThis is still an issue with current dev. The supposed dup was closed 9 years ago for bartik.
As correctly analyzed by @joachin in #6, this happens for any theme that does not declare an entry named "base" in its palette.
The offending code...
... obviously extrapolates colors not registered in the palette and needs a base color for this.
We could proceed in 2 ways:
a) Make the 'base' color a requirement for any theme and fix bartik for that
b) Use the first available color for $base if no 'base' key present.
After reading the _color_shift function's comment, i'm pragmatically for b).
After reading some more, i'm undecided...Comment #18
geek-merlinUps, i had the wrond dup, so closing again.
Comment #19
emb03 CreditAttribution: emb03 commentedThis is still an issue. I am using a subtheme of a subtheme and when I try to change the color in the theme to a different color, I get this error:
Notice: Undefined index: base in _color_rewrite_stylesheet() (line 553 of core/modules/color/color.module).
and the theme does not change color.Can someone finally fix this after 9 years? Thanks.
Comment #21
selinav CreditAttribution: selinav commentedSame probleme for me in the last version of Drupal 8.9.3 and a subtheme of bootstrap barrio.
Any idea how to fix it ?
Comment #22
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedwhat is the syntax for defining the "base" color in the theme?
Comment #23
marvil07 CreditAttribution: marvil07 at Adapt commentedBack to closed as duplicated of #1236098: Notice: Undefined index: 'base' in _color_rewrite_stylesheet(), following the reasoning at #789554-15: Notice: Undefined index: base in _color_rewrite_stylesheet() in line 437.
Let us continue there instead of re-opening this one.