Notice: Undefined index: 'base' in _color_rewrite_stylesheet()

Created on 1 August 2011, over 13 years ago
Updated 30 October 2023, about 1 year ago

When new colors choices are added to a theme, they do not appear on the theme settings form. This causes an error notice and user confusion.

The problem happens when using a custom color palette on the theme settings form (/admin/appearance/settings/THEME). As newer versions of a theme add support for more color-izable items, there is currently no way to get the new color fields added into this form. The form is built from the previously saved color_THEME_palette variable. Because that variable array does not contain the new colors, those fields are not added to the form. When the user attempts to save the form they get this error:

Notice: Undefined index: NEW-COLOR-NAME in _color_rewrite_stylesheet() (line 432 of /path/to/drupal7/modules/color/color.module).

This error continues to appear each time the user saves the form. The only way for the new colors to get added into the color_THEME_palette variable is for the user to switch to one of the pre-set palettes. If the user changes to a pre-set palette or the Default palette, that full set of colors is saved. At that point the error will not happen again, and the user will now get a field for each of the colors including the new ones. However, by switching to one of the pre-set palettes, the user will have lost all of their custom color choices and will need to paste in all of their color values again.

Over time as Bartik or other themes make more items color-izable, users will experience this error. Certainly contributed themes experience this problem. Here are a few issues where this is likely the underlying problem: http://drupal.org/node/1045348#comment-4168404, https://drupal.org/node/1235264, http://drupal.org/node/1038236, http://drupal.org/node/781594. Some of those are also confounded by problems with $base, but some of those are certainly a result of this issue.

There are a few possible solutions to this problem which I'll describe in a comment.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bowersox

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024