0

I add a webform node to another node via hook_page_alter() or in a block. Sometimes when submitting this form it doesn't submit the data and redirect to the Custom URL set in the settings. Right after I see the the form give me this issue I notice that the submitted data does not appear under Results -> Submissions. It only happens right after clearing the cache. Once it happens if you refresh the page or go to another page that has the form it doesn't happen. If I go to the actual node that is the webform I can't reproduce this issue.

Below are the steps I take to reproduce this problem (FYI I can only reproduce it sometimes. I can reproduce it logged in as user 1 but I have better luck reproducing as anonymous user):

  1. Flush all cache via drush cc all command

  2. Refresh page with form

  3. Fill out form and submit

  4. Notice that the page refreshes instead of going to destination url (this happens maybe 40% of the time)

This is how I display the webform on certain nodes via hook_page_alter():

$get_my_free_download_node = node_load($nid);   
$markup = drupal_render(node_view($get_my_free_download_node, 'hcp_gmfd_slide_in')); 

$page['content']['sliding_panel'] = array(
  '#markup' => $script . $markup,
);

I am using Webform 7.x-3.24. I added debug code webform_client_form_submit() and my code never gets run when this issue happens.

I'm wondering if Varnish or Memcache is causing this issue? I don't ever remember seeing this a long time ago but I don't think I ever did a test of clearing the cache and testing the form right away.

These are my Memcache settings in settings.php:

$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_inc'] = './sites/all/modules/memcache/memcache.inc';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_servers'] = array('127.0.0.1:11211' => 'default');
$conf['memcache_bins'] = array('cache' => 'default');
$conf['memcache_key_prefix'] = 'AW';

$conf['reverse_proxy'] = true;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
# Bypass Drupal bootstrap for anonymous users so that Drupal sets max-age > 0
$conf['page_cache_invoke_hooks'] = FALSE;
# Fix for admin_menu disappearing see https://drupal.org/node/442560#comment-2692220
$conf['admin_menu_cache_client'] = FALSE;

Update

I originally stated that this only happened in production but after testing locally more often I was able to replicate the issue locally.

0

Turns out that this issue was happening to me locally so it wasn't Memcache or Varnish that was causing this issue. It turned out to be a webforms module.

Because I was embedding the form on another node the '#action' value was incorrect. I didn't run into this issue in the past because the code was updated on a newer version of webforms.

One fix is to use hook_form_alter() to change the action:

if ($form["#node"]->type == "stage_one_form" && !path_is_admin(current_path())) {
  $alias = "/" . drupal_get_path_alias("node/{$form['#node']->nid}");
  $form['#action'] = $alias;
}

Another fix is to run the patch I created here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.