If the form cache is not in sync with the page cache, the AuthcacheFormBuildid can not return a new Buildid. The result is that nothing happens when users press the submit button on a form.

This should of course not happen, but we have had this several times while testing, debugging and building test scripts.

Attached patch tries to rebuild a new authcache template form and renames it to the originally requested form_build_id.

CommentFileSizeAuthor
recover_form_cache.patch1.83 KBbatje
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

Thanks, this is great.

+        require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+        include_once DRUPAL_ROOT . '/includes/unicode.inc';
+        include_once DRUPAL_ROOT . '/includes/menu.inc';
+        include_once DRUPAL_ROOT . '/includes/path.inc';
+        include_once DRUPAL_ROOT . '/includes/ajax.inc';
+        include_once DRUPAL_ROOT . '/includes/theme.inc';
+        module_load_all_includes('inc');
+        module_load_all(false);
+        drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL, FALSE);

What is the reason behind explicitly including those files when drupal gets bootstrapped after that anyway? Looking at _drupal_bootstrap_full it seems to me that those files should be loaded anyway? Also are you sure that the calls to module_load_all_includes and module_load_all really are required before the bootstrap?

znerol’s picture

Status: Active » Needs work

And now I remember why I left that bit out for the moment. There is another catch with this approach. Some forms need arguments. In those cases we need to supply the original arguments to drupal_get_form in order to be able to reproduce them completely.

batje’s picture

fair point. we didn't have that scenario.

znerol’s picture

Status: Needs work » Fixed

I found a way to get around the hard-coded 6h expiration time for cache_form entries. I've published a little helper module providing a cache-class capable of intercepting calls to cache_get, cache_set and cache_clear. Whenever one of those functions is called, the hooks hook_cacheobject_load, hook_cacheobject_presave and hook_cacheobject_clear get invoked. Implementors then have a chance to mess with the cache-object, i.e. alter the expiry-time etc.

When the Cache Object API module is present, authcache_form now will expose an option to set the expiry time for form prototypes held in the form cache.

Commit: 6142125

Status: Fixed » Closed (fixed)

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