If you go to admin/settings/filters/[number]/configure and save settings, drupal_set_variable() is called with the keys "config", "spec", and "help". That's because the config form is a system_settings_form, which automatically gets variables created using the array index.

The solution would be to alter the form array to use indices like "htmLawed_format_[number]_config" and "htmLawed_format_[number]_spec". Then, read these variables separately with variable_get() elsewhere in the code. This would also eliminate the need for _htmLawed_store_setting().

Comments

alpha2zee’s picture

Thank you for pointing this out. I will look into it (I never noticed the phantom variables), but my concern is about when the module is already in use. That is, I have to put in code to migrate variable values from the old (current) variables to new ones and then delete the old ones.

alpha2zee’s picture

Hi Gribnif, can you tell me which database table gets the phantom variables and what are they named like? I am having trouble spotting anything unusual. Thanks.

andyf’s picture

Just noticed this with 6.x as well.

@alpha2zee check out the variable table. The form currently saves the data once using _htmLawed_store_setting() and then system_settings_form_submit() also saves the variables based on the FAPI element name.

If you were to go Gribnif's route you could use a hook_update_N() to migrate the old variable to the new ones.

HTH

Andy

alpha2zee’s picture

Thanks, AndyF. I will fix the codes in a week or so once I have the time.

alpha2zee’s picture

Status: Closed (fixed) » Active

I have released version 3.1 and 2.11 of the module for Drupal 6 to fix this issue by unsetting the unnecessary form values in _htmLawed_store_setting() to prevent the creation of the phantom variables 'cache', 'config', 'help', and 'spec'. I did not implement a functionality to remove such (harmless) phantom variables if they already exist in the 'variable' table of the Drupal database because of the possibility that some other module may be using variables with identical names.

alpha2zee’s picture

Version: 7.x-3.0 » 6.x-3.0
Assigned: Unassigned » alpha2zee
Status: Active » Fixed
alpha2zee’s picture

Status: Fixed » Closed (fixed)
alpha2zee’s picture

Issue summary: View changes
Status: Active » Closed (fixed)