=== modified file 'database/updates.inc'
--- database/updates.inc	
+++ database/updates.inc	
@@ -1281,3 +1281,17 @@ function system_update_163() {
   }
   return $ret;
 }
+
+function system_update_164() {
+  $ret = array();
+  foreach (node_get_types() as $type => $name) {
+    if ($node_options = variable_get('node_options_'. $type, NULL)) {
+      $new_options = array();
+      foreach ($node_options as $option => $value) {
+        $new_options[$option] = 1;
+      }
+      variable_set('node_options_'. $node->type, $new_options);
+    }
+  }
+  return $ret;
+}
=== modified file 'includes/form.inc'
--- includes/form.inc	
+++ includes/form.inc	
@@ -423,6 +423,24 @@ function _element_info($type, $refresh =
 }
 
 /**
+ * Helper for checkboxes default_value
+ *
+ * @param $array
+ *   An array containing a list of keys
+ * @param $array
+ *   An optional array containing a list of return values
+ * @return
+ *   An array containing key => return value (defaults to 1) pairs.
+ */
+function form_checboxes_default($array, $return_values = array()) {
+  $default_value = array();
+  foreach ($array as $key => $value) {
+    $default_value[$key] = isset($return_values[$key]) ? $return_values[key] : 1;
+  }
+  return $default_value;
+}
+
+/**
  * Format a dropdown menu or scrolling selection box.
  *
  * @param $element
@@ -665,9 +683,9 @@ function expand_checkboxes($element) {
     if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
       $element['#default_value'] = array();
     }
-    foreach ($element['#options'] as $key => $choice) {
+    foreach ($element['#options'] as $key => $title) {
       if (!isset($element[$key])) {
-        $element[$key] = array('#type' => 'checkbox', '#processed' => TRUE, '#title' => $choice, '#default_value' => in_array($key, $value), '#attributes' => $element['#attributes']);
+        $element[$key] = array('#type' => 'checkbox', '#processed' => TRUE, '#title' => $title, '#default_value' => isset($value[$key]) ? $value[$key] : 0, '#attributes' => $element['#attributes']);
       }
     }
   }
=== modified file 'includes/locale.inc'
--- includes/locale.inc	
+++ includes/locale.inc	
@@ -45,7 +45,7 @@ function _locale_admin_manage_screen() {
     $options[$key] = '';
     $status = db_fetch_object(db_query("SELECT isdefault, enabled FROM {locales_meta} WHERE locale = '%s'", $key));
     if ($status->enabled) {
-      $enabled[] = $key;
+      $enabled[$key] = 1 ;
     }
     if ($status->isdefault) {
       $isdefault = $key;
@@ -63,8 +63,8 @@ function _locale_admin_manage_screen() {
       $form['translation'][$key] = array('#type' => 'markup', '#value' => "$translation->translation/$original->strings ($ratio%)");
     }
   }
-  $form['enabled'] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => $enabled, '#return_value' => 1);
-  $form['sitedefault'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $isdefault, '#return_value' => 1);
+  $form['enabled'] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => $enabled);
+  $form['sitedefault'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $isdefault);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
   return drupal_get_form('_locale_admin_manage_screen', $form);
=== modified file 'modules/aggregator.module'
--- modules/aggregator.module	
+++ modules/aggregator.module	
@@ -687,7 +687,9 @@ function aggregator_form_feed($edit = ar
   $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
   while ($category = db_fetch_object($categories)) {
     $options[$category->cid] = $category->title;
-    if ($category->fid) $values[] = check_plain($category->cid);
+    if ($category->fid) {
+      $values[$category->cid] = 1;
+    }
   }
   if ($options) {
     $form['category'] = array('#type' => 'checkboxes', '#title' => t('Categorize news items'), '#default_value' => $values, '#options' => $options, '#description' => t('New items in this feed will be automatically filed in the checked categories as they are received.'));
=== modified file 'modules/blogapi.module'
--- modules/blogapi.module	
+++ modules/blogapi.module	
@@ -563,7 +563,7 @@ function blogapi_settings() {
   $defaults = isset($node_types['blog']) ? array('blog' => 1) : array();
   $form['blogapi_node_types'] = array(
     '#type' => 'checkboxes', '#title' => t('Blog types'), '#required' => TRUE,
-    '#default_value' => array_keys(variable_get('blogapi_node_types', $defaults), 1), '#options' => $node_types,
+    '#default_value' => form_checkboxes_default(variable_get('blogapi_node_types', $defaults)), '#options' => $node_types,
     '#description' => t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).')
   );
 
=== modified file 'modules/node.module'
--- modules/node.module	
+++ modules/node.module	
@@ -1245,7 +1245,6 @@ function node_types_configure($type = NU
     $form['workflow'] = array('#type' => 'fieldset', '#title' =>t('Workflow'));
     $form['type'] = array('#type' => 'value', '#value' => $type);
 
-    $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
     return system_settings_form($type .'_node_settings', $form);
   }
   else {
@@ -1518,11 +1517,11 @@ function node_submit($node) {
     $node->uid = $user->uid ? $user->uid : 0;
     // Force defaults in case people modify the form:
     $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
-    $node->status = in_array('status', $node_options);
-    $node->moderate = in_array('moderate', $node_options);
-    $node->promote = in_array('promote', $node_options);
-    $node->sticky = in_array('sticky', $node_options);
-    $node->revision = in_array('revision', $node_options);
+    $node->status = isset($node_options['status']);
+    $node->moderate = isset($node_options['moderate']);
+    $node->promote = isset($node_options['promote']);
+    $node->sticky = isset($node_options['sticky']);
+    $node->revision = isset($node_options['revision']);
     unset($node->created);
   }
 
@@ -1640,19 +1639,19 @@ function node_form($node) {
   // If this is a new node, fill in the default values.
   $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
   if (!isset($node->status)) {
-    $node->status = in_array('status', $node_options);
+    $node->status = isset($node_options['status']);
   }
   if (!isset($node->moderate)) {
-    $node->moderate = in_array('moderate', $node_options);
+    $node->moderate = isset($node_options['moderate']);
   }
   if (!isset($node->promote)) {
-    $node->promote = in_array('promote', $node_options);
+    $node->promote = isset($node_options['promote']);
   }
   if (!isset($node->sticky)) {
-    $node->sticky = in_array('sticky', $node_options);
+    $node->sticky = isset($node_options['sticky']);
   }
   if (!isset($node->revision)) {
-    $node->revision = in_array('revision', $node_options);
+    $node->revision = isset($node_options['revision']);
   }
 
   if (user_access('administer nodes')) {
=== modified file 'modules/system.module'
--- modules/system.module	
+++ modules/system.module	
@@ -784,7 +784,7 @@ function system_themes() {
     $form[$info->name]['description'] = array('#type' => 'item', '#title' => $info->name,  '#value' => dirname($info->filename));
     $options[$info->name] = '';
     if ($info->status) {
-      $status[] = $info->name;
+      $status[$info->name] = 1;
     }
     if ($info->status && (function_exists($info->prefix . '_settings') || function_exists($info->prefix . '_features'))) {
       $form[$info->name]['operations'] = array('#type' => 'markup', '#value' => l(t('configure'), 'admin/themes/settings/' . $info->name) );
@@ -876,10 +876,10 @@ function system_modules() {
     $form['description'][$file->name] = array('#value' => $file->description);
     $options[$file->name] = '';
     if ($file->status) {
-      $status[] = $file->name;
+      $status[$file->name] = 1;
     }
     if ($file->throttle) {
-      $throttle[] = $file->name;
+      $throttle[$file->name] = 1;
     }
 
     // log the critical hooks implemented by this module
=== modified file 'modules/taxonomy.module'
--- modules/taxonomy.module	
+++ modules/taxonomy.module	
@@ -878,7 +878,7 @@ function taxonomy_get_vocabulary($vid) {
     $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
     $node_types = array();
     while ($voc = db_fetch_object($result)) {
-      $node_types[] = $voc->type;
+      $node_types[$voc->type] = $voc->type;
       unset($voc->type);
       $voc->nodes = $node_types;
       $vocabularies[$vid] = $voc;
=== modified file 'modules/upload.module'
--- modules/upload.module	
+++ modules/upload.module	
@@ -446,10 +446,10 @@ function _upload_form($node) {
     foreach ($node->files as $key => $file) {
       $options[$key] = '';
       if ($file->remove || $node->remove[$key]) {
-        $remove[] = $key;
+        $remove[$key] = 1;
       }
       if ($file->list || $node->list[$key]) {
-        $list[] = $key;
+        $list[$key] = 1;
       }
       $description = "<small>". file_create_url(($file->fid ? $file->filepath : file_create_filename($file->filename, file_create_path()))) ."</small>";
       $form['current']['description'][$key] = array('#type' => 'textfield', '#default_value' => $file->description ? $file->description : $file->filename, '#maxlength' => 256, '#description' => $description );
=== modified file 'modules/user.module'
--- modules/user.module	
+++ modules/user.module	
@@ -132,7 +132,7 @@ function user_save($account, $array = ar
     if (is_array($array['roles'])) {
       db_query('DELETE FROM {users_roles} WHERE uid = %d', $account->uid);
 
-      foreach (array_keys($array['roles']) as $rid) {
+      foreach (array_keys(array_filter($array['roles'])) as $rid) {
         db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $account->uid, $rid);
       }
     }
@@ -1171,7 +1171,7 @@ function user_edit_form($uid, $edit) {
     $form['account']['status'] = array('#type' => 'radios', '#title' => t('Status'), '#default_value' => $edit['status'], '#options' => array(t('Blocked'), t('Active')));
   }
   if (user_access('administer access control')) {
-    $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => array_keys($edit['roles']), '#options' => user_roles(1), '#description' => t('Select at least one role.  The user receives the combined permissions of all of the selected roles.'), '#required' => TRUE);
+    $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => form_checboxes_default($edit['roles']), '#options' => user_roles(1), '#description' => t('Select at least one role.  The user receives the combined permissions of all of the selected roles.'), '#required' => TRUE);
   }
 
   // Picture/avatar:
@@ -1304,7 +1304,9 @@ function user_edit_validate($form_id, $f
 
 function user_edit_submit($form_id, $form_values) {
   $account = $form_values['_account'];
-  user_save($account, $form_values, $form_values['_category']);
+  $category = $form_values['_category'];
+  unset($form_values['_account'], $form_values['submit'], $form_values['delete'], $form_values['form_id'], $form_values['_category']);
+  user_save($account, $form_values, $category);
   // Delete that user's menu cache.
   cache_clear_all('menu:'. $account->uid, TRUE);
   drupal_set_message(t('The changes have been saved.'));
@@ -1585,7 +1587,7 @@ function user_admin_perm($str_rids = NUL
         foreach ($role_names as $rid => $name) {
           // Builds arrays for checked boxes for each role
           if (strstr($role_permissions[$rid], $perm)) {
-            $status[$rid][] = $perm;
+            $status[$rid][$perm] = 1;
           }
         }
       }
