From 3a84ed2a90ab56b2563dd09f157131e45a0fe32f Mon Sep 17 00:00:00 2001 From: Gerhard Killesreiter Date: Sun, 2 Apr 2006 13:07:00 +0000 Subject: #56921, break up references in _validate, patch by chx --- includes/form.inc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'includes') diff --git a/includes/form.inc b/includes/form.inc index 91698e473..e11277391 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -157,6 +157,15 @@ function drupal_get_form($form_id, &$form, $callback = NULL) { function drupal_validate_form($form_id, &$form, $callback = NULL) { global $form_values; + // we need a copy of form_values otherwise foreach falls into an infite loop + $copy = (array)$form_values; + // this loop breaks the references in form_values thus makes it impossible for + // validate functions to modify the $form_values array + foreach ($copy as $k => $v) { + unset($form_values[$k]); + $form_values[$k] = $v; + } + if (isset($form['#token'])) { if ($form_values['form_token'] != md5(session_id() . $form['#token'] . variable_get('drupal_private_key', ''))) { // setting this error will cause the form to fail validation -- cgit v1.2.3