diff --git a/includes/batch.inc b/includes/batch.inc
index e89ab8dec9..3f983b958d 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -483,8 +483,8 @@ function _batch_finished() {
   $batch = NULL;
 
   // Clean-up the session. Not needed for CLI updates.
-  if (isset($_SESSION)) {
-    unset($_SESSION['batches'][$batch['id']]);
+  if (isset($_SESSION['batches'][$_batch['id']])) {
+    unset($_SESSION['batches'][$_batch['id']]);
     if (empty($_SESSION['batches'])) {
       unset($_SESSION['batches']);
     }
diff --git a/includes/common.inc b/includes/common.inc
index 4b722580e2..e17ba9b2f6 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -391,7 +391,7 @@ function drupal_add_feed($url = NULL, $title = '') {
  */
 function drupal_get_feeds($delimiter = "\n") {
   $feeds = drupal_add_feed();
-  return implode($feeds, $delimiter);
+  return implode($delimiter, $feeds);
 }
 
 /**
@@ -3740,7 +3740,7 @@ function _drupal_build_css_path($matches, $base = NULL) {
   }
 
   // Prefix with base and remove '../' segments where possible.
-  $path = $_base . $matches[1];
+  $path = isset($matches[1]) ? $_base . $matches[1] : $_base;
   $last = '';
   while ($path != $last) {
     $last = $path;
@@ -6653,7 +6653,8 @@ function element_children(&$elements, $sort = FALSE) {
   $children = array();
   $sortable = FALSE;
   foreach ($elements as $key => $value) {
-    if ($key === '' || $key[0] !== '#') {
+    $_key = (string) $key;
+    if ($_key === '' || $_key[0] !== '#') {
       $children[$key] = $value;
       if (is_array($value) && isset($value['#weight'])) {
         $sortable = TRUE;
diff --git a/includes/filetransfer/filetransfer.inc b/includes/filetransfer/filetransfer.inc
index 6c55b2f43f..cd420bd06a 100644
--- a/includes/filetransfer/filetransfer.inc
+++ b/includes/filetransfer/filetransfer.inc
@@ -301,7 +301,7 @@ abstract class FileTransfer {
     $parts = explode('/', $path);
     $chroot = '';
     while (count($parts)) {
-      $check = implode($parts, '/');
+      $check = implode('/', $parts);
       if ($this->isFile($check . '/' . drupal_basename(__FILE__))) {
         // Remove the trailing slash.
         return substr($chroot, 0, -1);
diff --git a/includes/menu.inc b/includes/menu.inc
index ca37ba509d..5cf2e989a8 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -2482,60 +2482,61 @@ function menu_link_get_preferred($path = NULL, $selected_menu = NULL) {
     // which are ordered by priority (translated hrefs are preferred over
     // untranslated paths). Afterwards, the most relevant path is picked from
     // the menus, ordered by menu preference.
-    $item = menu_get_item($path);
-    $path_candidates = array();
-    // 1. The current item href.
-    $path_candidates[$item['href']] = $item['href'];
-    // 2. The tab root href of the current item (if any).
-    if ($item['tab_parent'] && ($tab_root = menu_get_item($item['tab_root_href']))) {
-      $path_candidates[$tab_root['href']] = $tab_root['href'];
-    }
-    // 3. The current item path (with wildcards).
-    $path_candidates[$item['path']] = $item['path'];
-    // 4. The tab root path of the current item (if any).
-    if (!empty($tab_root)) {
-      $path_candidates[$tab_root['path']] = $tab_root['path'];
-    }
-
-    // Retrieve a list of menu names, ordered by preference.
-    $menu_names = menu_get_active_menu_names();
-    // Put the selected menu at the front of the list.
-    array_unshift($menu_names, $selected_menu);
+    if ($item = menu_get_item($path)) {
+      $path_candidates = array();
+      // 1. The current item href.
+      $path_candidates[$item['href']] = $item['href'];
+      // 2. The tab root href of the current item (if any).
+      if ($item['tab_parent'] && ($tab_root = menu_get_item($item['tab_root_href']))) {
+        $path_candidates[$tab_root['href']] = $tab_root['href'];
+      }
+      // 3. The current item path (with wildcards).
+      $path_candidates[$item['path']] = $item['path'];
+      // 4. The tab root path of the current item (if any).
+      if (!empty($tab_root)) {
+        $path_candidates[$tab_root['path']] = $tab_root['path'];
+      }
 
-    $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
-    $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
-    $query->fields('ml');
-    // Weight must be taken from {menu_links}, not {menu_router}.
-    $query->addField('ml', 'weight', 'link_weight');
-    $query->fields('m');
-    $query->condition('ml.link_path', $path_candidates, 'IN');
-    $query->addTag('preferred_menu_links');
-
-    // Sort candidates by link path and menu name.
-    $candidates = array();
-    foreach ($query->execute() as $candidate) {
-      $candidate['weight'] = $candidate['link_weight'];
-      $candidates[$candidate['link_path']][$candidate['menu_name']] = $candidate;
-      // Add any menus not already in the menu name search list.
-      if (!in_array($candidate['menu_name'], $menu_names)) {
-        $menu_names[] = $candidate['menu_name'];
+      // Retrieve a list of menu names, ordered by preference.
+      $menu_names = menu_get_active_menu_names();
+      // Put the selected menu at the front of the list.
+      array_unshift($menu_names, $selected_menu);
+
+      $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
+      $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
+      $query->fields('ml');
+      // Weight must be taken from {menu_links}, not {menu_router}.
+      $query->addField('ml', 'weight', 'link_weight');
+      $query->fields('m');
+      $query->condition('ml.link_path', $path_candidates, 'IN');
+      $query->addTag('preferred_menu_links');
+
+      // Sort candidates by link path and menu name.
+      $candidates = array();
+      foreach ($query->execute() as $candidate) {
+        $candidate['weight'] = $candidate['link_weight'];
+        $candidates[$candidate['link_path']][$candidate['menu_name']] = $candidate;
+        // Add any menus not already in the menu name search list.
+        if (!in_array($candidate['menu_name'], $menu_names)) {
+          $menu_names[] = $candidate['menu_name'];
+        }
       }
-    }
 
-    // Store the most specific link for each menu. Also save the most specific
-    // link of the most preferred menu in $preferred_link.
-    foreach ($path_candidates as $link_path) {
-      if (isset($candidates[$link_path])) {
-        foreach ($menu_names as $menu_name) {
-          if (empty($preferred_links[$path][$menu_name]) && isset($candidates[$link_path][$menu_name])) {
-            $candidate_item = $candidates[$link_path][$menu_name];
-            $map = explode('/', $path);
-            _menu_translate($candidate_item, $map);
-            if ($candidate_item['access']) {
-              $preferred_links[$path][$menu_name] = $candidate_item;
-              if (empty($preferred_links[$path][MENU_PREFERRED_LINK])) {
-                // Store the most specific link.
-                $preferred_links[$path][MENU_PREFERRED_LINK] = $candidate_item;
+      // Store the most specific link for each menu. Also save the most specific
+      // link of the most preferred menu in $preferred_link.
+      foreach ($path_candidates as $link_path) {
+        if (isset($candidates[$link_path])) {
+          foreach ($menu_names as $menu_name) {
+            if (empty($preferred_links[$path][$menu_name]) && isset($candidates[$link_path][$menu_name])) {
+              $candidate_item = $candidates[$link_path][$menu_name];
+              $map = explode('/', $path);
+              _menu_translate($candidate_item, $map);
+              if ($candidate_item['access']) {
+                $preferred_links[$path][$menu_name] = $candidate_item;
+                if (empty($preferred_links[$path][MENU_PREFERRED_LINK])) {
+                  // Store the most specific link.
+                  $preferred_links[$path][MENU_PREFERRED_LINK] = $candidate_item;
+                }
               }
             }
           }
diff --git a/includes/pager.inc b/includes/pager.inc
index c060d0e7cd..efd0520819 100644
--- a/includes/pager.inc
+++ b/includes/pager.inc
@@ -323,6 +323,17 @@ function theme_pager($variables) {
   $parameters = $variables['parameters'];
   $quantity = $variables['quantity'];
   global $pager_page_array, $pager_total;
+  $output = '';
+
+  // Pager has not been initialized yet (ie no SQL query has run).
+  if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
+    return $output;
+  }
+
+  // There are not enough query results to display a pager.
+  if ($pager_total[$element] <= 1) {
+    return $output;
+  }
 
   // Calculate various markers within this pager piece:
   // Middle is used to "center" pages around the current page.
@@ -419,11 +430,13 @@ function theme_pager($variables) {
         'data' => $li_last,
       );
     }
-    return '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array(
+    $output = '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array(
       'items' => $items,
       'attributes' => array('class' => array('pager')),
     ));
   }
+
+  return $output;
 }
 
 
@@ -455,6 +468,11 @@ function theme_pager_first($variables) {
   global $pager_page_array;
   $output = '';
 
+  // Pager has not been initialized yet (ie no SQL query has run).
+  if (!isset($pager_page_array[$element])) {
+    return $output;
+  }
+
   // If we are anywhere but the first page
   if ($pager_page_array[$element] > 0) {
     $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
@@ -485,6 +503,11 @@ function theme_pager_previous($variables) {
   global $pager_page_array;
   $output = '';
 
+  // Pager has not been initialized yet (ie no SQL query has run).
+  if (!isset($pager_page_array[$element])) {
+    return $output;
+  }
+
   // If we are anywhere but the first page
   if ($pager_page_array[$element] > 0) {
     $page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
@@ -524,6 +547,11 @@ function theme_pager_next($variables) {
   global $pager_page_array, $pager_total;
   $output = '';
 
+  // Pager has not been initialized yet (ie no SQL query has run).
+  if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
+    return $output;
+  }
+
   // If we are anywhere but the last page
   if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
     $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
@@ -560,6 +588,11 @@ function theme_pager_last($variables) {
   global $pager_page_array, $pager_total;
   $output = '';
 
+  // Pager has not been initialized yet (ie no SQL query has run).
+  if (!isset($pager_page_array[$element]) || !isset($pager_total[$element])) {
+    return $output;
+  }
+
   // If we are anywhere but the last page
   if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
     $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
diff --git a/includes/path.inc b/includes/path.inc
index 6bd48d3063..1f18a4f0eb 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -465,14 +465,15 @@ function path_delete($criteria) {
   if (!is_array($criteria)) {
     $criteria = array('pid' => $criteria);
   }
-  $path = path_load($criteria);
-  $query = db_delete('url_alias');
-  foreach ($criteria as $field => $value) {
-    $query->condition($field, $value);
+  if ($path = path_load($criteria)) {
+    $query = db_delete('url_alias');
+    foreach ($criteria as $field => $value) {
+      $query->condition($field, $value);
+    }
+    $query->execute();
+    module_invoke_all('path_delete', $path);
+    drupal_clear_path_cache($path['source']);
   }
-  $query->execute();
-  module_invoke_all('path_delete', $path);
-  drupal_clear_path_cache($path['source']);
 }
 
 /**
diff --git a/includes/request-sanitizer.inc b/includes/request-sanitizer.inc
index 7214436b8a..e31839f1b1 100644
--- a/includes/request-sanitizer.inc
+++ b/includes/request-sanitizer.inc
@@ -99,7 +99,8 @@ class DrupalRequestSanitizer {
   protected static function stripDangerousValues($input, array $whitelist, array &$sanitized_keys) {
     if (is_array($input)) {
       foreach ($input as $key => $value) {
-        if ($key !== '' && $key[0] === '#' && !in_array($key, $whitelist, TRUE)) {
+        $_key = (string) $key;
+        if ($_key !== '' && $_key[0] === '#' && !in_array($key, $whitelist, TRUE)) {
           unset($input[$key]);
           $sanitized_keys[] = $key;
         }
diff --git a/includes/session.inc b/includes/session.inc
index 25aa3475e9..745e308358 100644
--- a/includes/session.inc
+++ b/includes/session.inc
@@ -371,10 +371,20 @@ function drupal_session_regenerate() {
 
   if (drupal_session_started()) {
     $old_session_id = session_id();
+    // PHP 7.3 requires that we close session before setting new session ID.
+    $original_session_saving = drupal_save_session();
+    drupal_save_session(FALSE);
+    session_write_close();
+    drupal_session_started(FALSE);
   }
   session_id(drupal_random_key());
 
   if (isset($old_session_id)) {
+    // Preserve and restore user object, as starting session will reset it.
+    $original_user = $user;
+    drupal_session_start();
+    $user = $original_user;
+    drupal_save_session($original_session_saving);
     $params = session_get_cookie_params();
     $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
     setcookie(session_name(), session_id(), $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
diff --git a/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php b/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php
index acd5656f47..d704d26ab1 100644
--- a/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php
+++ b/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php
@@ -476,7 +476,7 @@ class PharStreamWrapper
     {
         $arguments = func_get_args();
         array_shift($arguments);
-        $silentExecution = $functionName{0} === '@';
+        $silentExecution = $functionName[0] === '@';
         $functionName = ltrim($functionName, '@');
         $this->restoreInternalSteamWrapper();
 
diff --git a/modules/block/block.module b/modules/block/block.module
index d68ea9e7a9..84d4d75ddf 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -263,7 +263,7 @@ function block_page_build(&$page) {
   $all_regions = system_region_list($theme);
 
   $item = menu_get_item();
-  if ($item['path'] != 'admin/structure/block/demo/' . $theme) {
+  if (!$item || $item['path'] != 'admin/structure/block/demo/' . $theme) {
     // Load all region content assigned via blocks.
     foreach (array_keys($all_regions) as $region) {
       // Assign blocks to region.
@@ -281,27 +281,24 @@ function block_page_build(&$page) {
     // above.
     drupal_static_reset('block_list');
   }
-  else {
-    // Append region description if we are rendering the regions demo page.
-    $item = menu_get_item();
-    if ($item['path'] == 'admin/structure/block/demo/' . $theme) {
-      foreach (system_region_list($theme, REGIONS_VISIBLE, FALSE) as $region) {
-        $description = '<div class="block-region">' . $all_regions[$region] . '</div>';
-        $page[$region]['block_description'] = array(
-          '#markup' => $description,
-          '#weight' => 15,
-        );
-      }
-      $page['page_top']['backlink'] = array(
-        '#type' => 'link',
-        '#title' => t('Exit block region demonstration'),
-        '#href' => 'admin/structure/block' . (variable_get('theme_default', 'bartik') == $theme ? '' : '/list/' . $theme),
-        // Add the "overlay-restore" class to indicate this link should restore
-        // the context in which the region demonstration page was opened.
-        '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))),
-        '#weight' => -10,
+  // Append region description if we are rendering the regions demo page.
+  elseif ($item['path'] == 'admin/structure/block/demo/' . $theme) {
+    foreach (system_region_list($theme, REGIONS_VISIBLE, FALSE) as $region) {
+      $description = '<div class="block-region">' . $all_regions[$region] . '</div>';
+      $page[$region]['block_description'] = array(
+        '#markup' => $description,
+        '#weight' => 15,
       );
     }
+    $page['page_top']['backlink'] = array(
+      '#type' => 'link',
+      '#title' => t('Exit block region demonstration'),
+      '#href' => 'admin/structure/block' . (variable_get('theme_default', 'bartik') == $theme ? '' : '/list/' . $theme),
+      // Add the "overlay-restore" class to indicate this link should restore
+      // the context in which the region demonstration page was opened.
+      '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))),
+      '#weight' => -10,
+    );
   }
 }
 
diff --git a/modules/color/color.module b/modules/color/color.module
index 5b441aabd3..959800960f 100644
--- a/modules/color/color.module
+++ b/modules/color/color.module
@@ -737,7 +737,7 @@ function _color_unpack($hex, $normalize = FALSE) {
   if (strlen($hex) == 4) {
     $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
   }
-  $c = hexdec($hex);
+  $c = hexdec(ltrim($hex, '#'));
   for ($i = 16; $i >= 0; $i -= 8) {
     $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1);
   }
diff --git a/modules/comment/comment.install b/modules/comment/comment.install
index e4da58f383..9f88c0a004 100644
--- a/modules/comment/comment.install
+++ b/modules/comment/comment.install
@@ -9,9 +9,6 @@
  * Implements hook_uninstall().
  */
 function comment_uninstall() {
-  // Delete comment_body field.
-  field_delete_field('comment_body');
-
   // Remove variables.
   variable_del('comment_block_count');
   $node_types = array_keys(node_type_get_types());
diff --git a/modules/field/modules/number/number.test b/modules/field/modules/number/number.test
index db225855bf..f1b2b7ec0b 100644
--- a/modules/field/modules/number/number.test
+++ b/modules/field/modules/number/number.test
@@ -174,7 +174,7 @@ class NumberFieldTestCase extends DrupalWebTestCase {
       ),
       'display' => array(
         'default' => array(
-          'type' => 'number_float',
+          'type' => 'number_decimal',
         ),
       ),
     );
diff --git a/modules/field/tests/field_test.storage.inc b/modules/field/tests/field_test.storage.inc
index a26af17655..9d6ce54914 100644
--- a/modules/field/tests/field_test.storage.inc
+++ b/modules/field/tests/field_test.storage.inc
@@ -448,26 +448,3 @@ function field_test_field_attach_rename_bundle($bundle_old, $bundle_new) {
 
   _field_test_storage_data($data);
 }
-
-/**
- * Implements hook_field_attach_delete_bundle().
- */
-function field_test_field_attach_delete_bundle($entity_type, $bundle, $instances) {
-  $data = _field_test_storage_data();
-
-  foreach ($instances as $field_name => $instance) {
-    $field = field_info_field($field_name);
-    if ($field['storage']['type'] == 'field_test_storage') {
-      $field_data = &$data[$field['id']];
-      foreach (array('current', 'revisions') as $sub_table) {
-        foreach ($field_data[$sub_table] as &$row) {
-          if ($row->bundle == $bundle_old) {
-            $row->deleted = TRUE;
-          }
-        }
-      }
-    }
-  }
-
-  _field_test_storage_data($data);
-}
diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc
index 7d09d6f8eb..7917d10a17 100644
--- a/modules/field_ui/field_ui.admin.inc
+++ b/modules/field_ui/field_ui.admin.inc
@@ -1016,95 +1016,99 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
     else {
       $formatter_type = $display['type'];
     }
-    if (isset($form_state['formatter_settings'][$name])) {
-      $settings = $form_state['formatter_settings'][$name];
-    }
-    else {
-      $settings = $display['settings'];
-    }
-    $settings += field_info_formatter_settings($formatter_type);
-
-    $instance['display'][$view_mode]['type'] = $formatter_type;
-    $formatter = field_info_formatter_types($formatter_type);
-    $instance['display'][$view_mode]['module'] = $formatter['module'];
-    $instance['display'][$view_mode]['settings'] = $settings;
-
-    // Base button element for the various formatter settings actions.
-    $base_button = array(
-      '#submit' => array('field_ui_display_overview_multistep_submit'),
-      '#ajax' => array(
-        'callback' => 'field_ui_display_overview_multistep_js',
-        'wrapper' => 'field-display-overview-wrapper',
-        'effect' => 'fade',
-      ),
-      '#field_name' => $name,
-    );
 
-    if ($form_state['formatter_settings_edit'] == $name) {
-      // We are currently editing this field's formatter settings. Display the
-      // settings form and submit buttons.
-      $table[$name]['format']['settings_edit_form'] = array();
-
-      $settings_form = array();
-      $function = $formatter['module'] . '_field_formatter_settings_form';
-      if (function_exists($function)) {
-        $settings_form = $function($field, $instance, $view_mode, $form, $form_state);
+    // Hidden is not a real field formatter, but rather an UI element.
+    if ($formatter_type !== 'hidden') {
+      if (isset($form_state['formatter_settings'][$name])) {
+        $settings = $form_state['formatter_settings'][$name];
+      }
+      else {
+        $settings = $display['settings'];
       }
+      $settings += field_info_formatter_settings($formatter_type);
+
+      $instance['display'][$view_mode]['type'] = $formatter_type;
+      $formatter = field_info_formatter_types($formatter_type);
+      $instance['display'][$view_mode]['module'] = $formatter['module'];
+      $instance['display'][$view_mode]['settings'] = $settings;
+
+      // Base button element for the various formatter settings actions.
+      $base_button = array(
+        '#submit' => array('field_ui_display_overview_multistep_submit'),
+        '#ajax' => array(
+          'callback' => 'field_ui_display_overview_multistep_js',
+          'wrapper' => 'field-display-overview-wrapper',
+          'effect' => 'fade',
+        ),
+        '#field_name' => $name,
+      );
+
+      if ($form_state['formatter_settings_edit'] == $name) {
+        // We are currently editing this field's formatter settings. Display the
+        // settings form and submit buttons.
+        $table[$name]['format']['settings_edit_form'] = array();
 
-      if ($settings_form) {
-        $table[$name]['format']['#cell_attributes'] = array('colspan' => 3);
-        $table[$name]['format']['settings_edit_form'] = array(
-          '#type' => 'container',
-          '#attributes' => array('class' => array('field-formatter-settings-edit-form')),
-          '#parents' => array('fields', $name, 'settings_edit_form'),
-          'label' => array(
-            '#markup' => t('Format settings:') . ' <span class="formatter-name">' . $formatter['label'] . '</span>',
-          ),
-          'settings' => $settings_form,
-          'actions' => array(
-            '#type' => 'actions',
-            'save_settings' => $base_button + array(
-              '#type' => 'submit',
-              '#name' => $name . '_formatter_settings_update',
-              '#value' => t('Update'),
-              '#op' => 'update',
+        $settings_form = array();
+        $function = $formatter['module'] . '_field_formatter_settings_form';
+        if (function_exists($function)) {
+          $settings_form = $function($field, $instance, $view_mode, $form, $form_state);
+        }
+
+        if ($settings_form) {
+          $table[$name]['format']['#cell_attributes'] = array('colspan' => 3);
+          $table[$name]['format']['settings_edit_form'] = array(
+            '#type' => 'container',
+            '#attributes' => array('class' => array('field-formatter-settings-edit-form')),
+            '#parents' => array('fields', $name, 'settings_edit_form'),
+            'label' => array(
+              '#markup' => t('Format settings:') . ' <span class="formatter-name">' . $formatter['label'] . '</span>',
             ),
-            'cancel_settings' => $base_button + array(
-              '#type' => 'submit',
-              '#name' => $name . '_formatter_settings_cancel',
-              '#value' => t('Cancel'),
-              '#op' => 'cancel',
-              // Do not check errors for the 'Cancel' button, but make sure we
-              // get the value of the 'formatter type' select.
-              '#limit_validation_errors' => array(array('fields', $name, 'type')),
+            'settings' => $settings_form,
+            'actions' => array(
+              '#type' => 'actions',
+              'save_settings' => $base_button + array(
+            '#type' => 'submit',
+            '#name' => $name . '_formatter_settings_update',
+            '#value' => t('Update'),
+            '#op' => 'update',
+              ),
+              'cancel_settings' => $base_button + array(
+            '#type' => 'submit',
+            '#name' => $name . '_formatter_settings_cancel',
+            '#value' => t('Cancel'),
+            '#op' => 'cancel',
+            // Do not check errors for the 'Cancel' button, but make sure we
+            // get the value of the 'formatter type' select.
+            '#limit_validation_errors' => array(array('fields', $name, 'type')),
+              ),
             ),
-          ),
-        );
-        $table[$name]['#attributes']['class'][] = 'field-formatter-settings-editing';
+          );
+          $table[$name]['#attributes']['class'][] = 'field-formatter-settings-editing';
+        }
       }
-    }
-    else {
-      // Display a summary of the current formatter settings.
-      $summary = module_invoke($formatter['module'], 'field_formatter_settings_summary', $field, $instance, $view_mode);
-      $table[$name]['settings_summary'] = array();
-      $table[$name]['settings_edit'] = array();
-      if ($summary) {
-        $table[$name]['settings_summary'] = array(
-          '#markup' => '<div class="field-formatter-summary">' . $summary . '</div>',
-          '#cell_attributes' => array('class' => array('field-formatter-summary-cell')),
-        );
-        $table[$name]['settings_edit'] = $base_button + array(
-          '#type' => 'image_button',
-          '#name' => $name . '_formatter_settings_edit',
-          '#src' => 'misc/configure.png',
-          '#attributes' => array('class' => array('field-formatter-settings-edit'), 'alt' => t('Edit')),
-          '#op' => 'edit',
-          // Do not check errors for the 'Edit' button, but make sure we get
-          // the value of the 'formatter type' select.
-          '#limit_validation_errors' => array(array('fields', $name, 'type')),
-          '#prefix' => '<div class="field-formatter-settings-edit-wrapper">',
-          '#suffix' => '</div>',
-        );
+      else {
+        // Display a summary of the current formatter settings.
+        $summary = module_invoke($formatter['module'], 'field_formatter_settings_summary', $field, $instance, $view_mode);
+        $table[$name]['settings_summary'] = array();
+        $table[$name]['settings_edit'] = array();
+        if ($summary) {
+          $table[$name]['settings_summary'] = array(
+            '#markup' => '<div class="field-formatter-summary">' . $summary . '</div>',
+            '#cell_attributes' => array('class' => array('field-formatter-summary-cell')),
+          );
+          $table[$name]['settings_edit'] = $base_button + array(
+            '#type' => 'image_button',
+            '#name' => $name . '_formatter_settings_edit',
+            '#src' => 'misc/configure.png',
+            '#attributes' => array('class' => array('field-formatter-settings-edit'), 'alt' => t('Edit')),
+            '#op' => 'edit',
+            // Do not check errors for the 'Edit' button, but make sure we get
+            // the value of the 'formatter type' select.
+            '#limit_validation_errors' => array(array('fields', $name, 'type')),
+            '#prefix' => '<div class="field-formatter-settings-edit-wrapper">',
+            '#suffix' => '</div>',
+          );
+        }
       }
     }
   }
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index e9fd01d388..5014a8a627 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -1557,7 +1557,7 @@ function _filter_url($text, $filter) {
       }
     }
 
-    $text = implode($chunks);
+    $text = implode('', $chunks);
     // Revert back to the original comment contents
     _filter_url_escape_comments('', FALSE);
     $text = preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 1224418a9f..0f6ae349d5 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -922,7 +922,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
   );
 
   $order = _forum_get_topic_order($sortby);
-  for ($i = 0; $i < count($forum_topic_list_header); $i++) {
+  for ($i = 1; $i < count($forum_topic_list_header); $i++) {
     if ($forum_topic_list_header[$i]['field'] == $order['field']) {
       $forum_topic_list_header[$i]['sort'] = $order['sort'];
     }
diff --git a/modules/search/search.extender.inc b/modules/search/search.extender.inc
index 407425696c..a9abf0d86b 100644
--- a/modules/search/search.extender.inc
+++ b/modules/search/search.extender.inc
@@ -219,7 +219,7 @@ class SearchQuery extends SelectQueryExtender {
       }
       $phrase = FALSE;
       // Strip off phrase quotes.
-      if ($match[2]{0} == '"') {
+      if ($match[2][0] == '"') {
         $match[2] = substr($match[2], 1, -1);
         $phrase = TRUE;
         $this->simple = FALSE;
diff --git a/modules/search/search.module b/modules/search/search.module
index 7542f98918..f253c9bd70 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -1076,9 +1076,9 @@ function template_preprocess_search_block_form(&$variables) {
     }
   }
   // Hidden form elements have no value to themers. No need for separation.
-  $variables['search']['hidden'] = implode($hidden);
+  $variables['search']['hidden'] = implode('', $hidden);
   // Collect all form elements to make it easier to print the whole form.
-  $variables['search_form'] = implode($variables['search']);
+  $variables['search_form'] = implode('', $variables['search']);
 }
 
 /**
@@ -1171,8 +1171,7 @@ function search_excerpt($keys, $text) {
         $p = $match[0][1];
       }
       else {
-        $info = search_simplify_excerpt_match($key, $text, $included[$key], $boundary);
-        if ($info['where']) {
+        if ($info = search_simplify_excerpt_match($key, $text, $included[$key], $boundary)) {
           $p = $info['where'];
           if ($info['keyword']) {
             $foundkeys[] = $info['keyword'];
diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install
index 60a9b5d2af..ecbd0f2e1a 100644
--- a/modules/taxonomy/taxonomy.install
+++ b/modules/taxonomy/taxonomy.install
@@ -448,7 +448,7 @@ function taxonomy_update_7004() {
       }
       else {
         $instance['widget'] = array(
-          'type' => 'select',
+          'type' => 'options_select',
           'module' => 'options',
           'settings' => array(),
         );
