After some struggle with my custom theme and doing a bit of research on custom theme settings (which led to posting issue http://drupal.org/node/199693 later recognized as duplicate by myself - don't even bother to click), I spotted another problem as a side effect:

When the theme settings form is submitted (i.e. admin/build/themes/settings/theme_name), the resulting theme-settings stored inside variable 'theme_theme_name_settings' contain some FAPI crap that should not be there ('op', 'form_build_id', and 'form_token'). Some elements are already removed, but there are apparently new ones in FAPI after the code has been last updated.

Additionally, the submit handler keeps some constructs inherited from 5.x, which I don't see as good practices in current 6.x code:
- relies on $_POST directly, although relevant data are now passed-in from FAPI
- performs unset() on $form_state, which is now passed by reference, just to exclude elements from data processed later in the local code. My suspicion is, that this is even done without examining possible (future?) consequences; the code seems to be completely unchanged from 5.x.

How to reproduce: Submit the theme settings form at admin/build/themes/settings/theme_name. Observe the junk in variable 'theme_[theme_name]_settings'. Also see the code of system_theme_settings_submit() inside system.admin.inc (or in the patch here).

The patch cleans this up, by using 'op' passed from FAPI rather than $_POST, doing the unsets on a local copy of the values, and of course doing it for _all_ the unnecessary elements now present. (Keeping status 'normal' rather than 'minor', since we really shouldn't insert junk into variables - unserialized on every page an so on; the rest is just cleanup).

CommentFileSizeAuthor
#1 theme-settings-cleanup.patch1.3 KBJirkaRybka

Comments

JirkaRybka’s picture

StatusFileSize
new1.3 KB

And where is my attachment?!?!!!?

It was uploaded properly, before preview :-/

Bevan’s picture

Status: Needs review » Reviewed & tested by the community
patching file ./modules/system/system.admin.inc
Hunk #1 succeeded at 537 with fuzz 2 (offset 24 lines).

Looks good to me. Not sure about the FAPI stuff though

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

I wish we would have a better cleanup method then this, but for now, this is what we have in D6. Committed, thanks.

Bevan’s picture

Version: 6.x-dev » 7.x-dev
Status: Fixed » Active

By the sounds of Gabor's comment this might need a better fix in D7.

JirkaRybka’s picture

As I understand it, Gábor commented on the FAPI itself, where we have no way to tell what's real data, and what's just FAPI-internal stuff, unless we know in advance which elements are on the form. Since this form here is extendable by themes, and so virtually unlimited in real elements, we go the route of knowing what FAPI-internal stuff is present, and remove that explicitly. It's maybe ugly, hardcoding FAPI stuff, but we can't do it better, and we didn't consider/change the method here - this issue is just a small update for new FAPI in 6.x.

The "better" fix is probably going to require large changes in FAPI, so we should open a new issue, for 7.x forms system, rather than reclasifying this one IMO. Correct me if I'm wrong. I'm inclined to return this issue to 6.x fixed.

marcingy’s picture

JirkaRybka if you are happy close this issue and open a new one

JirkaRybka’s picture

Status: Active » Closed (fixed)

Ok, closed. #4 is a new, different issue, agreed. But due to my current time limits, I'm not going to open and push a new issue now. Feel free to do so, anyone...