Index: modules/file/file.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/file.field.inc,v
retrieving revision 1.9
diff -u -r1.9 file.field.inc
--- modules/file/file.field.inc	1 Nov 2009 14:05:32 -0000	1.9
+++ modules/file/file.field.inc	8 Nov 2009 16:40:34 -0000
@@ -478,12 +478,14 @@
       $element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
     }
     $elements = array($element);
+    $elements[0]['#parents'][] = $delta;
   }
   else {
     // If there are multiple values, add an element for each existing one.
     $delta = -1;
     foreach ($items as $delta => $item) {
       $elements[$delta] = $element;
+      $elements[$delta]['#parents'][] = $delta;
       $elements[$delta]['#default_value'] = $item;
       $elements[$delta]['#weight'] = $delta;
     }
@@ -491,6 +493,7 @@
     $delta++;
     if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality']) {
       $elements[$delta] = $element;
+      $elements[$delta]['#parents'][] = $delta;
       $elements[$delta]['#default_value'] = $defaults;
       $elements[$delta]['#weight'] = $delta;
       $elements[$delta]['#required'] = ($element['#required'] && $delta == 0);
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.417
diff -u -r1.417 system.install
--- modules/system/system.install	8 Nov 2009 09:29:07 -0000	1.417
+++ modules/system/system.install	8 Nov 2009 16:40:35 -0000
@@ -1567,7 +1567,8 @@
     ),
     'primary key' => array('filename'),
     'indexes' => array(
-      'system_list' => array('status', 'weight', 'name'),
+      'modules' => array('type', 'status', 'weight', 'name'),
+      'bootstrap' => array('type', 'status', 'bootstrap', 'weight', 'name'),
       'type_name' => array('type', 'name'),
     ),
   );
