hook_form_system_theme_settings_alter() vs. THEME_form_system_theme_settings_alter() name-clash

Created on 16 October 2010, about 14 years ago
Updated 6 September 2023, over 1 year ago

Updated: Comment #47

Problem/Motivation

First the setup to recreate this problem:

- A sub theme set to the Admin theme
- Another sub theme (with same base theme as admin theme) set as the main front end theme
- Both sub themes have custom theme settings

When changing the theme settings for the front end theme, they are saved and take effect, however when the settings page reloads all the settings for the admin theme are loaded instead, not the front end themes settings.

To show this clearly please watch this video.

--

@bfroehle summarizes the problem technically in #2:

The theme settings pages are built by system_theme_settings(). This function generates the form by running THEME_system_theme_settings_alter() for the theme you are trying to edit, as well as all of that theme's parents. In each case, $GLOBALS['theme_key'] is set to the name of the theme we're trying to edit.

After the form is initially built, we reset $GLOBALS['theme_key'] to the name of the administration theme, and finish processing the form by calling drupal_alter() which then calls THEME_system_theme_settings_alter() and overwrites the correct sub-theme values.

Proposed resolution

We need to move away from the drupal_alter() namespace in this case as form alter hooks are the main cause of this issue.

Remaining tasks

  1. There is a patch attached to comment #43 that needs help to get passing tests

User interface changes

N/A

API changes

@JohnAlbin provides a good explantion of the API changes in #34

As discussed in https://drupal.org/node/1164790 if we rename system_theme_settings() to system_theme_config() and THEME_form_system_theme_settings_alter() to THEME_theme_config() (That would also make the module's hook alter be hook_form_system_theme_config_alter().)

Related Issues

N/A

🐛 Bug report
Status

Closed: won't fix

Version

11.0 🔥

Component
Theme 

Last updated about 14 hours ago

Created by

🇳🇿New Zealand Jeff Burnz

Live updates comments and jobs are added and updated live.
  • 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.

  • 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.

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.

  • 🇯🇵Japan tyler36 Osaka

    The video in the description requires flash to play.

    Marking it as "wont fix" based on:
    - was original open in 2010
    - has had no activity for 5 year
    - @markhalliwell comment in #63

    Should anyone decided to reopen, please note the current (5 year old) patch has multiple references to "bartik", a theme that is no longer shipped with Drupal.

Production build 0.71.5 2024