-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautosave_restore_multivalue_fields.patch
43 lines (39 loc) · 1.94 KB
/
autosave_restore_multivalue_fields.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
diff --git a/docroot/sites/all/modules/contrib/autosave/autosave.module b/docroot/sites/all/modules/contrib/autosave/autosave.module
index 36881e0..8c81626 100644
--- a/docroot/sites/all/modules/contrib/autosave/autosave.module
+++ b/docroot/sites/all/modules/contrib/autosave/autosave.module
@@ -281,7 +281,7 @@ function autosave_restore($form_id, $timestamp) {
$commands = array();
if ($record) {
- $form_state = array();
+ $form_state = unserialize($record->serialized);
// We need to extract and reuse any additional page arguments that the
// original form may have. That's especially true for, say, a node form,
// which needs the node object passed in as well.
@@ -290,13 +290,6 @@ function autosave_restore($form_id, $timestamp) {
require_once DRUPAL_ROOT . '/' . $menu_item['include_file'];
$form_state['build_info']['files'][] = $menu_item['include_file'];
}
- $form_state['input'] = unserialize($record->serialized);
-
- // Restore form arguments.
- if (!empty($record->args)) {
- $args = unserialize($record->args);
- $form_state['build_info']['args'] = $args;
- }
// Disable the "this form has already been submitted" nonsense by making
// Drupal think the form is being rebuilt as part of a multi-step form.
@@ -392,11 +385,10 @@ function autosave_save() {
$prevent_autosave = FALSE;
drupal_alter('autosave_prevent', $prevent_autosave);
- $path = $_POST['autosave_form_path'];
- $form_id = $_POST['form_id'];
- // Not all variables need to be serialized.
- unset($_POST['autosave_form_path'], $_POST['op'], $_POST['form_build_id']);
- $serialized = serialize($_POST);
+ list($form, $form_state) = ajax_get_form();
+ $path = $form_state['input']['autosave_form_path'];
+ $form_id = $form_state['input']['form_id'];
+ $serialized = serialize($form_state);
if (!$prevent_autosave) {
// Currently, each user can have only one autosave form at a particular path.