saves surplus variables when submitting node_type_form

Created on 9 February 2016, about 9 years ago
Updated 20 September 2024, 7 months ago

The node type form has special behaviour: any form element gets saved on submit by node module into a variable called {$form_key}_{$node_type}. This is automatic, and handles any form elements including those added by another module with hook_form_alter(): see https://api.drupal.org/api/drupal/modules!node!content_types.inc/functio....

Most modules that add properties to node types rely on this behaviour, and thus have a variable per node type. However, this module saves its own data in a single variable that covers all node types, search_api_exclude_types. But the node form is still saving variables for this module's form element, so in my {variable} table I also have search_api_exclude_setting_page, search_api_exclude_setting_article, and so on.

These variables are duplicating data, which is bad for performance, and also can cause confusion if exporting settings with Strongarm & Features.

I can see the following ways to fix this:

1. switch to the node variables. This is more variables, but it provides granularity which is good for exporting to Features. Cleanest option, but requires reworking how the module's data works, and also an update hook to convert existing users' settings.
2. search_api_exclude_form_node_type_form_submit() runs after node_type_form_submit(), so delete the variable node module just created. Inelegant, but simple.
3. change the form alteration to have search_api_exclude_form_node_type_form_submit() run before node_type_form_submit(). Save the combined variable, then hack $form_state['values'] so node_type_form_submit() doesn't see that value and save the variable. A bit fiddly, but less of a hack than option 2.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

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