diff --git a/webform_conditional.install b/webform_conditional.install index 786c18f..089aa03 100644 --- a/webform_conditional.install +++ b/webform_conditional.install @@ -171,7 +171,7 @@ function webform_conditional_update_7201(&$sandbox) { $existing_query->orderBy('rgid', 'DESC'); $existing_query->range(0,1); $rgid = $existing_query->execute()->fetchField(); - if (empty($rgid)) { + if ($rgid === FALSE) { $rgid = 0; } else { @@ -210,9 +210,13 @@ function webform_conditional_update_7201(&$sandbox) { 'target' => $component['cid'], 'weight' => 0, ); - drupal_write_record('webform_conditional', $conditional); + db_insert('webform_conditional') + ->fields($conditional) + ->execute(); foreach ($rules as $rule) { - drupal_write_record('webform_conditional_rules', $rule); + db_insert('webform_conditional_rules') + ->fields($rule) + ->execute(); } $sandbox['converted_count']++; $rgid++; @@ -223,9 +227,13 @@ function webform_conditional_update_7201(&$sandbox) { // Update the component with the conditional properties removed. if ($component['extra'] != $original_extra) { $component['extra'] = serialize($component['extra']); - drupal_write_record('webform_component', $component, array('nid', 'cid')); + db_merge('webform_component') + ->key(array('nid', 'cid')) + ->fields($component) + ->execute(); } } + $sandbox['last_nid_processed'] = $nid; } // If less than limit was processed, the update process is finished. @@ -242,3 +250,27 @@ function webform_conditional_update_7201(&$sandbox) { $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; } } + + +/** + * Implements hook_update_dependencies(). + */ +function webform_conditional_update_dependencies() { + + + // Make sure our update runs before the conditional table is altered. + $dependencies = array( + 'webform_conditional' => array( + 7201 => array( + 'webform' => 7403, + ), + ), + 'webform' => array( + 7404 => array( + 'webform_conditional' => 7201 + ) + ), + ); + + return $dependencies; +} \ No newline at end of file