@@ -2195,15 +2196,14 @@
 }
 
 /**
- * Shorten the {system}.type column and modify indexes.
+ * Shorten the {system}.type column and add an index on type and name.
  */
 function system_update_7018() {
   db_drop_index('system', 'modules');
   db_drop_index('system', 'type_name');
-  db_drop_index('system', 'bootstrap');
   db_change_field('system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
+  db_add_index('system', 'modules', array('type', 'status', 'weight', 'name'));
   db_add_index('system', 'type_name', array('type', 'name'));
-  db_add_index('system', 'system_list', array('status', 'weight', 'name'));
 }
 
 /**
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.550
diff -u -r1.550 theme.inc
--- includes/theme.inc	8 Nov 2009 12:43:41 -0000	1.550
+++ includes/theme.inc	8 Nov 2009 16:40:33 -0000
@@ -562,7 +562,6 @@
 
   if ($refresh) {
     $list = array();
-    drupal_static_reset('system_list');
   }
 
   if (empty($list)) {
@@ -571,7 +570,8 @@
     // Extract from the database only when it is available.
     // Also check that the site is not in the middle of an install or update.
     if (db_is_active() && !defined('MAINTENANCE_MODE')) {
-      foreach (system_list('theme') as $theme) {
+      $result = db_query("SELECT * FROM {system} WHERE type = :theme", array(':theme' => 'theme'));
+      foreach ($result as $theme) {
         if (file_exists($theme->filename)) {
           $theme->info = unserialize($theme->info);
           $themes[] = $theme;
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.395
diff -u -r1.395 form.inc
--- includes/form.inc	8 Nov 2009 13:37:34 -0000	1.395
+++ includes/form.inc	8 Nov 2009 16:40:32 -0000
@@ -3053,7 +3053,7 @@
   $batch =& batch_get();
 
   drupal_theme_initialize();
-  
+
   if (isset($batch)) {
     // Add process information
     $process_info = array(
@@ -3068,7 +3068,7 @@
     );
     $batch += $process_info;
 
-    // The batch is now completely built. Allow other modules to make changes to the 
+    // The batch is now completely built. Allow other modules to make changes to the
     // batch so that it is easier to reuse batch processes in other enviroments.
     drupal_alter('batch', $batch);
 
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.167
diff -u -r1.167 module.inc
--- includes/module.inc	8 Nov 2009 09:31:10 -0000	1.167
+++ includes/module.inc	8 Nov 2009 16:40:32 -0000
@@ -69,10 +69,21 @@
       // locations in the file system. The ordering here must also be
       // consistent with the one used in module_implements().
       if ($bootstrap) {
-        $list = system_list('bootstrap');
+        $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, name ASC");
       }
       else {
-        $list = system_list('module');
+        $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, name ASC");
+      }
+      foreach ($result as $module) {
+        if (file_exists($module->filename)) {
+          // First call drupal_get_filename() to prime the static cache for
+          // later lookups of the module path. Since we've already queried for
+          // the filename and can pass that in as an argument, this avoids a
+          // database hit for every module when drupal_get_filename() is
+          // subsequently called by drupal_load().
+          drupal_get_filename('module', $module->name, $module->filename);
+          $list[$module->name] = $module->name;
+        }
       }
     }
   }
@@ -87,49 +98,6 @@
 }
 
 /**
- * Build a list of bootstrap modules and enabled modules and themes.
- *
- * @param $type
- *   The type of list to return, either 'module', 'bootstrap', or 'theme'.
- *
- * @return
- *   An associative array of modules or themes, keyed by name, with the minimum
- *   data required to bootstrap.
- *
- * @see module_list()
- * @see list_themes()
- */
-function system_list($type) {
-  $lists = &drupal_static(__FUNCTION__);
-
-  if (!isset($lists)) {
-    $lists = array('bootstrap' => array(), 'module' => array(), 'theme' => array());
-    $result = db_query("SELECT * FROM {system} WHERE status = 1 ORDER BY weight ASC, name ASC");
-    foreach ($result as $record) {
-      // Build a list of all enabled modules.
-      if ($record->type == 'module') {
-        $lists['module'][$record->name] = $record->name;
-        // Build a separate array of modules required for bootstrap.
-        if ($record->bootstrap) {
-          $lists['bootstrap'][$record->name] = $record->name;
-        }
-      }
-      // Build a list of enabled themes.
-      if ($record->type == 'theme') {
-        $lists['theme'][$record->name] = $record;
-      }
-
-      // Additionally prime drupal_get_filename() with the filename and type
-      // for each record, this prevents subsequent database lookups when
-      // drupal_get_filename() is called without the 'file' argument.
-      drupal_get_filename($record->type, $record->name, $record->filename);
-    }
-  }
-
-  return $lists[$type];
-}
-
-/**
  * Find dependencies any level deep and fill in required by information too.
  *
  * @param $files
@@ -268,7 +236,6 @@
 
   if (!empty($invoke_modules)) {
     // Refresh the module list to exclude the disabled modules.
-    drupal_static_reset('system_list');
     module_list(TRUE);
     module_implements('', FALSE, TRUE);
     // Force to regenerate the stored list of hook implementations.
@@ -329,7 +296,6 @@
 
   if (!empty($invoke_modules)) {
     // Refresh the module list to exclude the disabled modules.
-    drupal_static_reset('system_list');
     module_list(TRUE);
     module_implements('', FALSE, TRUE);
     // Invoke hook_modules_disabled before disabling modules,
Index: modules/field/theme/field.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/theme/field.css,v
retrieving revision 1.6
diff -u -r1.6 field.css
--- modules/field/theme/field.css	28 Aug 2009 06:51:07 -0000	1.6
+++ modules/field/theme/field.css	8 Nov 2009 16:40:33 -0000
@@ -20,7 +20,7 @@
   width: 30px;
   padding-right: 0; /*LTR*/
 }
-form .field-multiple-table td.field-multiple-drag a.tabledrag-handle{
+form .field-multiple-table td.field-multiple-drag a.tabledrag-handle {
   padding-right: .5em; /*LTR*/
 }
 
@@ -32,7 +32,7 @@
   display: inline;
   width: auto;
 }
