#898584: cleanup the upgrade path of the System module.

From: Damien Tournoud <damien@commerceguys.com>


---
 system/system.install |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git modules/system/system.install modules/system/system.install
index 8088136..1176be1 100644
--- modules/system/system.install
+++ modules/system/system.install
@@ -2055,13 +2055,15 @@ function system_update_7016() {
  * Change the theme setting 'toggle_node_info' into a per content type variable.
  */
 function system_update_7017() {
-  $types = node_type_get_types();
-  if (count($types)) {
-    foreach ($types as $type) {
-      $node_info = theme_get_setting('toggle_node_info_' . $type->type);
-      if ($node_info !== NULL) {
-        variable_set('node_submitted_' . $type->type, $node_info);
-      }
+  // Get the global theme settings.
+  $settings = variable_get('theme_settings', array());
+  // Get the settings of the default theme.
+  $settings = array_merge($settings, variable_get('theme_' . variable_get('theme_default', 'bartik') . '_settings', array()));
+
+  $types = _update_node_get_types();
+  foreach ($types as $type) {
+    if (isset($settings['toggle_node_info_' . $type])) {
+      variable_set('node_submitted_' . $type, $settings['toggle_node_info_' . $type]);
     }
   }
 
@@ -2690,7 +2692,7 @@ function system_update_7060(&$sandbox) {
 
     // Check which node types have upload.module attachments enabled.
     $context['types'] = array();
-    foreach (node_type_get_types() as $node_type => $node_info) {
+    foreach (_update_node_get_types() as $node_type) {
       if (variable_get('upload_' . $node_type, 1)) {
         $context['types'][$node_type] = $node_type;
       }
@@ -2719,6 +2721,7 @@ function system_update_7060(&$sandbox) {
       $field = array(
         'field_name' => 'file',
         'type' => 'file',
+        'module' => 'file',
         'locked' => FALSE,
         'cardinality' => FIELD_CARDINALITY_UNLIMITED,
         'translatable' => FALSE,
@@ -2736,7 +2739,6 @@ function system_update_7060(&$sandbox) {
         'entity_type' => 'node',
         'bundle' => NULL,
         'label' => 'File attachments',
-        'widget_type' => 'file_generic',
         'required' => 0,
         'description' => '',
         'widget' => array(
@@ -2778,13 +2780,13 @@ function system_update_7060(&$sandbox) {
       );
 
       // Create the field. Save the field id for the data insertion later on.
-      $field = field_create_field($field);
+      $field = _update_field_create_field($field);
       $sandbox['field_id'] = $field['id'];
 
       // Create the instances.
       foreach ($context['types'] as $bundle) {
         $instance['bundle'] = $bundle;
-        field_create_instance($instance);
+        _update_field_create_instance($field, $instance);
       }
     }
     else {
