- Patch #437018 by JamesAn: convert form_options_flatten() in form.inc to use new static caching API.

merge-requests/26/head
Dries Buytaert 2009-12-29 20:16:09 +00:00
parent f639b9e965
commit 1b521566bb
1 changed files with 9 additions and 9 deletions

View File

@ -1673,21 +1673,21 @@ function _form_set_value(&$form_values, $element, $parents, $value) {
} }
} }
function form_options_flatten($array, $reset = TRUE) { function form_options_flatten($array) {
// $reset has been ignored here as the function recurses, retaining // Always reset static var when first entering the recursion.
// its value while recursing and resetting itself when called. drupal_static_reset('_form_options_flatten');
static $return; return _form_options_flatten($array);
}
if ($reset) { function _form_options_flatten($array) {
$return = array(); $return = &drupal_static(__FUNCTION__);
}
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
form_options_flatten($value->option, FALSE); _form_options_flatten($value->option);
} }
elseif (is_array($value)) { elseif (is_array($value)) {
form_options_flatten($value, FALSE); _form_options_flatten($value);
} }
else { else {
$return[$key] = 1; $return[$key] = 1;