-form .form-item .number {
+form .form-item .widget-number {
   display: inline;
   width: auto;
 }
Index: modules/field/modules/number/number.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/number/number.module,v
retrieving revision 1.25
diff -u -r1.25 number.module
--- modules/field/modules/number/number.module	1 Nov 2009 22:19:56 -0000	1.25
+++ modules/field/modules/number/number.module	8 Nov 2009 16:40:33 -0000
@@ -7,15 +7,6 @@
  */
 
 /**
- * Implement hook_theme().
- */
-function number_theme() {
-  return array(
-    'number' => array('render element' => 'element'),
-  );
-}
-
-/**
  * Implement hook_theme_alter().
  */
 function number_theme_registry_alter(&$theme_registry) {
@@ -39,7 +30,7 @@
     'number_decimal' => array(
       'label' => t('Decimal'),
       'description' => t('This field stores a number in the database in a fixed decimal format.'),
-      'settings' => array('precision' => 10, 'scale' => 2, 'decimal' => '.'),
+      'settings' => array('precision' => 10, 'scale' => 2, 'decimal_separator' => '.'),
       'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''),
       'default_widget' => 'number',
       'default_formatter' => 'number_decimal',
@@ -47,6 +38,7 @@
     'number_float' => array(
       'label' => t('Float'),
       'description' => t('This field stores a number in the database in a floating point format.'),
+      'settings' => array('decimal_separator' => '.'),
       'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''),
       'default_widget' => 'number',
       'default_formatter' => 'number_decimal',
@@ -117,7 +109,9 @@
       '#description' => t('The number of digits to the right of the decimal.'),
       '#disabled' => $has_data,
     );
-    $form['decimal'] = array(
+  }
+  if ($field['type'] == 'number_decimal' || $field['type'] == 'number_float') {
+    $form['decimal_separator'] = array(
       '#type' => 'select',
       '#title' => t('Decimal marker'),
       '#options' => array(
@@ -125,7 +119,7 @@
         ',' => 'comma',
         ' ' => 'space',
       ),
-      '#default_value' => $settings['decimal'],
+      '#default_value' => $settings['decimal_separator'],
       '#description' => t('The character users will input to mark the decimal point in forms.'),
     );
   }
@@ -277,14 +271,6 @@
 
 /**
  * Implement hook_field_widget_info().
- *
- * Here we indicate that the Field module will handle
- * multiple values for these widgets.
- *
- * Callbacks can be omitted if default handing is used.
- * They're included here just so this module can be used
- * as an example for custom modules that might do things
- * differently.
  */
 function number_field_widget_info() {
   return array(
@@ -296,185 +282,91 @@
 }
 
 /**
- * Implement hook_element_info().
- *
- * Includes a regex to check for valid values as an additional parameter
- * the validator can use. The regex can be overridden if necessary.
- */
-function number_element_info() {
-  $types['number'] = array(
-    '#input' => TRUE,
-    '#columns' => array('value'),
-    '#delta' => 0,
-    '#process' => array('number_elements_process'),
-  );
-  return $types;
-}
-
-/**
  * Implement hook_field_widget().
  */
 function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
-  $element += array(
-    '#type' => $instance['widget']['type'],
-    '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
-  );
-  return $element;
-}
-
-/**
- * Implement hook_field_widget_error().
- */
-function number_field_widget_error($element, $error) {
-  form_error($element['value'], $error['message']);
-}
-
-/**
- * Process an individual element.
- *
- * Build the form element. When creating a form using FAPI #process,
- * note that $element['#value'] is already set.
- *
- * The $field and $instance arrays are in $form['#fields'][$element['#field_name']].
- */
-function number_elements_process($element, $form_state, $form) {
-  $field_name = $element['#field_name'];
-  $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
-  $field_key  = $element['#columns'][0];
-
-  $value = isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : '';
-  if ($field['type'] == 'number_decimal') {
-    $value = str_replace('.', $field['settings']['decimal'], $value);
+  $value = isset($items[$delta]['value']) ? $items[$delta]['value'] : '';
+  // Substitute the decimal separator.
+  if ($field['type'] == 'number_decimal' || $field['type'] == 'number_float') {
+    $value = strtr($value, '.', $field['settings']['decimal_separator']);
   }
 
-  $element[$field_key] = array(
+  $element += array(
     '#type' => 'textfield',
     '#default_value' => $value,
-    // Need to allow a slightly larger size that the field length to allow
-    // for some configurations where all characters won't fit in input field.
+    // Allow a slightly larger size that the field length to allow for some
+    // configurations where all characters won't fit in input field.
     '#size' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] + 2 : 12,
     '#maxlength' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] : 10,
-    '#attributes' => array('class' => array('number')),
-    // The following values were set by the Field module and need
-    // to be passed down to the nested element.
-    '#title' => $element['#title'],
-    '#description' => $element['#description'],
-    '#required' => $element['#required'],
-    '#field_name' => $element['#field_name'],
-    '#object_type' => $element['#object_type'],
-    '#bundle' => $element['#bundle'],
-    '#delta' => $element['#delta'],
-    '#columns' => $element['#columns'],
+    // A specific CSS class is needed to override node form default styling and
+    // allow texfield inputs with a custom width.
+    '#attributes' => array('class' => array('widget-number')),
+    // Extract the number type from the field type name for easier validation.
+    '#number_type' => str_replace('number_', '', $field['type']),
   );
 
+  // Add prefix and suffix.
   if (!empty($instance['settings']['prefix'])) {
     $prefixes = explode('|', $instance['settings']['prefix']);
-    $element[$field_key]['#field_prefix'] = field_filter_xss(array_pop($prefixes));
+    $element['#field_prefix'] = field_filter_xss(array_pop($prefixes));
   }
   if (!empty($instance['settings']['suffix'])) {
     $suffixes = explode('|', $instance['settings']['suffix']);
-    $element[$field_key]['#field_suffix'] = field_filter_xss(array_pop($suffixes));
+    $element['#field_suffix'] = field_filter_xss(array_pop($suffixes));
   }
 
-  // Make sure we don't wipe out element validation added elsewhere.
-  if (empty($element['#element_validate'])) {
-    $element['#element_validate'] = array();
-  }
-  switch ($field['type']) {
-    case 'number_float':
-      $element['#element_validate'][] = 'number_float_validate';
-      break;
-    case 'number_integer':
-      $element['#element_validate'][] = 'number_integer_validate';
-      break;
-    case 'number_decimal':
-      $element['#element_validate'][] = 'number_decimal_validate';
-      break;
-  }
+  $element['#element_validate'][] = 'number_field_widget_validate';
+  $element['#parents'][] = 'value';
 
   return $element;
 }
 
 /**
- * FAPI validation of an individual float element.
+ * FAPI validation of an individual number element.
  */
-function number_float_validate($element, &$form_state) {
-  $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
-  $field_key = $element['#columns'][0];
-  $value = $element['#value'][$field_key];
-
-  if (($element[$field_key]['#required'] || !empty($value))) {
-    $start = $value;
-    $value = preg_replace('@[^-0-9\.]@', '', $value);
-    if ($start != $value) {
-      $error_field = implode('][', $element['#parents']) . '][' . $field_key;
-      form_set_error($error_field, t('Only numbers and decimals are allowed in %field.', array('%field' => t($instance['label']))));
+function number_field_widget_validate($element, &$form_state) {
+  $field = $form_state['complete form']['#fields'][$element['#field_name']]['field'];
+  $instance = $form_state['complete form']['#fields'][$element['#field_name']]['instance'];
+
+  $type = $element['#number_type'];
+  $value = $element['#value'];
+
+  // Reject invalid characters.
+  if (!empty($value)) {
+    switch ($type) {
+      case 'float':
+      case 'decimal':
+        $regexp = '@[^-0-9\\' . $field['settings']['decimal_separator'] . ']@';
+        $message = t('Only numbers and the decimal separator (@separator) allowed in %field.', array('%field' => t($instance['label']), '@separator' => $field['settings']['decimal_separator']));
+        break;
+
+      case 'integer';
+        $regexp = '@[^-0-9]@';
+        $message = t('Only numbers are allowed in %field.', array('%field' => t($instance['label'])));
+        break;
     }
-    else {
-      form_set_value($element[$field_key], $value, $form_state);
-    }
-  }
-}
-
-/**
- * FAPI validation of an individual integer element.
- */
-function number_integer_validate($element, &$form_state) {
-  $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
-  $field_key = $element['#columns'][0];
-  $value = $element['#value'][$field_key];
-
-  if (($element[$field_key]['#required'] || !empty($value))) {
-    $start = $value;
-    $value = preg_replace('@[^-0-9]@', '', $value);
-    if ($start != $value) {
-      $error_field = implode('][', $element['#parents']) . '][' . $field_key;
-      form_set_error($error_field, t('Only numbers are allowed in %field.', array('%field' => t($instance['label']))));
+    if ($value != preg_replace($regexp, '', $value)) {
+      form_error($element, $message);
     }
     else {
-      form_set_value($element[$field_key], $value, $form_state);
-    }
-  }
-}
-
-/**
- * FAPI validation of an individual decimal element.
- */
-function number_decimal_validate($element, &$form_state) {
-  $field = field_info_field($element['#field_name']);
-  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
-  $field_key = $element['#columns'][0];
-  $value = $element['#value'][$field_key];
-
-  if (($element[$field_key]['#required'] || !empty($value))) {
-    $start = $value;
-    $value = preg_replace('@[^-0-9\\' . $field['settings']['decimal'] . ']@', '', $value);
-    if ($start != $value) {
-      $error_field = implode('][', $element['#parents']) . '][' . $field_key;
-      form_set_error($error_field, t('Only numbers and the decimal character (%decimal) are allowed in %field.', array('%decimal' => $field['settings']['decimal'], '%field' => t($instance['label']))));
-    }
-    else {
-      $value = str_replace($field['settings']['decimal'], '.', $value);
-      $value = round($value, $field['settings']['scale']);
-      form_set_value($element[$field_key], $value, $form_state);
+      // Substitute the decimal separator,
+      if ($type == 'decimal' || $type == 'float') {
+        $value = strtr($value, $field['settings']['decimal_separator'], '.');
+      }
+      // Let PHP round the value to ensure consistent behavior across storage
+      // backends.
+      // @todo This should be done at field level.
+      if ($type == 'decimal') {
+        $value = round($value, $field['settings']['scale']);
+      }
+      form_set_value($element, $value, $form_state);
     }
   }
 }
 
 /**
- * FAPI theme for an individual number element.
- *
- * The textfield is already rendered by the textfield
- * theme and the HTML output lives in $variables['element']['#children'].
- * Override this theme to make custom changes to the output.
- *
- * $variables['element']['#field_name'] contains the field name
- * $variables['element']['#delta] is the position of this element in the group
+ * Implement hook_field_widget_error().
  */
-function theme_number($variables) {
-  $element = $variables['element'];
-  return $element['#children'];
+function number_field_widget_error($element, $error) {
+  form_error($element['value'], $error['message']);
 }
Index: modules/field/field.form.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v
retrieving revision 1.32
diff -u -r1.32 field.form.inc
--- modules/field/field.form.inc	1 Nov 2009 14:05:31 -0000	1.32
+++ modules/field/field.form.inc	8 Nov 2009 16:40:33 -0000
@@ -67,6 +67,9 @@
         // Only the first widget should be required.
         '#required' => $delta == 0 && $instance['required'],
         '#delta' => $delta,
+        // Ensure the submitted values end up where
+        // field_default_extract_form_values() expects them.
+        '#parents' => array($field['field_name'], $langcode),
       );
       if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
         // If we're processing a specific delta value for a field where the
@@ -163,6 +166,9 @@
         '#required' => $delta == 0 && $instance['required'],
         '#delta' => $delta,
         '#weight' => $delta,
+        // Ensure the submitted values end up where
+        // field_default_extract_form_values() expects them.
+        '#parents' => array($field['field_name'], $langcode, $delta),
       );
       if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element)) {
         // Input field for the delta (drag-n-drop reordering).
@@ -174,6 +180,9 @@
              // Note: this 'delta' is the FAPI 'weight' element's property.
             '#delta' => $max,
             '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
+            // The widget might have altered $element['#parents'], make sure
+            // the '_weight' value ends up where we expect it.
+            '#parents' => array($field['field_name'], $langcode, $delta, '_weight'),
             '#weight' => 100,
           );
         }
