Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.479
diff -u -p -r1.479 form.inc
--- includes/form.inc	26 Jul 2010 13:07:59 -0000	1.479
+++ includes/form.inc	27 Jul 2010 22:57:32 -0000
@@ -88,6 +88,14 @@
  * the form system and each other.
  *
  * The $form_state keys are:
+ * - build_info: Do not touch; internal information stored by Form API to be
+ *   able to build and rebuild the form:
+ *   - args: A list of arguments used to rebuild the form from cache.
+ * - files: A list of include files that need to be loaded to rebuild the form,
+ *   whereas each item may just be the path to a file or an array containing the
+ *   keys 'type', 'module' and 'name' for module_load_include(). Modules may
+ *   only add to this list; e.g., to ensure that an normally not loaded include
+ *   file containing handlers is automatically loaded by Form API for this form.
  * - 'values': An associative array of values submitted to the form. The
  *   validation functions and submit functions use this array for nearly all
  *   their decision making. (Note that
@@ -207,12 +215,12 @@ function drupal_get_form($form_id) {
  *     rebuild the form from cache when the original context may no longer be
  *     available:
  *     - args: An array of arguments to pass to the form builder.
- *     - files: An optional array defining include files that need to be loaded
- *       for building the form. Each array entry may be the path to a file or
- *       another array containing values for the parameters 'type', 'module' and
- *       'name' as needed by module_load_include(). The files listed here are
- *       automatically loaded by form_get_cache(). Defaults to the current menu
- *       router item's 'file' definition, if existent.
+ *   - files: An optional array defining include files that need to be loaded
+ *     for building the form. Each array entry may be the path to a file or
+ *     another array containing values for the parameters 'type', 'module' and
+ *     'name' as needed by module_load_include(). The files listed here are
+ *     automatically loaded by form_get_cache(). Defaults to the current menu
+ *     router item's 'file' definition, if existent.
  *   - rebuild: Normally, after the entire form processing is completed and
  *     submit handlers ran, a form is considered to be done and
  *     drupal_redirect_form() will redirect the user to a new page using a GET
@@ -301,10 +309,10 @@ function drupal_build_form($form_id, &$f
       // rebuilt from cache on a different path (such as 'system/ajax'). See
       // form_get_cache().
       // $menu_get_item() is not available at installation time.
-      if (!isset($form_state['build_info']['files']['menu']) && !defined('MAINTENANCE_MODE')) {
+      if (!isset($form_state['files']['menu']) && !defined('MAINTENANCE_MODE')) {
         $item = menu_get_item();
         if (!empty($item['include_file'])) {
-          $form_state['build_info']['files']['menu'] = $item['include_file'];
+          $form_state['files']['menu'] = $item['include_file'];
         }
       }
 
@@ -381,6 +389,7 @@ function form_state_defaults() {
     'rebuild' => FALSE,
     'redirect' => NULL,
     'build_info' => array('args' => array()),
+    'files' => array(),
     'temporary' => array(),
     'submitted' => FALSE,
     'programmed' => FALSE,
@@ -478,9 +487,8 @@ function form_get_cache($form_build_id, 
         $form_state = $cached->data + $form_state;
 
         // If the original form is contained in include files, load the files.
-        // See drupal_build_form().
-        $form_state['build_info'] += array('files' => array());
-        foreach ($form_state['build_info']['files'] as $file) {
+        // @see drupal_build_form()
+        foreach ($form_state['files'] as $file) {
           if (is_array($file)) {
             $file += array('type' => 'inc', 'name' => $file['module']);
             module_load_include($file['type'], $file['module'], $file['name']);
Index: modules/simpletest/tests/form_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form_test.module,v
retrieving revision 1.46
diff -u -p -r1.46 form_test.module
--- modules/simpletest/tests/form_test.module	26 Jul 2010 13:07:59 -0000	1.46
+++ modules/simpletest/tests/form_test.module	27 Jul 2010 22:39:40 -0000
@@ -1222,7 +1222,7 @@ function form_test_load_include_custom($
   // Specify the include file and enable form caching. That way the form is
   // cached when it is submitted, but needs to find the specified submit handler
   // in the include.
-  $form_state['build_info']['files'][] = array('module' => 'form_test', 'name' => 'form_test.file');
+  $form_state['files'][] = array('module' => 'form_test', 'name' => 'form_test.file');
   $form_state['cache'] = TRUE;
   return $form;
 }
