I'm running a multisite with about 20+ websites (D7). They all are using the Webform 7.x-3.20 module - all of them have one webform each with mandatory fields. However, just today I noticed that two of the webforms were not showing their "Mandatory" asterisks. When I went to "Form Components" I saw an error message that said

Notice: Undefined index: mandatory in webform_components_form() (line 75 of /var/www/htdocs/sites/all/modules/webform/includes/webform.components.inc).

I tried to check the "Mandatory" checkboxes on the fields I wanted and hit save, but then Drupal just flashes a massive error:

    Notice: Undefined index: mandatory in webform_components_form() (line 75 of /var/www/htdocs/sites/all/modules/webform/includes/webform.components.inc).
    Notice: Undefined index: mandatory in webform_components_form_submit() (line 324 of /var/www/htdocs/sites/all/modules/webform/includes/webform.components.inc).
    PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mandatory' in 'field list': UPDATE {webform_component} SET pid=:db_update_placeholder_0, form_key=:db_update_placeholder_1, name=:db_update_placeholder_2, type=:db_update_placeholder_3, value=:db_update_placeholder_4, extra=:db_update_placeholder_5, mandatory=:db_update_placeholder_6, weight=:db_update_placeholder_7 WHERE (nid = :db_condition_placeholder_0) AND (cid = :db_condition_placeholder_1) ; Array ( [:db_update_placeholder_0] => 0 [:db_update_placeholder_1] => first_name [:db_update_placeholder_2] => First Name [:db_update_placeholder_3] => textfield [:db_update_placeholder_4] => [:db_update_placeholder_5] => a:15:{s:13:"title_display";s:6:"inline";s:7:"private";i:0;s:15:"wrapper_classes";s:0:"";s:11:"css_classes";s:0:"";s:5:"width";s:0:"";s:9:"maxlength";s:0:"";s:12:"field_prefix";s:0:"";s:12:"field_suffix";s:0:"";s:8:"disabled";i:0;s:6:"unique";i:0;s:11:"description";s:0:"";s:10:"attributes";a:0:{}s:21:"conditional_component";s:0:"";s:20:"conditional_operator";s:1:"=";s:18:"conditional_values";s:0:"";} [:db_update_placeholder_6] => 1 [:db_update_placeholder_7] => 1 [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 2 ) in webform_component_update() (line 828 of /var/www/htdocs/sites/all/modules/webform/includes/webform.components.inc).

In my research of similar issues, many people suggested running the update.php script or uninstalling and installing the Webform module. I've tried this but it doesn't work for me. I suspect I may have to manually add this column in the DB table, but this doesn't make sense since no other websites in my multisite installation have this problem, and they're sharing the same module.

Does anyone have any idea what might be the problem?

Comments

richardzili’s picture

Issue summary: View changes
danchadwick’s picture

Status: Active » Fixed

I'm guessing that this database was updated to the 7.x-4.x branch and update 7408 ran, which renames the mandatory column to required.

If so, you can undo this by renaming it back, but I worry about the (tons) of other problems. If it is feasible, I would disable and uninstall webform. This will delete all the webform data. Then re-install the module and re-create the webforms.

If this isn't feasible, then you would have to examine webform.install and determine which of the update function ran (when they shouldn't) and reverse them. This may be difficult or impossible.

You can find the webform row in the system table to find out what the schema version is. This would tell you what updates the database *think* have been run. This may not be accurate, of course, if changes have been made manually.

richardzili’s picture

Thanks, DanChadwick. I first tried to rename the column, which yielded only partial success (and creates potential problems down the road, as you hinted).

What ultimately worked for me was disabling and uninstalling the webform module. A critical step in this is to make sure to disable any elements on the websites (blocks, pages, etc.) that refer to the webform. I then flushed the cache, installed the new webform module, and ran the update.php script - now the errors are gone. The only tough part was having to repeat this process for all 20 websites and re-create the webforms.

I had no idea that Drupal can "see" a different schema version than the one the module actually is on.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

happyblitz’s picture

I've got the same issue. The problem went away when i upgraded webform module to 7.x-4.17 version.