diff --git a/.htaccess b/.htaccess
index 9494b53..aa3f7b8 100644
--- a/.htaccess
+++ b/.htaccess
@@ -129,7 +129,7 @@ DirectoryIndex index.php index.html index.htm
 
     <FilesMatch "(\.js\.gz|\.css\.gz)$">
       # Serve correct encoding type.
-      Header append Content-Encoding gzip
+      Header set Content-Encoding gzip
       # Force proxies to cache gzipped & non-gzipped css/js files separately.
       Header append Vary Accept-Encoding
     </FilesMatch>
diff --git a/MAINTAINERS.txt b/MAINTAINERS.txt
index 09d7cb7..30fa827 100644
--- a/MAINTAINERS.txt
+++ b/MAINTAINERS.txt
@@ -33,6 +33,7 @@ Batch system
 
 Cache system
 - Damien Tournoud 'DamZ' <http://drupal.org/user/22211>
+- Nathaniel Catchpole 'catch' <http://drupal.org/user/35733>
 
 Cron system
 - Károly Négyesi 'chx' <http://drupal.org/user/9446>
diff --git a/UPGRADE.txt b/UPGRADE.txt
index d4909d8..c6fee98 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -1,4 +1,3 @@
-
 INTRODUCTION
 ------------
 This document describes how to:
@@ -25,6 +24,11 @@ First steps and definitions:
     applying it to your live site. Even minor updates can cause your site's
     behavior to change.
 
+  * Each new release of Drupal has release notes, which explain the changes made
+    since the previous version and any special instructions needed to update or
+    upgrade to the new version. You can find a link to the release notes for the
+    version you are upgrading or updating to on the Drupal project page
+    (http://drupal.org/project/drupal).
 
 UPGRADE PROBLEMS
 ----------------
@@ -40,7 +44,6 @@ If you encounter errors during this process,
 
 More in-depth information on upgrading can be found at http://drupal.org/upgrade
 
-
 MINOR VERSION UPDATES
 ---------------------
 To update from one minor 7.x version of Drupal to any later 7.x version, after
@@ -58,11 +61,18 @@ following the instructions in the INTRODUCTION section at the top of this file:
    If you made modifications to files like .htaccess or robots.txt, you will
    need to re-apply them from your backup, after the new files are in place.
 
-   Sometimes an update includes changes to settings.php (this will be noted in
-   the release announcement). If that's the case, replace your old settings.php
-   with the new one, and copy the site-specific entries (especially the lines
-   giving the database name, user, and password) from the old settings.php to
-   the new settings.php.
+   Sometimes an update includes changes to default.settings.php (this will be
+   noted in the release notes). If that's the case, follow these steps:
+
+   - Make a backup copy of your settings.php file, with a different file name.
+
+   - Make a copy of the new default.settings.php file, and name the copy
+     settings.php (overwriting your previous settings.php file).
+
+   - Copy the custom and site-specific entries from the backup you made into the
+     new settings.php file. You will definitely need the lines giving the
+     database information, and you will also want to copy in any other
+     customizations you have added.
 
 4. Download the latest Drupal 7.x release from http://drupal.org to a
    directory outside of your web root. Extract the archive and copy the files
@@ -110,7 +120,6 @@ following the instructions in the INTRODUCTION section at the top of this file:
    Disable the "Put site into maintenance mode" checkbox and save the
    configuration.
 
-
 MAJOR VERSION UPGRADE
 ---------------------
 To upgrade from a previous major version of Drupal to Drupal 7.x, after
@@ -221,4 +230,3 @@ following the instructions in the INTRODUCTION section at the top of this file:
 
 To get started with Drupal 7 administration, visit
 http://drupal.org/getting-started/7/admin
-
diff --git a/authorize.php b/authorize.php
index cd3df50..9961b54 100644
--- a/authorize.php
+++ b/authorize.php
@@ -35,7 +35,7 @@ define('DRUPAL_ROOT', getcwd());
 define('MAINTENANCE_MODE', 'update');
 
 /**
- * Render a 403 access denied page for authorize.php
+ * Renders a 403 access denied page for authorize.php.
  */
 function authorize_access_denied_page() {
   drupal_add_http_header('Status', '403 Forbidden');
@@ -45,7 +45,7 @@ function authorize_access_denied_page() {
 }
 
 /**
- * Determine if the current user is allowed to run authorize.php.
+ * Determines if the current user is allowed to run authorize.php.
  *
  * The killswitch in settings.php overrides all else, otherwise, the user must
  * have access to the 'administer software updates' permission.
@@ -145,7 +145,7 @@ if (authorize_access_allowed()) {
         l(t('Front page'), '<front>'),
       ));
     }
-	
+
     $output .= theme('item_list', array('items' => $links, 'title' => t('Next steps')));
   }
   // If a batch is running, let it run.
@@ -172,4 +172,3 @@ else {
 if (!empty($output)) {
   print theme('update_page', array('content' => $output, 'show_messages' => $show_messages));
 }
-
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 8e907f4..1fe8c14 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -489,22 +489,22 @@ function timer_stop($name) {
  * With a site located at http://www.example.com:8080/mysite/test/, the file,
  * settings.php, is searched for in the following directories:
  *
- *  1. $confdir/8080.www.example.com.mysite.test
- *  2. $confdir/www.example.com.mysite.test
- *  3. $confdir/example.com.mysite.test
- *  4. $confdir/com.mysite.test
+ * - $confdir/8080.www.example.com.mysite.test
+ * - $confdir/www.example.com.mysite.test
+ * - $confdir/example.com.mysite.test
+ * - $confdir/com.mysite.test
  *
- *  5. $confdir/8080.www.example.com.mysite
- *  6. $confdir/www.example.com.mysite
- *  7. $confdir/example.com.mysite
- *  8. $confdir/com.mysite
+ * - $confdir/8080.www.example.com.mysite
+ * - $confdir/www.example.com.mysite
+ * - $confdir/example.com.mysite
+ * - $confdir/com.mysite
  *
- *  9. $confdir/8080.www.example.com
- * 10. $confdir/www.example.com
- * 11. $confdir/example.com
- * 12. $confdir/com
+ * - $confdir/8080.www.example.com
+ * - $confdir/www.example.com
+ * - $confdir/example.com
+ * - $confdir/com
  *
- * 13. $confdir/default
+ * - $confdir/default
  *
  * If a file named sites.php is present in the $confdir, it will be loaded
  * prior to scanning for directories. It should define an associative array
@@ -1556,11 +1556,12 @@ function drupal_validate_utf8($text) {
 }
 
 /**
- * Since $_SERVER['REQUEST_URI'] is only available on Apache, we
- * generate an equivalent using other environment variables.
+ * Returns the equivalent of Apache's $_SERVER['REQUEST_URI'] variable.
+ *
+ * Because $_SERVER['REQUEST_URI'] is only available on Apache, we generate an
+ * equivalent using other environment variables.
  */
 function request_uri() {
-
   if (isset($_SERVER['REQUEST_URI'])) {
     $uri = $_SERVER['REQUEST_URI'];
   }
diff --git a/includes/common.inc b/includes/common.inc
index c6638dc..ba0b6ff 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -860,7 +860,7 @@ function drupal_http_request($url, array $options = array()) {
 
   // If the server URL has a user then attempt to use basic authentication.
   if (isset($uri['user'])) {
-    $options['headers']['Authorization'] = 'Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : ''));
+    $options['headers']['Authorization'] = 'Basic ' . base64_encode($uri['user'] . (isset($uri['pass']) ? ':' . $uri['pass'] : ''));
   }
 
   // If the database prefix is being used by SimpleTest to run the tests in a copied
diff --git a/includes/database/prefetch.inc b/includes/database/prefetch.inc
index f378d35..4f2b19d 100644
--- a/includes/database/prefetch.inc
+++ b/includes/database/prefetch.inc
@@ -370,7 +370,7 @@ class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface
     }
   }
 
-  public function fetchField($index = 0) {
+  public function fetchColumn($index = 0) {
     if (isset($this->currentRow) && isset($this->columnNames[$index])) {
       // We grab the value directly from $this->data, and format it.
       $return = $this->currentRow[$this->columnNames[$index]];
@@ -382,6 +382,10 @@ class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface
     }
   }
 
+  public function fetchField($index = 0) {
+    return $this->fetchColumn($index);
+  }
+
   public function fetchObject($class_name = NULL, $constructor_args = array()) {
     if (isset($this->currentRow)) {
       if (!isset($class_name)) {
diff --git a/includes/database/sqlite/schema.inc b/includes/database/sqlite/schema.inc
index 3c8cd3f..c5882f1 100644
--- a/includes/database/sqlite/schema.inc
+++ b/includes/database/sqlite/schema.inc
@@ -672,9 +672,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
     // Don't add the prefix, $table_expression already includes the prefix.
     $info = $this->getPrefixInfo($table_expression, FALSE);
 
-    // Can't use query placeholders because the query would have to be
-    // :prefixsqlite_master, which does not work.
-    $result = db_query("SELECT name FROM " . $info['schema'] . ".sqlite_master WHERE name LIKE :table_name", array(
+    // Can't use query placeholders for the schema because the query would have
+    // to be :prefixsqlite_master, which does not work.
+    $result = db_query("SELECT name FROM " . $info['schema'] . ".sqlite_master WHERE type = :type AND name LIKE :table_name", array(
+      ':type' => 'table',
       ':table_name' => $info['table'],
     ));
     return $result->fetchAllKeyed(0, 0);
diff --git a/includes/entity.inc b/includes/entity.inc
index 67225bc..45d697c 100644
--- a/includes/entity.inc
+++ b/includes/entity.inc
@@ -606,18 +606,25 @@ class EntityFieldQuery {
    *   dependent on $operator.
    * @param $operator
    *   Possible values:
-   *   - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
+   *   - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
    *     operators expect $value to be a literal of the same type as the
    *     column.
    *   - 'IN', 'NOT IN': These operators expect $value to be an array of
    *     literals of the same type as the column.
    *   - 'BETWEEN': This operator expects $value to be an array of two literals
    *     of the same type as the column.
+   *   The operator can be omitted, and will default to 'IN' if the value is an
+   *   array, or to '=' otherwise.
    *
    * @return EntityFieldQuery
    *   The called object.
    */
   public function entityCondition($name, $value, $operator = NULL) {
+    // The '!=' operator is deprecated in favour of the '<>' operator since the
+    // latter is ANSI SQL compatible.
+    if ($operator == '!=') {
+      $operator = '<>';
+    }
     $this->entityConditions[$name] = array(
       'value' => $value,
       'operator' => $operator,
@@ -722,13 +729,15 @@ class EntityFieldQuery {
    *   element in the array is dependent on $operator.
    * @param $operator
    *   Possible values:
-   *   - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
+   *   - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
    *     operators expect $value to be a literal of the same type as the
    *     column.
    *   - 'IN', 'NOT IN': These operators expect $value to be an array of
    *     literals of the same type as the column.
    *   - 'BETWEEN': This operator expects $value to be an array of two literals
    *     of the same type as the column.
+   *   The operator can be omitted, and will default to 'IN' if the value is an
+   *   array, or to '=' otherwise.
    * @param $delta_group
    *   An arbitrary identifier: conditions in the same group must have the same
    *   $delta_group. For example, let's presume a multivalue field which has
@@ -747,6 +756,11 @@ class EntityFieldQuery {
    *   The called object.
    */
   protected function addFieldCondition(&$conditions, $field, $column = NULL, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL) {
+    // The '!=' operator is deprecated in favour of the '<>' operator since the
+    // latter is ANSI SQL compatible.
+    if ($operator == '!=') {
+      $operator = '<>';
+    }
     if (is_scalar($field)) {
       $field_definition = field_info_field($field);
       if (empty($field_definition)) {
@@ -787,7 +801,7 @@ class EntityFieldQuery {
    *   array is dependent on $operator.
    * @param $operator
    *   Possible values:
-   *   - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
+   *   - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
    *     operators expect $value to be a literal of the same type as the
    *     column.
    *   - 'IN', 'NOT IN': These operators expect $value to be an array of
@@ -801,6 +815,11 @@ class EntityFieldQuery {
    *   The called object.
    */
   public function propertyCondition($column, $value, $operator = NULL) {
+    // The '!=' operator is deprecated in favour of the '<>' operator since the
+    // latter is ANSI SQL compatible.
+    if ($operator == '!=') {
+      $operator = '<>';
+    }
     $this->propertyConditions[] = array(
       'column' => $column,
       'value' => $value,
diff --git a/includes/file.inc b/includes/file.inc
index 69e2a62..40e8349 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -2192,27 +2192,32 @@ function drupal_unlink($uri, $context = NULL) {
 }
 
 /**
- * Returns the absolute path of a file or directory
+ * Returns the absolute local filesystem path of a stream URI.
  *
- * PHP's realpath() does not properly support streams, so this function
- * fills that gap. If a stream wrapped URI is provided, it will be passed
- * to the registered wrapper for handling. If the URI does not contain a
- * scheme or the wrapper implementation does not implement realpath, then
- * FALSE will be returned.
+ * This function was originally written to ease the conversion of 6.x code to
+ * use 7.x stream wrappers. However, it assumes that every URI may be resolved
+ * to an absolute local filesystem path, and this assumption fails when stream
+ * wrappers are used to support remote file storage. Remote stream wrappers
+ * may implement the realpath method by always returning FALSE. The use of
+ * drupal_realpath() is discouraged, and is slowly being removed from core
+ * functions where possible.
  *
- * @see http://php.net/manual/en/function.realpath.php
- *
- * Compatibility: normal paths and stream wrappers.
- * @see http://drupal.org/node/515192
+ * Only use this function if you know that the stream wrapper in the URI uses
+ * the local file system, and you need to pass an absolute path to a function
+ * that is incompatible with stream URIs.
  *
  * @param $uri
- *   A string containing the URI to verify.
+ *   A stream wrapper URI or a filesystem path, possibly including one or more
+ *   symbolic links.
  *
  * @return
- *   The absolute pathname, or FALSE on failure.
+ *   The absolute local filesystem path (with no symbolic links), or FALSE on
+ *   failure.
  *
- * @see realpath()
+ * @see DrupalStreamWrapperInterface::realpath()
+ * @see http://php.net/manual/function.realpath.php
  * @ingroup php_wrappers
+ * @todo: This function is deprecated, and should be removed wherever possible.
  */
 function drupal_realpath($uri) {
   // If this URI is a stream, pass it off to the appropriate stream wrapper.
diff --git a/includes/form.inc b/includes/form.inc
index 1b5ac37..b564797 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -1082,8 +1082,12 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
   // matches the current user's session.
   if (isset($form['#token'])) {
     if (!drupal_valid_token($form_state['values']['form_token'], $form['#token'])) {
+      $path = current_path();
+      $query = drupal_get_query_parameters();
+      $url = url($path, array('query' => $query));
+
       // Setting this error will cause the form to fail validation.
-      form_set_error('form_token', t('This form is outdated. Reload the page and try again. Contact the site administrator if the problem persists.'));
+      form_set_error('form_token', t('The form has become outdated. Copy any unsaved work in the form below and then <a href="@link">reload this page</a>.', array('@link' => $url)));
     }
   }
 
diff --git a/includes/menu.inc b/includes/menu.inc
index a32fa13..9ebb816 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -1134,6 +1134,45 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
 }
 
 /**
+ * Set the path for determining the active trail of the specified menu tree.
+ *
+ * This path will also affect the breadcrumbs under some circumstances.
+ * Breadcrumbs are built using the preferred link returned by
+ * menu_link_get_preferred(). If the preferred link is inside one of the menus
+ * specified in calls to menu_tree_set_path(), the preferred link will be
+ * overridden by the corresponding path returned by menu_tree_get_path().
+ *
+ * Setting this path does not affect the main content; for that use
+ * menu_set_active_item() instead.
+ *
+ * @param $menu_name
+ *   The name of the affected menu tree.
+ * @param $path
+ *   The path to use when finding the active trail.
+ */
+function menu_tree_set_path($menu_name, $path = NULL) {
+  $paths = &drupal_static(__FUNCTION__);
+  if (isset($path)) {
+    $paths[$menu_name] = $path;
+  }
+  return isset($paths[$menu_name]) ? $paths[$menu_name] : NULL;
+}
+
+/**
+ * Get the path for determining the active trail of the specified menu tree.
+ *
+ * @param $menu_name
+ *   The menu name of the requested tree.
+ *
+ * @return
+ *   A string containing the path. If no path has been specified with
+ *   menu_tree_set_path(), NULL is returned.
+ */
+function menu_tree_get_path($menu_name) {
+  return menu_tree_set_path($menu_name);
+}
+
+/**
  * Get the data structure representing a named menu tree, based on the current page.
  *
  * The tree order is maintained by storing each parent in an individual
@@ -1158,8 +1197,10 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
 function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) {
   $tree = &drupal_static(__FUNCTION__, array());
 
+  // Check if the active trail has been overridden for this menu tree.
+  $active_path = menu_tree_get_path($menu_name);
   // Load the menu item corresponding to the current page.
-  if ($item = menu_get_item()) {
+  if ($item = menu_get_item($active_path)) {
     if (isset($max_depth)) {
       $max_depth = min($max_depth, MENU_MAX_DEPTH);
     }
@@ -1198,8 +1239,9 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
         // If the item for the current page is accessible, build the tree
         // parameters accordingly.
         if ($item['access']) {
-          // Find a menu link corresponding to the current path.
-          if ($active_link = menu_link_get_preferred()) {
+          // Find a menu link corresponding to the current path. If $active_path
+          // is NULL, let menu_link_get_preferred() determine the path.
+          if ($active_link = menu_link_get_preferred($active_path)) {
             // The active link may only be taken into account to build the
             // active trail, if it resides in the requested menu. Otherwise,
             // we'd needlessly re-run _menu_build_tree() queries for every menu
@@ -2229,38 +2271,36 @@ function menu_get_active_menu_names() {
 /**
  * Set the active path, which determines which page is loaded.
  *
- * @param $path
- *   A Drupal path - not a path alias.
- *
  * Note that this may not have the desired effect unless invoked very early
  * in the page load, such as during hook_boot, or unless you call
  * menu_execute_active_handler() to generate your page output.
+ *
+ * @param $path
+ *   A Drupal path - not a path alias.
  */
 function menu_set_active_item($path) {
   $_GET['q'] = $path;
 }
 
 /**
- * Sets or gets the active trail (path to menu tree root) of the current page.
+ * Sets the active trail (path to menu tree root) of the current page.
+ *
+ * Any trail set by this function will only be used for functionality that calls
+ * menu_get_active_trail(). Drupal core only uses trails set here for
+ * breadcrumbs and the page title and not for menu trees or page content.
+ * Additionally, breadcrumbs set by drupal_set_breadcrumb() will override any
+ * trail set here.
+ *
+ * To affect the trail used by menu trees, use menu_tree_set_path(). To affect
+ * the page content, use menu_set_active_item() instead.
  *
  * @param $new_trail
- *   Menu trail to set, or NULL to use previously-set or calculated trail. If
- *   supplying a trail, use the same format as the return value (see below).
+ *   Menu trail to set; the value is saved in a static variable and can be
+ *   retrieved by menu_get_active_trail(). The format of this array should be
+ *   the same as the return value of menu_get_active_trail().
  *
  * @return
- *   Path to menu root of the current page, as an array of menu link items,
- *   starting with the site's home page. Each link item is an associative array
- *   with the following components:
- *   - title: Title of the item.
- *   - href: Drupal path of the item.
- *   - localized_options: Options for passing into the l() function.
- *   - type: A menu type constant, such as MENU_DEFAULT_LOCAL_TASK, or 0 to
- *     indicate it's not really in the menu (used for the home page item).
- *   If $new_trail is supplied, the value is saved in a static variable and
- *   returned. If $new_trail is not supplied, and there is a saved value from
- *   a previous call, the saved value is returned. If $new_trail is not supplied
- *   and there is no saved value, the path to the current page is calculated,
- *   saved as the static value, and returned.
+ *   The active trail. See menu_get_active_trail() for details.
  */
 function menu_set_active_trail($new_trail = NULL) {
   $trail = &drupal_static(__FUNCTION__);
@@ -2419,7 +2459,20 @@ function menu_link_get_preferred($path = NULL) {
 /**
  * Gets the active trail (path to root menu root) of the current page.
  *
- * See menu_set_active_trail() for details of return value.
+ * If a trail is supplied to menu_set_active_trail(), that value is returned. If
+ * a trail is not supplied to menu_set_active_trail(), the path to the current
+ * page is calculated and returned. The calculated trail is also saved as a
+ * static value for use by subsequent calls to menu_get_active_trail().
+ *
+ * @return
+ *   Path to menu root of the current page, as an array of menu link items,
+ *   starting with the site's home page. Each link item is an associative array
+ *   with the following components:
+ *   - title: Title of the item.
+ *   - href: Drupal path of the item.
+ *   - localized_options: Options for passing into the l() function.
+ *   - type: A menu type constant, such as MENU_DEFAULT_LOCAL_TASK, or 0 to
+ *     indicate it's not really in the menu (used for the home page item).
  */
 function menu_get_active_trail() {
   return menu_set_active_trail();
diff --git a/includes/theme.inc b/includes/theme.inc
index 6c2b640..49865cf 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1902,11 +1902,12 @@ function theme_feed_icon($variables) {
  */
 function theme_html_tag($variables) {
   $element = $variables['element'];
+  $attributes = isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '';
   if (!isset($element['#value'])) {
-    return '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . " />\n";
+    return '<' . $element['#tag'] . $attributes . " />\n";
   }
   else {
-    $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
+    $output = '<' . $element['#tag'] . $attributes . '>';
     if (isset($element['#value_prefix'])) {
       $output .= $element['#value_prefix'];
     }
diff --git a/includes/update.inc b/includes/update.inc
index 35be17a..3a13108 100644
--- a/includes/update.inc
+++ b/includes/update.inc
@@ -1426,7 +1426,7 @@ function update_retrieve_dependencies() {
   $return = array();
   // Get a list of installed modules, arranged so that we invoke their hooks in
   // the same order that module_invoke_all() does.
-  $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version != :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
+  $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version <> :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
   foreach ($modules as $module) {
     $function = $module . '_update_dependencies';
     if (function_exists($function)) {
diff --git a/misc/favicon.ico b/misc/favicon.ico
index bfa1c99..3417ec2 100644
Binary files a/misc/favicon.ico and b/misc/favicon.ico differ
diff --git a/modules/aggregator/aggregator-item.tpl.php b/modules/aggregator/aggregator-item.tpl.php
index c5dd70c..e9ad1e0 100644
--- a/modules/aggregator/aggregator-item.tpl.php
+++ b/modules/aggregator/aggregator-item.tpl.php
@@ -24,19 +24,19 @@
   </h3>
 
   <div class="feed-item-meta">
-  <?php if ($source_url) : ?>
+  <?php if ($source_url): ?>
     <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> -
   <?php endif; ?>
     <span class="feed-item-date"><?php print $source_date; ?></span>
   </div>
 
-<?php if ($content) : ?>
+<?php if ($content): ?>
   <div class="feed-item-body">
     <?php print $content; ?>
   </div>
 <?php endif; ?>
 
-<?php if ($categories) : ?>
+<?php if ($categories): ?>
   <div class="feed-item-categories">
     <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
   </div>
diff --git a/modules/aggregator/aggregator-summary-item.tpl.php b/modules/aggregator/aggregator-summary-item.tpl.php
index 1c82999..fcd57c7 100644
--- a/modules/aggregator/aggregator-summary-item.tpl.php
+++ b/modules/aggregator/aggregator-summary-item.tpl.php
@@ -18,6 +18,6 @@
 <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
 <span class="age"><?php print $feed_age; ?></span>
 
-<?php if ($source_url) : ?>,
-<span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span>
+<?php if ($source_url): ?>,
+  <span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span>
 <?php endif; ?>
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc
index c91cc80..067c8f4 100644
--- a/modules/block/block.admin.inc
+++ b/modules/block/block.admin.inc
@@ -276,7 +276,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
     '#maxlength' => 64,
     '#description' => $block->module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>!placeholder</em> to display no title, or leave blank to use the default block title.', array('!placeholder' => '&lt;none&gt;')),
     '#default_value' => isset($block->title) ? $block->title : '',
-    '#weight' => -18,
+    '#weight' => -19,
   );
 
   // Module-specific block configuration.
diff --git a/modules/block/block.module b/modules/block/block.module
index 4f498d3..754febd 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -500,7 +500,7 @@ function block_custom_block_form($edit = array()) {
     '#maxlength' => 64,
     '#description' => t('A brief description of your block. Used on the <a href="@overview">Blocks administration page</a>.', array('@overview' => url('admin/structure/block'))),
     '#required' => TRUE,
-    '#weight' => -19,
+    '#weight' => -18,
   );
   $form['body_field']['#weight'] = -17;
   $form['body_field']['body'] = array(
@@ -668,7 +668,7 @@ function block_list($region) {
  *   Name of the module that implements the block to load.
  * @param $delta
  *   Unique ID of the block within the context of $module. Pass NULL to return
- *   an empty $block object for $module.
+ *   an empty block object for $module.
  *
  * @return
  *   A block object.
diff --git a/modules/book/book-all-books-block.tpl.php b/modules/book/book-all-books-block.tpl.php
index d22ff2c..626a5f2 100644
--- a/modules/book/book-all-books-block.tpl.php
+++ b/modules/book/book-all-books-block.tpl.php
@@ -11,8 +11,8 @@
  *   render() on each to print it as an unordered list.
  */
 ?>
-<?php foreach ($book_menus as $book_id => $menu) : ?>
-<div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
-  <?php print render($menu); ?>
-</div>
+<?php foreach ($book_menus as $book_id => $menu): ?>
+  <div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
+    <?php print render($menu); ?>
+  </div>
 <?php endforeach; ?>
diff --git a/modules/book/book-export-html.tpl.php b/modules/book/book-export-html.tpl.php
index 180f3ae..4b25a76 100644
--- a/modules/book/book-export-html.tpl.php
+++ b/modules/book/book-export-html.tpl.php
@@ -40,7 +40,7 @@
      */
     $div_close = '';
     ?>
-    <?php for ($i = 1; $i < $depth; $i++) : ?>
+    <?php for ($i = 1; $i < $depth; $i++): ?>
       <div class="section-<?php print $i; ?>">
       <?php $div_close .= '</div>'; ?>
     <?php endfor; ?>
diff --git a/modules/book/book-navigation.tpl.php b/modules/book/book-navigation.tpl.php
index e5883dc..5d8e9aa 100644
--- a/modules/book/book-navigation.tpl.php
+++ b/modules/book/book-navigation.tpl.php
@@ -35,13 +35,13 @@
 
     <?php if ($has_links): ?>
     <div class="page-links clearfix">
-      <?php if ($prev_url) : ?>
+      <?php if ($prev_url): ?>
         <a href="<?php print $prev_url; ?>" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('‹ ') . $prev_title; ?></a>
       <?php endif; ?>
-      <?php if ($parent_url) : ?>
+      <?php if ($parent_url): ?>
         <a href="<?php print $parent_url; ?>" class="page-up" title="<?php print t('Go to parent page'); ?>"><?php print t('up'); ?></a>
       <?php endif; ?>
-      <?php if ($next_url) : ?>
+      <?php if ($next_url): ?>
         <a href="<?php print $next_url; ?>" class="page-next" title="<?php print t('Go to next page'); ?>"><?php print $next_title . t(' ›'); ?></a>
       <?php endif; ?>
     </div>
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index c17c5a6..59c9ad7 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -92,7 +92,7 @@ function comment_help($path, $arg) {
  * Implements hook_entity_info().
  */
 function comment_entity_info() {
-  $return =  array(
+  $return = array(
     'comment' => array(
       'label' => t('Comment'),
       'base table' => 'comment',
@@ -542,7 +542,7 @@ function comment_new_page_count($num_comments, $new_replies, $node) {
   elseif ($flat) {
     // Flat comments.
     $count = $num_comments - $new_replies;
-    $pageno =  $count / $comments_per_page;
+    $pageno = $count / $comments_per_page;
   }
   else {
     // Threaded comments: we build a query with a subquery to find the first
@@ -575,7 +575,7 @@ function comment_new_page_count($num_comments, $new_replies, $node) {
       ':thread' => $first_thread,
     ))->fetchField();
 
-    $pageno =  $count / $comments_per_page;
+    $pageno = $count / $comments_per_page;
   }
 
   if ($pageno >= 1) {
@@ -1439,7 +1439,7 @@ function comment_save($comment) {
 
   $transaction = db_transaction();
   try {
-    $defaults =  array(
+    $defaults = array(
       'mail' => '',
       'homepage' => '',
       'name' => '',
@@ -1711,7 +1711,7 @@ function comment_num_new($nid, $timestamp = 0) {
     $timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT);
 
     // Use the timestamp to retrieve the number of new comments.
-    return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid  AND created > :timestamp AND status = :status', array(
+    return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array(
       ':nid' => $nid,
       ':timestamp' => $timestamp,
       ':status' => COMMENT_PUBLISHED,
@@ -2279,10 +2279,10 @@ function template_preprocess_comment(&$variables) {
 
   // Set status to a string representation of comment->status.
   if (isset($comment->in_preview)) {
-    $variables['status']  = 'comment-preview';
+    $variables['status'] = 'comment-preview';
   }
   else {
-    $variables['status']  = ($comment->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
+    $variables['status'] = ($comment->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
   }
   // Gather comment classes.
   if ($comment->uid === 0) {
diff --git a/modules/dblog/dblog.css b/modules/dblog/dblog.css
index ff310e3..88f4ba0 100644
--- a/modules/dblog/dblog.css
+++ b/modules/dblog/dblog.css
@@ -1,4 +1,3 @@
-
 .form-item-type,
 .form-item-severity {
   float: left; /* LTR */
@@ -52,7 +51,9 @@ table#admin-dblog td.icon {
 table#admin-dblog tr.dblog-warning td.icon {
   background-image: url(../../misc/message-16-warning.png);
 }
-table#admin-dblog tr.dblog-error td.icon {
+table#admin-dblog tr.dblog-error td.icon,
+table#admin-dblog tr.dblog-critical td.icon,
+table#admin-dblog tr.dblog-alert td.icon,
+table#admin-dblog tr.dblog-emerg td.icon {
   background-image: url(../../misc/message-16-error.png);
 }
-
diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc
index 80c1dac..4b92501 100644
--- a/modules/field/field.form.inc
+++ b/modules/field/field.form.inc
@@ -273,7 +273,7 @@ function theme_field_multiple_value_form($variables) {
   if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
     $table_id = drupal_html_id($element['#field_name'] . '_values');
     $order_class = $element['#field_name'] . '-delta-order';
-    $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required. ') . '">*</span>' : '';
+    $required = !empty($element['#required']) ? theme('form_required_marker', $variables) : '';
 
     $header = array(
       array(
diff --git a/modules/field/tests/field_test.storage.inc b/modules/field/tests/field_test.storage.inc
index 3ca322d..a26af17 100644
--- a/modules/field/tests/field_test.storage.inc
+++ b/modules/field/tests/field_test.storage.inc
@@ -282,7 +282,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor
           case '=':
             $match = $match && $row->{$column} == $value;
             break;
-          case '!=':
+          case '<>':
           case '<':
           case '<=':
           case '>':
diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php
index e4cd85c..9e76e3b 100644
--- a/modules/field/theme/field.tpl.php
+++ b/modules/field/theme/field.tpl.php
@@ -49,11 +49,11 @@ After copying this file to your theme's folder and customizing it, remove this
 HTML comment.
 -->
 <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
-  <?php if (!$label_hidden) : ?>
+  <?php if (!$label_hidden): ?>
     <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
   <?php endif; ?>
   <div class="field-items"<?php print $content_attributes; ?>>
-    <?php foreach ($items as $delta => $item) : ?>
+    <?php foreach ($items as $delta => $item): ?>
       <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
     <?php endforeach; ?>
   </div>
diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc
index 2af3cb6..35696dd 100644
--- a/modules/file/file.field.inc
+++ b/modules/file/file.field.inc
@@ -428,7 +428,7 @@ function file_field_widget_settings_form($field, $instance) {
       'bar' => t('Bar with progress meter'),
     ),
     '#default_value' => $settings['progress_indicator'],
-    '#description' => t('The throbber display does not show the status of uploads but takes up space. The progress bar is helpful for monitoring progress on large uploads.'),
+    '#description' => t('The throbber display does not show the status of uploads but takes up less space. The progress bar is helpful for monitoring progress on large uploads.'),
     '#weight' => 16,
     '#access' => file_progress_implementation(),
   );
@@ -447,37 +447,18 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco
     'description' => '',
   );
 
-  // Retrieve any values set in $form_state, as will be the case during Ajax
-  // rebuilds of this form.
-  if (isset($form_state['values'])) {
-    $path = array_merge($element['#field_parents'], array($field['field_name'], $langcode));
-    $path_exists = FALSE;
-    $values = drupal_array_get_nested_value($form_state['values'], $path, $path_exists);
-    if ($path_exists) {
-      $items = $values;
-      drupal_array_set_nested_value($form_state['values'], $path, NULL);
-    }
-  }
-
-  foreach ($items as $delta => $item) {
-    $items[$delta] = array_merge($defaults, $items[$delta]);
-    // Remove any items from being displayed that are not needed.
-    if ($items[$delta]['fid'] == 0) {
-      unset($items[$delta]);
-    }
+  // Load the items for form rebuilds from the field state as they might not be
+  // in $form_state['values'] because of validation limitations. Also, they are
+  // only passed in as $items when editing existing entities.
+  $field_state = field_form_get_state($element['#field_parents'], $field['field_name'], $langcode, $form_state);
+  if (isset($field_state['items'])) {
+    $items = $field_state['items'];
   }
 
-  // Re-index deltas after removing empty items.
-  $items = array_values($items);
-
-  // Update order according to weight.
-  $items = _field_sort_items($field, $items);
-
   // Essentially we use the managed_file type, extended with some enhancements.
   $element_info = element_info('managed_file');
   $element += array(
     '#type' => 'managed_file',
-    '#default_value' => isset($items[$delta]) ? $items[$delta] : $defaults,
     '#upload_location' => file_field_widget_uri($field, $instance),
     '#upload_validators' => file_field_widget_upload_validators($field, $instance),
     '#value_callback' => 'file_field_widget_value',
@@ -487,6 +468,8 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco
   );
 
   if ($field['cardinality'] == 1) {
+    // Set the default value.
+    $element['#default_value'] = !empty($items) ? $items[0] : $defaults;
     // If there's only one field, return it as delta 0.
     if (empty($element['#default_value']['fid'])) {
       $element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
@@ -495,15 +478,15 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco
   }
   else {
     // If there are multiple values, add an element for each existing one.
-    $delta = -1;
-    foreach ($items as $delta => $item) {
+    foreach ($items as $item) {
       $elements[$delta] = $element;
       $elements[$delta]['#default_value'] = $item;
       $elements[$delta]['#weight'] = $delta;
+      $delta++;
     }
-    // And then add one more empty row for new uploads.
-    $delta++;
-    if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality']) {
+    // And then add one more empty row for new uploads except when this is a
+    // programmed form as it is not necessary.
+    if (($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality']) && empty($form_state['programmed'])) {
       $elements[$delta] = $element;
       $elements[$delta]['#default_value'] = $defaults;
       $elements[$delta]['#weight'] = $delta;
@@ -757,6 +740,32 @@ function file_field_widget_submit($form, &$form_state) {
   // so nothing is lost in doing this.
   $parents = array_slice($form_state['triggering_element']['#parents'], 0, -2);
   drupal_array_set_nested_value($form_state['input'], $parents, NULL);
+
+  $button = $form_state['triggering_element'];
+
+  // Go one level up in the form, to the widgets container.
+  $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
+  $field_name = $element['#field_name'];
+  $langcode = $element['#language'];
+  $parents = $element['#field_parents'];
+
+  $submitted_values = drupal_array_get_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2));
+  foreach ($submitted_values as $delta => $submitted_value) {
+    if (!$submitted_value['fid']) {
+      unset($submitted_values[$delta]);
+    }
+  }
+
+  // Re-index deltas after removing empty items.
+  $submitted_values = array_values($submitted_values);
+
+  // Update form_state values.
+  drupal_array_set_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2), $submitted_values);
+
+  // Update items.
+  $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
+  $field_state['items'] = $submitted_values;
+  field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
 }
 
 /**
diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test
index ef250ef..59f6e0c 100644
--- a/modules/file/tests/file.test
+++ b/modules/file/tests/file.test
@@ -380,7 +380,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
   }
 
   /**
-   * Tests upload and remove buttons, with and without Ajax, for a multi-valued File field.
+   * Tests upload and remove buttons, with and without Ajax, for multiple multi-valued File field.
    */
   function testMultiValuedWidget() {
     // Use 'page' instead of 'article', so that the 'article' image field does
@@ -389,77 +389,106 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
     // using a custom node type.
     $type_name = 'page';
     $field_name = strtolower($this->randomName());
+    $field_name2 = strtolower($this->randomName());
     $this->createFileField($field_name, $type_name, array('cardinality' => 3));
+    $this->createFileField($field_name2, $type_name, array('cardinality' => 3));
+
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
 
+    $field2 = field_info_field($field_name2);
+    $instance2 = field_info_instance('node', $field_name2, $type_name);
+
     $test_file = $this->getTestFile('text');
 
     foreach (array('nojs', 'js') as $type) {
-      // Visit the node creation form, and upload 3 files. Since the field has
-      // cardinality of 3, ensure the "Upload" button is displayed until after
-      // the 3rd file, and after that, isn't displayed.
+      // Visit the node creation form, and upload 3 files for each field. Since
+      // the field has cardinality of 3, ensure the "Upload" button is displayed
+      // until after the 3rd file, and after that, isn't displayed. Because
+      // SimpleTest triggers the last button with a given name, so upload to the
+      // second field first.
       // @todo This is only testing a non-Ajax upload, because drupalPostAJAX()
       //   does not yet emulate jQuery's file upload.
+      //
       $this->drupalGet("node/add/$type_name");
-      for ($delta = 0; $delta < 3; $delta++) {
-        $edit = array('files[' . $field_name . '_' . LANGUAGE_NONE . '_' . $delta . ']' => drupal_realpath($test_file->uri));
-        // If the Upload button doesn't exist, drupalPost() will automatically
-        // fail with an assertion message.
-        $this->drupalPost(NULL, $edit, t('Upload'));
-      }
-      $this->assertNoFieldByXpath('//input[@type="submit"]', t('Upload'), t('After uploading 3 files, the "Upload" button is no longer displayed.'));
-
-      // Test clicking each "Remove" button. For extra robustness, test them out
-      // of sequential order. They are 0-indexed, and get renumbered after each
-      // iteration, so array(1, 1, 0) means:
-      // - First remove the 2nd file.
-      // - Then remove what is then the 2nd file (was originally the 3rd file).
-      // - Then remove the first file.
-      $num_expected_remove_buttons = 3;
-      foreach (array(1, 1, 0) as $delta) {
-        // Ensure we have the expected number of Remove buttons, and that they
-        // are numbered sequentially.
-        $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
-        $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, t('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type)));
-        foreach ($buttons as $i => $button) {
-          $this->assertIdentical((string) $button['name'], $field_name . '_' . LANGUAGE_NONE . '_' . $i . '_remove_button');
+      foreach (array($field_name2, $field_name) as $each_field_name) {
+        for ($delta = 0; $delta < 3; $delta++) {
+          $edit = array('files[' . $each_field_name . '_' . LANGUAGE_NONE . '_' . $delta . ']' => drupal_realpath($test_file->uri));
+          // If the Upload button doesn't exist, drupalPost() will automatically
+          // fail with an assertion message.
+          $this->drupalPost(NULL, $edit, t('Upload'));
         }
+      }
+      $this->assertNoFieldByXpath('//input[@type="submit"]', t('Upload'), t('After uploading 3 files for each field, the "Upload" button is no longer displayed.'));
+
+      $num_expected_remove_buttons = 6;
+
+      foreach (array($field_name, $field_name2) as $current_field_name) {
+        // How many uploaded files for the current field are remaining.
+        $remaining = 3;
+        // Test clicking each "Remove" button. For extra robustness, test them out
+        // of sequential order. They are 0-indexed, and get renumbered after each
+        // iteration, so array(1, 1, 0) means:
+        // - First remove the 2nd file.
+        // - Then remove what is then the 2nd file (was originally the 3rd file).
+        // - Then remove the first file.
+        foreach (array(1,1,0) as $delta) {
+          // Ensure we have the expected number of Remove buttons, and that they
+          // are numbered sequentially.
+          $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
+          $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, t('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type)));
+          foreach ($buttons as $i => $button) {
+            $key = $i >= $remaining ? $i - $remaining : $i;
+            $check_field_name = $field_name2;
+            if ($current_field_name == $field_name && $i < $remaining) {
+              $check_field_name = $field_name;
+            }
 
-        // "Click" the remove button (emulating either a nojs or js submission).
-        $button_name = $field_name . '_' . LANGUAGE_NONE . '_' . $delta . '_remove_button';
-        switch ($type) {
-          case 'nojs':
-            // drupalPost() takes a $submit parameter that is the value of the
-            // button whose click we want to emulate. Since we have multiple
-            // buttons with the value "Remove", and want to control which one we
-            // use, we change the value of the other ones to something else.
-            // Since non-clicked buttons aren't included in the submitted POST
-            // data, and since drupalPost() will result in $this being updated
-            // with a newly rebuilt form, this doesn't cause problems.
-            foreach ($buttons as $button) {
-              if ($button['name'] != $button_name) {
-                $button['value'] = 'DUMMY';
+            $this->assertIdentical((string) $button['name'], $check_field_name . '_' . LANGUAGE_NONE . '_' . $key. '_remove_button');
+          }
+
+          // "Click" the remove button (emulating either a nojs or js submission).
+          $button_name = $current_field_name . '_' . LANGUAGE_NONE . '_' . $delta . '_remove_button';
+          switch ($type) {
+            case 'nojs':
+              // drupalPost() takes a $submit parameter that is the value of the
+              // button whose click we want to emulate. Since we have multiple
+              // buttons with the value "Remove", and want to control which one we
+              // use, we change the value of the other ones to something else.
+              // Since non-clicked buttons aren't included in the submitted POST
+              // data, and since drupalPost() will result in $this being updated
+              // with a newly rebuilt form, this doesn't cause problems.
+              foreach ($buttons as $button) {
+                if ($button['name'] != $button_name) {
+                  $button['value'] = 'DUMMY';
+                }
               }
-            }
-            $this->drupalPost(NULL, array(), t('Remove'));
-            break;
-          case 'js':
-            // drupalPostAJAX() lets us target the button precisely, so we don't
-            // require the workaround used above for nojs.
-            $this->drupalPostAJAX(NULL, array(), array($button_name => t('Remove')));
-            break;
+              $this->drupalPost(NULL, array(), t('Remove'));
+              break;
+            case 'js':
+              // drupalPostAJAX() lets us target the button precisely, so we don't
+              // require the workaround used above for nojs.
+              $this->drupalPostAJAX(NULL, array(), array($button_name => t('Remove')));
+              break;
+          }
+          $num_expected_remove_buttons--;
+          $remaining--;
+
+          // Ensure an "Upload" button for the current field is displayed with the
+          // correct name.
+          $upload_button_name = $current_field_name . '_' . LANGUAGE_NONE . '_' . $remaining . '_upload_button';
+          $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name));
+          $this->assertTrue(is_array($buttons) && count($buttons) == 1, t('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type)));
+
+          // Ensure only at most one button per field is displayed.
+          $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]');
+          $expected = $current_field_name == $field_name ? 1 : 2;
+          $this->assertTrue(is_array($buttons) && count($buttons) == $expected, t('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type)));
         }
-        $num_expected_remove_buttons--;
-
-        // Ensure we have a single Upload button, and that it is numbered
-        // sequentially after the Remove buttons.
-        $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]');
-        $this->assertTrue(is_array($buttons) && count($buttons) == 1 && ((string) $buttons[0]['name'] === ($field_name . '_' . LANGUAGE_NONE . '_' . $num_expected_remove_buttons . '_upload_button')), t('After removing a file, an "Upload" button is displayed (JSMode=%type).'));
       }
 
       // Ensure the page now has no Remove buttons.
-      $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After removing all files, there is no "Remove" button displayed.', array('%n' => $num_expected_remove_buttons, '%type' => $type)));
+      $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type)));
 
       // Save the node and ensure it does not have any files.
       $this->drupalPost(NULL, array('title' => $this->randomName()), t('Save'));
diff --git a/modules/forum/forum.admin.inc b/modules/forum/forum.admin.inc
index 1e6b365..49c71d9 100644
--- a/modules/forum/forum.admin.inc
+++ b/modules/forum/forum.admin.inc
@@ -55,7 +55,7 @@ function forum_form_forum($form, &$form_state, $edit = array()) {
 
   $form['vid'] = array('#type' => 'hidden', '#value' => variable_get('forum_nav_vocabulary', ''));
   $form['actions'] = array('#type' => 'actions');
-  $form['actions']['submit' ] = array('#type' => 'submit', '#value' => t('Save'));
+  $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
   if ($edit['tid']) {
     $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
     $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']);
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 5bb4392..0dcea5a 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -1127,7 +1127,6 @@ function template_preprocess_forum_topic_list(&$variables) {
         $variables['topics'][$id]->title = l($topic->title, "node/$topic->nid");
         $variables['topics'][$id]->message = '';
       }
-      $topic->uid = $topic->last_comment_uid ? $topic->last_comment_uid : $topic->uid;
       $variables['topics'][$id]->created = theme('forum_submitted', array('topic' => $topic));
       $variables['topics'][$id]->last_reply = theme('forum_submitted', array('topic' => isset($topic->last_reply) ? $topic->last_reply : NULL));
 
diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc
index 7b5882c..d9b98cc 100644
--- a/modules/menu/menu.admin.inc
+++ b/modules/menu/menu.admin.inc
@@ -286,6 +286,7 @@ function menu_edit_item($form, &$form_state, $type, $item, $menu) {
     $form['link_path'] = array(
       '#type' => 'textfield',
       '#title' => t('Path'),
+      '#maxlength' => 255,
       '#default_value' => $path,
       '#description' => t('The path for this menu link. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
       '#required' => TRUE,
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index 2540797..c914867 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -322,6 +322,9 @@ function menu_delete($menu) {
  * @param $item
  *   The menu item or the node type for which to generate a list of parents.
  *   If $item['mlid'] == 0 then the complete tree is returned.
+ * @param $type
+ *   The node type for which to generate a list of parents.
+ *   If $item itself is a node type then $type is ignored.
  * @return
  *   An array of menu link titles keyed on the a string containing the menu name
  *   and mlid. The list excludes the given item and its children.
@@ -329,7 +332,7 @@ function menu_delete($menu) {
  * @todo This has to be turned into a #process form element callback. The
  *   'menu_override_parent_selector' variable is entirely superfluous.
  */
-function menu_parent_options($menus, $item) {
+function menu_parent_options($menus, $item, $type = '') {
   // The menu_links table can be practically any size and we need a way to
   // allow contrib modules to provide more scalable pattern choosers.
   // hook_form_alter is too late in itself because all the possible parents are
@@ -339,18 +342,22 @@ function menu_parent_options($menus, $item) {
   }
 
   $available_menus = array();
-  if (is_array($item)) {
-    // If $item is an array fill it with all menus given to this function.
+  if (!is_array($item)) {
+    // If $item is not an array then it is a node type.
+    // Use it as $type and prepare a dummy menu item for _menu_get_options().
+    $type = $item;
+    $item = array('mlid' => 0);
+  }
+  if (empty($type)) {
+    // If no node type is set, use all menus given to this function.
     $available_menus = $menus;
   }
   else {
-    // If $item is a node type, get all available menus for this type and
-    // prepare a dummy menu item for _menu_parent_depth_limit().
-    $type_menus = variable_get('menu_options_' . $item, array('main-menu' => 'main-menu'));
+    // If a node type is set, use all available menus for this type.
+    $type_menus = variable_get('menu_options_' . $type, array('main-menu' => 'main-menu'));
     foreach ($type_menus as $menu) {
       $available_menus[$menu] = $menu;
     }
-    $item = array('mlid' => 0);
   }
 
   return _menu_get_options($menus, $available_menus, $item);
@@ -600,15 +607,18 @@ function _menu_parent_depth_limit($item) {
  * @see menu_node_submit()
  */
 function menu_form_node_form_alter(&$form, $form_state) {
-  // Generate a list of possible parents.
+  // Generate a list of possible parents (not including this link or descendants).
   // @todo This must be handled in a #process handler.
+  $link = $form['#node']->menu;
   $type = $form['#node']->type;
-  $options = menu_parent_options(menu_get_menus(), $type);
+  // menu_parent_options() is goofy and can actually handle either a menu link
+  // or a node type both as second argument. Pick based on whether there is
+  // a link already (menu_node_prepare() sets mlid default to 0).
+  $options = menu_parent_options(menu_get_menus(), $link['mlid'] ? $link : $type);
   // If no possible parent menu items were found, there is nothing to display.
   if (empty($options)) {
     return;
   }
-  $link = $form['#node']->menu;
 
   $form['menu'] = array(
     '#type' => 'fieldset',
@@ -659,9 +669,13 @@ function menu_form_node_form_alter(&$form, $form_state) {
   );
 
   $default = ($link['mlid'] ? $link['menu_name'] . ':' . $link['plid'] : variable_get('menu_parent_' . $type, 'main-menu:0'));
-  // @todo This will fail with the new selective menus per content type.
+  // If the current parent menu item is not present in options, use the first
+  // available option as default value.
+  // @todo User should not be allowed to access menu link settings in such a
+  // case.
   if (!isset($options[$default])) {
-    $default = 'navigation:0';
+    $array = array_keys($options);
+    $default = reset($array);
   }
   $form['menu']['link']['parent'] = array(
     '#type' => 'select',
diff --git a/modules/menu/menu.test b/modules/menu/menu.test
index b457177..0edfc47 100644
--- a/modules/menu/menu.test
+++ b/modules/menu/menu.test
@@ -680,5 +680,43 @@ class MenuNodeTestCase extends DrupalWebTestCase {
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
     $link = menu_link_load($item['mlid']);
     $this->assertTrue($link, t('Link in not allowed menu still exists after saving node'));
+
+    // Move the menu link back to the Navigation menu.
+    $item['menu_name'] = 'navigation';
+    menu_link_save($item);
+    // Create a second node.
+    $child_node = $this->drupalCreateNode(array('type' => 'article'));
+    // Assign a menu link to the second node, being a child of the first one.
+    $child_item = array(
+      'link_path' => 'node/'. $child_node->nid,
+      'link_title' => $this->randomName(16),
+      'plid' => $item['mlid'],
+    );
+    menu_link_save($child_item);
+    // Edit the first node.
+    $this->drupalGet('node/'. $node->nid .'/edit');
+    // Assert that it is not possible to set the parent of the first node to itself or the second node.
+    $this->assertNoOption('edit-menu-parent', 'navigation:'. $item['mlid']);
+    $this->assertNoOption('edit-menu-parent', 'navigation:'. $child_item['mlid']);
+  }
+
+  /**
+   * Asserts that a select option in the current page does not exist.
+   *
+   * @param $id
+   *   Id of select field to assert.
+   * @param $option
+   *   Option to assert.
+   * @param $message
+   *   Message to display.
+   * @return
+   *   TRUE on pass, FALSE on fail.
+   *
+   * @todo move to simpletest drupal_web_test_case.php.
+   */
+  protected function assertNoOption($id, $option, $message = '') {
+    $selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
+    $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
+    return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : t('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), t('Browser'));
   }
 }
diff --git a/modules/node/node.module b/modules/node/node.module
index 6abfcb2..95b4219 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -2447,7 +2447,7 @@ function node_feed($nids = FALSE, $channel = array()) {
     $nids = db_select('node', 'n')
       ->fields('n', array('nid', 'created'))
       ->condition('n.promote', 1)
-      ->condition('status', 1)
+      ->condition('n.status', 1)
       ->orderBy('n.created', 'DESC')
       ->range(0, variable_get('feed_default_items', 10))
       ->addTag('node_access')
diff --git a/modules/node/node.test b/modules/node/node.test
index 56a2d34..8a1899e 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -2270,6 +2270,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
     $tests['[node:language]'] = check_plain($node->language);
     $tests['[node:url]'] = url('node/' . $node->nid, $url_options);
     $tests['[node:edit-url]'] = url('node/' . $node->nid . '/edit', $url_options);
+    $tests['[node:author]'] = check_plain(format_username($account));
     $tests['[node:author:uid]'] = $node->uid;
     $tests['[node:author:name]'] = check_plain(format_username($account));
     $tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->created, 2, $language->language);
diff --git a/modules/node/node.tokens.inc b/modules/node/node.tokens.inc
index 80dbda5..b6bafc6 100644
--- a/modules/node/node.tokens.inc
+++ b/modules/node/node.tokens.inc
@@ -157,8 +157,9 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
 
         // Default values for the chained tokens handled below.
         case 'author':
-          $name = ($node->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $node->name;
-          $replacements[$original] = $sanitize ? filter_xss($name) : $name;
+          $account = user_load($node->uid);
+          $name = format_username($account);
+          $replacements[$original] = $sanitize ? check_plain($name) : $name;
           break;
 
         case 'created':
diff --git a/modules/openid/openid.js b/modules/openid/openid.js
index 1f20427..fdc97fa 100644
--- a/modules/openid/openid.js
+++ b/modules/openid/openid.js
@@ -11,10 +11,10 @@ Drupal.behaviors.openid = {
       if (cookie) {
         $('#edit-openid-identifier').val(cookie);
       }
-      if ($('#edit-openid-identifier').val()) {
+      if ($('#edit-openid-identifier').val() || location.hash == '#openid-login') {
         $('#edit-openid-identifier').addClass('openid-processed');
         loginElements.hide();
-        // Use .css('display', 'block') instead of .show() to  Konqueror friendly.
+        // Use .css('display', 'block') instead of .show() to be Konqueror friendly.
         openidElements.css('display', 'block');
       }
     }
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index bb6ad71..2bf891a 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -146,11 +146,11 @@ function _openid_user_login_form_alter(&$form, &$form_state) {
 
   $items = array();
   $items[] = array(
-    'data' => l(t('Log in using OpenID'), '#'),
+    'data' => l(t('Log in using OpenID'), '#openid-login', array('external' => TRUE)),
     'class' => array('openid-link'),
   );
   $items[] = array(
-    'data' => l(t('Cancel OpenID login'), '#'),
+    'data' => l(t('Cancel OpenID login'), '#', array('external' => TRUE)),
     'class' => array('user-link'),
   );
 
diff --git a/modules/overlay/overlay-child.css b/modules/overlay/overlay-child.css
index d31952e..a2b23b4 100644
--- a/modules/overlay/overlay-child.css
+++ b/modules/overlay/overlay-child.css
@@ -17,6 +17,7 @@ html.js body {
   min-width: 700px;
   position: relative;
   padding: .2em;
+  padding-bottom: 2em;
   padding-right: 26px; /* LTR */
   width: 88%;
 }
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 2737c2b..13d2606 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -299,7 +299,9 @@ function poll_form($node, &$form_state) {
   $form['choice_wrapper']['poll_more'] = array(
     '#type' => 'submit',
     '#value' => t('More choices'),
-    '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
+    '#attributes' => array(
+      'title' => t("If the amount of boxes above isn't enough, click here to add more choices."),
+    ),
     '#weight' => 1,
     '#limit_validation_errors' => array(array('choice')),
     '#submit' => array('poll_more_choices_submit'),
diff --git a/modules/profile/profile-block.tpl.php b/modules/profile/profile-block.tpl.php
index 0bd8331..dbdbcd8 100644
--- a/modules/profile/profile-block.tpl.php
+++ b/modules/profile/profile-block.tpl.php
@@ -31,9 +31,9 @@
 ?>
 <?php print $user_picture; ?>
 
-<?php foreach ($profile as $field) : ?>
+<?php foreach ($profile as $field): ?>
   <p>
-    <?php if ($field->type != 'checkbox') : ?>
+    <?php if ($field->type != 'checkbox'): ?>
       <strong><?php print $field->title; ?></strong><br />
     <?php endif; ?>
     <?php print $field->value; ?>
diff --git a/modules/profile/profile-listing.tpl.php b/modules/profile/profile-listing.tpl.php
index d484ed2..d8b835a 100644
--- a/modules/profile/profile-listing.tpl.php
+++ b/modules/profile/profile-listing.tpl.php
@@ -43,7 +43,7 @@
     <?php print $name; ?>
   </div>
 
-  <?php foreach ($profile as $field) : ?>
+  <?php foreach ($profile as $field): ?>
     <div class="field">
       <?php print $field->value; ?>
     </div>
diff --git a/modules/search/search-block-form.tpl.php b/modules/search/search-block-form.tpl.php
index 7844746..da58403 100644
--- a/modules/search/search-block-form.tpl.php
+++ b/modules/search/search-block-form.tpl.php
@@ -30,7 +30,7 @@
  */
 ?>
 <div class="container-inline">
-  <?php if (empty($variables['form']['#block']->subject)) : ?>
+  <?php if (empty($variables['form']['#block']->subject)): ?>
     <h2 class="element-invisible"><?php print t('Search form'); ?></h2>
   <?php endif; ?>
   <?php print $search_form; ?>
diff --git a/modules/search/search-result.tpl.php b/modules/search/search-result.tpl.php
index db9f220..949452a 100644
--- a/modules/search/search-result.tpl.php
+++ b/modules/search/search-result.tpl.php
@@ -45,7 +45,7 @@
  * for its existence before printing. The default keys of 'type', 'user' and
  * 'date' always exist for node searches. Modules may provide other data.
  * @code
- *   <?php if (isset($info_split['comment'])) : ?>
+ *   <?php if (isset($info_split['comment'])): ?>
  *     <span class="info-comment">
  *       <?php print $info_split['comment']; ?>
  *     </span>
@@ -69,10 +69,10 @@
   </h3>
   <?php print render($title_suffix); ?>
   <div class="search-snippet-info">
-    <?php if ($snippet) : ?>
+    <?php if ($snippet): ?>
       <p class="search-snippet"<?php print $content_attributes; ?>><?php print $snippet; ?></p>
     <?php endif; ?>
-    <?php if ($info) : ?>
+    <?php if ($info): ?>
       <p class="search-info"><?php print $info; ?></p>
     <?php endif; ?>
   </div>
diff --git a/modules/search/search-results.tpl.php b/modules/search/search-results.tpl.php
index 4de724b..e35be1e 100644
--- a/modules/search/search-results.tpl.php
+++ b/modules/search/search-results.tpl.php
@@ -21,7 +21,7 @@
  * @see template_preprocess_search_results()
  */
 ?>
-<?php if ($search_results) : ?>
+<?php if ($search_results): ?>
   <h2><?php print t('Search results');?></h2>
   <ol class="search-results <?php print $module; ?>-results">
     <?php print $search_results; ?>
diff --git a/modules/shortcut/shortcut.admin.inc b/modules/shortcut/shortcut.admin.inc
index 4c8bf53..91ce7c8 100644
--- a/modules/shortcut/shortcut.admin.inc
+++ b/modules/shortcut/shortcut.admin.inc
@@ -482,6 +482,7 @@ function _shortcut_link_form_elements($shortcut_link = NULL) {
     '#size' => 40,
     '#maxlength' => 255,
     '#default_value' => $shortcut_link['link_title'],
+    '#required' => TRUE,
   );
 
   $form['shortcut_link']['link_path'] = array(
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 76ca103..2a3d4c4 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -2364,8 +2364,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
   }
 
   /**
-  * Confirm that every pager gets a valid non-overlaping element ID.
-  */
+   * Confirm that every pager gets a valid non-overlaping element ID.
+   */
   function testElementNumbers() {
     $_GET['page'] = '3, 2, 1, 0';
 
diff --git a/modules/simpletest/tests/entity_query.test b/modules/simpletest/tests/entity_query.test
index 0fe8106..3c53eae 100644
--- a/modules/simpletest/tests/entity_query.test
+++ b/modules/simpletest/tests/entity_query.test
@@ -722,6 +722,31 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
     $query = new EntityFieldQuery();
     $query
       ->entityCondition('entity_type', 'test_entity_bundle_key')
+      ->propertyCondition('ftid', 3, '<>');
+    $this->assertEntityFieldQuery($query, array(
+      array('test_entity_bundle_key', 1),
+      array('test_entity_bundle_key', 2),
+      array('test_entity_bundle_key', 4),
+      array('test_entity_bundle_key', 5),
+      array('test_entity_bundle_key', 6),
+    ), t('Test the "not equal to" operation on a property.'));
+
+    $query = new EntityFieldQuery();
+    $query->fieldCondition($this->fields[0], 'value', 3, '<>');
+    $this->assertEntityFieldQuery($query, array(
+      array('test_entity_bundle_key', 1),
+      array('test_entity_bundle_key', 2),
+      array('test_entity_bundle_key', 4),
+      array('test_entity_bundle_key', 5),
+      array('test_entity_bundle_key', 6),
+      array('test_entity', 1),
+      array('test_entity', 2),
+      array('test_entity', 4),
+    ), t('Test the "not equal to" operation on a field.'));
+
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity_bundle_key')
       ->propertyCondition('ftid', 3, '!=');
     $this->assertEntityFieldQuery($query, array(
       array('test_entity_bundle_key', 1),
@@ -1088,6 +1113,15 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
     $query = new EntityFieldQuery();
     $query
       ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>');
+    $this->assertEntityFieldQuery($query, array(
+      array('test_entity', 1),
+    ), t('Test with a language meta condition.'));
+
+    // Test language field meta condition.
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=');
     $this->assertEntityFieldQuery($query, array(
       array('test_entity', 1),
@@ -1115,6 +1149,16 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
     $query
       ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
+      ->fieldLanguageCondition($this->fields[0], 'en', '<>', NULL, 'group');
+    $this->assertEntityFieldQuery($query, array(
+      array('test_entity', 1),
+    ), t('Test with a grouped language meta condition.'));
+
+    // Test language grouping.
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
       ->fieldLanguageCondition($this->fields[0], 'en', '!=', NULL, 'group');
     $this->assertEntityFieldQuery($query, array(
       array('test_entity', 1),
@@ -1124,6 +1168,13 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
     $query
       ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
+      ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', NULL, 'group');
+    $this->assertEntityFieldQuery($query, array(), t('Test with a grouped language meta condition (empty result set).'));
+
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
       ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=', NULL, 'group');
     $this->assertEntityFieldQuery($query, array(), t('Test with a grouped language meta condition (empty result set).'));
 
@@ -1133,6 +1184,17 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
       ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
+      ->fieldLanguageCondition($this->fields[0], 'en', '<>', 'delta', 'language');
+    $this->assertEntityFieldQuery($query, array(
+      array('test_entity', 1),
+    ), t('Test with a grouped delta + language meta condition.'));
+
+    // Test delta and language grouping.
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+      ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
       ->fieldLanguageCondition($this->fields[0], 'en', '!=', 'delta', 'language');
     $this->assertEntityFieldQuery($query, array(
       array('test_entity', 1),
@@ -1143,6 +1205,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
       ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
+      ->fieldLanguageCondition($this->fields[0], 'en', '<>', 'delta', 'language');
+    $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, delta condition unsatisifed).'));
+
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+      ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
       ->fieldLanguageCondition($this->fields[0], 'en', '!=', 'delta', 'language');
     $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, delta condition unsatisifed).'));
 
@@ -1151,6 +1221,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
       ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
+      ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', 'delta', 'language');
+    $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, language condition unsatisifed).'));
+
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+      ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
       ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=', 'delta', 'language');
     $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, language condition unsatisifed).'));
 
@@ -1159,6 +1237,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
       ->entityCondition('entity_type', 'test_entity', '=')
       ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
       ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
+      ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', 'delta', 'language');
+    $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, both conditions unsatisifed).'));
+
+    $query = new EntityFieldQuery();
+    $query
+      ->entityCondition('entity_type', 'test_entity', '=')
+      ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+      ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
       ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=', 'delta', 'language');
     $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, both conditions unsatisifed).'));
 
diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test
index c0a79d4..0ec61dc 100644
--- a/modules/simpletest/tests/menu.test
+++ b/modules/simpletest/tests/menu.test
@@ -5,6 +5,122 @@
  * Provides SimpleTests for menu.inc.
  */
 
+class MenuWebTestCase extends DrupalWebTestCase {
+  function setUp() {
+    $modules = func_get_args();
+    if (isset($modules[0]) && is_array($modules[0])) {
+      $modules = $modules[0];
+    }
+    parent::setUp($modules);
+  }
+
+  /**
+   * Assert that a given path shows certain breadcrumb links.
+   *
+   * @param string $goto
+   *   (optional) A system path to pass to DrupalWebTestCase::drupalGet().
+   * @param array $trail
+   *   An associative array whose keys are expected breadcrumb link paths and
+   *   whose values are expected breadcrumb link texts (not sanitized).
+   * @param string $page_title
+   *   (optional) A page title to additionally assert via
+   *   DrupalWebTestCase::assertTitle(). Without site name suffix.
+   * @param array $tree
+   *   (optional) An associative array whose keys are link paths and whose
+   *   values are link titles (not sanitized) of an expected active trail in a
+   *   menu tree output on the page.
+   * @param $last_active
+   *   (optional) Whether the last link in $tree is expected to be active (TRUE)
+   *   or just to be in the active trail (FALSE).
+   */
+  protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = array(), $last_active = TRUE) {
+    if (isset($goto)) {
+      $this->drupalGet($goto);
+    }
+    // Compare paths with actual breadcrumb.
+    $parts = $this->getParts();
+    $pass = TRUE;
+    foreach ($trail as $path => $title) {
+      $url = url($path);
+      $part = array_shift($parts);
+      $pass = ($pass && $part['href'] === $url && $part['text'] === check_plain($title));
+    }
+    // No parts must be left, or an expected "Home" will always pass.
+    $pass = ($pass && empty($parts));
+
+    $this->assertTrue($pass, t('Breadcrumb %parts found on @path.', array(
+      '%parts' => implode(' » ', $trail),
+      '@path' => $this->getUrl(),
+    )));
+
+    // Additionally assert page title, if given.
+    if (isset($page_title)) {
+      $this->assertTitle(strtr('@title | Drupal', array('@title' => $page_title)));
+    }
+
+    // Additionally assert active trail in a menu tree output, if given.
+    if ($tree) {
+      end($tree);
+      $active_link_path = key($tree);
+      $active_link_title = array_pop($tree);
+      $xpath = '';
+      if ($tree) {
+        $i = 0;
+        foreach ($tree as $link_path => $link_title) {
+          $part_xpath = (!$i ? '//' : '/following-sibling::ul/descendant::');
+          $part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]';
+          $part_args = array(
+            ':class' => 'active-trail',
+            ':href' => url($link_path),
+            ':title' => $link_title,
+          );
+          $xpath .= $this->buildXPathQuery($part_xpath, $part_args);
+          $i++;
+        }
+        $elements = $this->xpath($xpath);
+        $this->assertTrue(!empty($elements), t('Active trail to current page was found in menu tree.'));
+
+        // Append prefix for active link asserted below.
+        $xpath .= '/following-sibling::ul/descendant::';
+      }
+      else {
+        $xpath .= '//';
+      }
+      $xpath_last_active = ($last_active ? 'and contains(@class, :class-active)' : '');
+      $xpath .= 'li[contains(@class, :class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
+      $args = array(
+        ':class-trail' => 'active-trail',
+        ':class-active' => 'active',
+        ':href' => url($active_link_path),
+        ':title' => $active_link_title,
+      );
+      $elements = $this->xpath($xpath, $args);
+      $this->assertTrue(!empty($elements), t('Active link %title was found in menu tree, including active trail links %tree.', array(
+        '%title' => $active_link_title,
+        '%tree' => implode(' » ', $tree),
+      )));
+    }
+  }
+
+  /**
+   * Returns the breadcrumb contents of the current page in the internal browser.
+   */
+  protected function getParts() {
+    $parts = array();
+    $elements = $this->xpath('//div[@class="breadcrumb"]/a');
+    if (!empty($elements)) {
+      foreach ($elements as $element) {
+        $parts[] = array(
+          'text' => (string) $element,
+          'href' => (string) $element['href'],
+          'title' => (string) $element['title'],
+        );
+      }
+    }
+    return $parts;
+  }
+}
+
 class MenuRouterTestCase extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
@@ -897,7 +1013,7 @@ class MenuTreeOutputTestCase extends DrupalWebTestCase {
       'group' => 'Menu',
     );
   }
-  
+
   function setUp() {
     parent::setUp();
   }
@@ -925,7 +1041,7 @@ class MenuTreeOutputTestCase extends DrupalWebTestCase {
 /**
  * Menu breadcrumbs related tests.
  */
-class MenuBreadcrumbTestCase extends DrupalWebTestCase {
+class MenuBreadcrumbTestCase extends MenuWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Breadcrumbs',
@@ -935,7 +1051,12 @@ class MenuBreadcrumbTestCase extends DrupalWebTestCase {
   }
 
   function setUp() {
-    parent::setUp(array('menu_test'));
+    $modules = func_get_args();
+    if (isset($modules[0]) && is_array($modules[0])) {
+      $modules = $modules[0];
+    }
+    $modules[] = 'menu_test';
+    parent::setUp($modules);
     $perms = array_keys(module_invoke_all('permission'));
     $this->admin_user = $this->drupalCreateUser($perms);
     $this->drupalLogin($this->admin_user);
@@ -1410,110 +1531,117 @@ class MenuBreadcrumbTestCase extends DrupalWebTestCase {
     $this->assertBreadcrumb('admin/reports/dblog', $trail, t('Recent log messages'));
     $this->assertNoResponse(403);
   }
+}
 
-  /**
-   * Assert that a given path shows certain breadcrumb links.
-   *
-   * @param string $goto
-   *   (optional) A system path to pass to DrupalWebTestCase::drupalGet().
-   * @param array $trail
-   *   An associative array whose keys are expected breadcrumb link paths and
-   *   whose values are expected breadcrumb link texts (not sanitized).
-   * @param string $page_title
-   *   (optional) A page title to additionally assert via
-   *   DrupalWebTestCase::assertTitle(). Without site name suffix.
-   * @param array $tree
-   *   (optional) An associative array whose keys are link paths and whose
-   *   values are link titles (not sanitized) of an expected active trail in a
-   *   menu tree output on the page.
-   * @param $last_active
-   *   (optional) Whether the last link in $tree is expected to be active (TRUE)
-   *   or just to be in the active trail (FALSE).
-   */
-  protected function assertBreadcrumb($goto, array $trail, $page_title = NULL, array $tree = array(), $last_active = TRUE) {
-    if (isset($goto)) {
-      $this->drupalGet($goto);
-    }
-    // Compare paths with actual breadcrumb.
-    $parts = $this->getParts();
-    $pass = TRUE;
-    foreach ($trail as $path => $title) {
-      $url = url($path);
-      $part = array_shift($parts);
-      $pass = ($pass && $part['href'] === $url && $part['text'] === check_plain($title));
-    }
-    // No parts must be left, or an expected "Home" will always pass.
-    $pass = ($pass && empty($parts));
-
-    $this->assertTrue($pass, t('Breadcrumb %parts found on @path.', array(
-      '%parts' => implode(' » ', $trail),
-      '@path' => $this->getUrl(),
-    )));
+/**
+ * Tests active menu trails.
+ */
+class MenuTrailTestCase extends MenuWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Active trail',
+      'description' => 'Tests active menu trails and alteration functionality.',
+      'group' => 'Menu',
+    );
+  }
 
-    // Additionally assert page title, if given.
-    if (isset($page_title)) {
-      $this->assertTitle(strtr('@title | Drupal', array('@title' => $page_title)));
+  function setUp() {
+    $modules = func_get_args();
+    if (isset($modules[0]) && is_array($modules[0])) {
+      $modules = $modules[0];
     }
+    $modules[] = 'menu_test';
+    parent::setUp($modules);
+    $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages'));
+    $this->drupalLogin($this->admin_user);
 
-    // Additionally assert active trail in a menu tree output, if given.
-    if ($tree) {
-      end($tree);
-      $active_link_path = key($tree);
-      $active_link_title = array_pop($tree);
-      $xpath = '';
-      if ($tree) {
-        $i = 0;
-        foreach ($tree as $link_path => $link_title) {
-          $part_xpath = (!$i ? '//' : '/following-sibling::ul/descendant::');
-          $part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]';
-          $part_args = array(
-            ':class' => 'active-trail',
-            ':href' => url($link_path),
-            ':title' => $link_title,
-          );
-          $xpath .= $this->buildXPathQuery($part_xpath, $part_args);
-          $i++;
-        }
-        $elements = $this->xpath($xpath);
-        $this->assertTrue(!empty($elements), t('Active trail to current page was found in menu tree.'));
+    // This test puts menu links in the Navigation menu and then tests for
+    // their presence on the page, so we need to ensure that the Navigation
+    // block will be displayed in all active themes.
+    db_update('block')
+      ->fields(array(
+        // Use a region that is valid for all themes.
+        'region' => 'content',
+        'status' => 1,
+      ))
+      ->condition('module', 'system')
+      ->condition('delta', 'navigation')
+      ->execute();
 
-        // Append prefix for active link asserted below.
-        $xpath .= '/following-sibling::ul/descendant::';
-      }
-      else {
-        $xpath .= '//';
-      }
-      $xpath_last_active = ($last_active ? 'and contains(@class, :class-active)' : '');
-      $xpath .= 'li[contains(@class, :class-trail)]/a[contains(@href, :href) ' . $xpath_last_active . 'and contains(text(), :title)]';
-      $args = array(
-        ':class-trail' => 'active-trail',
-        ':class-active' => 'active',
-        ':href' => url($active_link_path),
-        ':title' => $active_link_title,
-      );
-      $elements = $this->xpath($xpath, $args);
-      $this->assertTrue(!empty($elements), t('Active link %title was found in menu tree, including active trail links %tree.', array(
-        '%title' => $active_link_title,
-        '%tree' => implode(' » ', $tree),
-      )));
-    }
+    // This test puts menu links in the Management menu and then tests for
+    // their presence on the page, so we need to ensure that the Management
+    // block will be displayed in all active themes.
+    db_update('block')
+      ->fields(array(
+        // Use a region that is valid for all themes.
+        'region' => 'content',
+        'status' => 1,
+      ))
+      ->condition('module', 'system')
+      ->condition('delta', 'management')
+      ->execute();
   }
 
   /**
-   * Returns the breadcrumb contents of the current page in the internal browser.
+   * Tests active trails are properly affected by menu_tree_set_path().
    */
-  protected function getParts() {
-    $parts = array();
-    $elements = $this->xpath('//div[@class="breadcrumb"]/a');
-    if (!empty($elements)) {
-      foreach ($elements as $element) {
-        $parts[] = array(
-          'text' => (string) $element,
-          'href' => (string) $element['href'],
-          'title' => (string) $element['title'],
-        );
-      }
-    }
-    return $parts;
+  function testMenuTreeSetPath() {
+    $home = array('<front>' => 'Home');
+    $config_tree = array(
+      'admin' => t('Administration'),
+      'admin/config' => t('Configuration'),
+    );
+    $config = $home + $config_tree;
+
+    // The menu_test_menu_tree_set_path system variable controls whether or not
+    // the menu_test_menu_trail_callback() callback (used by all paths in these
+    // tests) issues an overriding call to menu_trail_set_path().
+    $test_menu_path = array(
+      'menu_name' => 'management',
+      'path' => 'admin/config/system/site-information',
+    );
+
+    $breadcrumb = $home + array(
+      'menu-test' => t('Menu test root'),
+    );
+    $tree = array(
+      'menu-test' => t('Menu test root'),
+      'menu-test/menu-trail' => t('Menu trail - Case 1'),
+    );
+
+    // Test the tree generation for the Navigation menu.
+    variable_del('menu_test_menu_tree_set_path');
+    $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
+
+    // Override the active trail for the Management tree; it should not affect
+    // the Navigation tree.
+    variable_set('menu_test_menu_tree_set_path', $test_menu_path);
+    $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
+
+    $breadcrumb = $config + array(
+      'admin/config/development' => t('Development'),
+    );
+    $tree = $config_tree + array(
+      'admin/config/development' => t('Development'),
+      'admin/config/development/menu-trail' => t('Menu trail - Case 2'),
+    );
+
+    $override_breadcrumb = $config + array(
+      'admin/config/system' => t('System'),
+      'admin/config/system/site-information' => t('Site information'),
+    );
+    $override_tree = $config_tree + array(
+      'admin/config/system' => t('System'),
+      'admin/config/system/site-information' => t('Site information'),
+    );
+
+    // Test the tree generation for the Management menu.
+    variable_del('menu_test_menu_tree_set_path');
+    $this->assertBreadcrumb('admin/config/development/menu-trail', $breadcrumb, t('Menu trail - Case 2'), $tree);
+
+    // Override the active trail for the Management tree; it should affect the
+    // breadcrumbs and Management tree.
+    variable_set('menu_test_menu_tree_set_path', $test_menu_path);
+    $this->assertBreadcrumb('admin/config/development/menu-trail', $override_breadcrumb, t('Menu trail - Case 2'), $override_tree);
   }
 }
diff --git a/modules/simpletest/tests/menu_test.module b/modules/simpletest/tests/menu_test.module
index 3046a04..c42aca6 100644
--- a/modules/simpletest/tests/menu_test.module
+++ b/modules/simpletest/tests/menu_test.module
@@ -217,6 +217,20 @@ function menu_test_menu() {
     'type' => MENU_LOCAL_TASK,
   ) + $base;
 
+  // Menu trail tests.
+  // @see MenuTrailTestCase
+  $items['menu-test/menu-trail'] = array(
+    'title' => 'Menu trail - Case 1',
+    'page callback' => 'menu_test_menu_trail_callback',
+    'access arguments' => array('access content'),
+  );
+  $items['admin/config/development/menu-trail'] = array(
+    'title' => 'Menu trail - Case 2',
+    'description' => 'Tests menu_tree_set_path()',
+    'page callback' => 'menu_test_menu_trail_callback',
+    'access arguments' => array('access administration pages'),
+  );
+
   // File inheritance tests. This menu item should inherit the page callback
   // system_admin_menu_block_page() and therefore render its children as links
   // on the page.
@@ -345,6 +359,17 @@ function menu_test_callback() {
 }
 
 /**
+ * Callback that test menu_test_menu_tree_set_path().
+ */
+function menu_test_menu_trail_callback() {
+  $menu_path = variable_get('menu_test_menu_tree_set_path', array());
+  if (!empty($menu_path)) {
+    menu_tree_set_path($menu_path['menu_name'], $menu_path['path']);
+  }
+  return 'This is menu_test_menu_trail_callback().';
+}
+
+/**
  * Page callback to use when testing the theme callback functionality.
  *
  * @param $inherited
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index f1e1bd5..53557e3 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -354,3 +354,29 @@ class ThemeFastTestCase extends DrupalWebTestCase {
     $this->assertText('registry not initialized', t('The registry was not initialized'));
   }
 }
+
+/**
+ * Unit tests for theme_html_tag().
+ */
+class ThemeHtmlTag extends DrupalUnitTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Theme HTML Tag',
+      'description' => 'Tests theme_html_tag() built-in theme functions.',
+      'group' => 'Theme',
+    );
+  }
+
+  /**
+   * Test function theme_html_tag()
+   */
+  function testThemeHtmlTag() {
+    // Test auto-closure meta tag generation
+    $tag['element'] = array('#tag' => 'meta', '#attributes' => array('name' => 'description', 'content' => 'Drupal test'));
+    $this->assertEqual('<meta name="description" content="Drupal test" />'."\n", theme_html_tag($tag), t('Test auto-closure meta tag generation.'));
+
+    // Test title tag generation
+    $tag['element'] = array('#tag' => 'title', '#value' => 'title test');
+    $this->assertEqual('<title>title test</title>'."\n", theme_html_tag($tag), t('Test title tag generation.'));
+  }
+}
diff --git a/modules/statistics/statistics.test b/modules/statistics/statistics.test
index 126828f..153f6a6 100644
--- a/modules/statistics/statistics.test
+++ b/modules/statistics/statistics.test
@@ -102,6 +102,7 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
     $this->drupalGet($path);
     $this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Testing a cached page.'));
     $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
+    dd($log);
     $this->assertTrue(is_array($log) && count($log) == 2, t('Page request was logged.'));
     $this->assertEqual(array_intersect_key($log[1], $expected), $expected);
     $node_counter = statistics_get($this->node->nid);
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 46aa9c2..78f06eb 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -19,7 +19,7 @@ function system_admin_config_page() {
       SELECT m.*, ml.*
       FROM {menu_links} ml
       INNER JOIN {menu_router} m ON ml.router_path = m.path
-      WHERE ml.link_path != 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
+      WHERE ml.link_path <> 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
     foreach ($result as $item) {
       _menu_link_translate($item);
       if (!$item['access']) {
@@ -1582,7 +1582,7 @@ function system_cron_settings() {
     '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
   );
 
-  return system_settings_form($form, FALSE);
+  return system_settings_form($form);
 }
 
 /**
@@ -2181,24 +2181,45 @@ function system_site_maintenance_mode() {
  * @see system_settings_form()
  */
 function system_clean_url_settings($form, &$form_state) {
-  global $base_url;
-
-  // When accessing this form using a non-clean URL, allow a re-check to make
-  // sure clean URLs can be disabled at all times.
   $available = FALSE;
-  if (strpos(request_uri(), '?q=') === FALSE || !empty($_SESSION['clean_url'])) {
+  $conflict = FALSE;
+
+  // If the request URI is a clean URL, clean URLs must be available.
+  // Otherwise, run a test.
+  if (strpos(request_uri(), '?q=') === FALSE && strpos(request_uri(), '&q=') === FALSE) {
     $available = TRUE;
   }
   else {
-    $request = drupal_http_request($base_url . '/admin/config/search/clean-urls/check');
+    $request = drupal_http_request($GLOBALS['base_url'] . '/admin/config/search/clean-urls/check');
+    // If the request returns HTTP 200, clean URLs are available.
     if (isset($request->code) && $request->code == 200) {
       $available = TRUE;
+      // If the user started the clean URL test, provide explicit feedback.
+      if (isset($form_state['input']['clean_url_test_execute'])) {
+        drupal_set_message(t('The clean URL test passed.'));
+      }
+    }
+    else {
+      // If the test failed while clean URLs are enabled, make sure clean URLs
+      // can be disabled.
+      if (variable_get('clean_url', 0)) {
+        $conflict = TRUE;
+        // Warn the user of a conflicting situation, unless after processing
+        // a submitted form.
+        if (!isset($form_state['input']['op'])) {
+          drupal_set_message(t('Clean URLs are enabled, but the clean URL test failed. Uncheck the box below to disable clean URLs.'), 'warning');
+        }
+      }
+      // If the user started the clean URL test, provide explicit feedback.
+      elseif (isset($form_state['input']['clean_url_test_execute'])) {
+        drupal_set_message(t('The clean URL test failed.'), 'warning');
+      }
     }
   }
 
-  if ($available) {
-    $_SESSION['clean_url'] = TRUE;
-
+  // Show the enable/disable form if clean URLs are available or if the user
+  // must be able to resolve a conflicting setting.
+  if ($available || $conflict) {
     $form['clean_url'] = array(
       '#type' => 'checkbox',
       '#title' => t('Enable clean URLs'),
@@ -2206,18 +2227,37 @@ function system_clean_url_settings($form, &$form_state) {
       '#description' => t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.'),
     );
     $form = system_settings_form($form);
+    if ($conflict) {
+      // $form_state['redirect'] needs to be set to the non-clean URL,
+      // otherwise the setting is not saved.
+      $form_state['redirect'] = url('', array('query' => array('q' => '/admin/config/search/clean-urls')));
+    }
   }
+  // Show the clean URLs test form.
   else {
     drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
 
-    $form_state['redirect'] = $base_url . '/admin/config/search/clean-urls';
+    $form_state['redirect'] = url('admin/config/search/clean-urls');
     $form['clean_url_description'] = array(
       '#type' => 'markup',
-      '#markup' => '<p>' . t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.') . ' ' . t('If you are directed to a <em>Page not found (404)</em> error after testing for clean URLs, see the <a href="@handbook">online handbook</a>.', array('@handbook' => 'http://drupal.org/node/15365')) . '</p>',
+      '#markup' => '<p>' . t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.'),
     );
-    $form['clean_url_test'] = array(
-      '#type' => 'submit',
-      '#value' => t('Run the clean URL test'),
+    // Explain why the user is seeing this page and what to expect after
+    // clicking the 'Run the clean URL test' button.
+    $form['clean_url_test_result'] = array(
+      '#type' => 'markup',
+      '#markup' => '<p>' . t('Clean URLs cannot be enabled. If you are directed to this page or to a <em>Page not found (404)</em> error after testing for clean URLs, see the <a href="@handbook">online handbook</a>.', array('@handbook' => 'http://drupal.org/node/15365')) . '</p>',
+    );
+    $form['actions'] = array(
+      '#type' => 'actions',
+      'clean_url_test' => array(
+        '#type' => 'submit',
+        '#value' => t('Run the clean URL test'),
+      ),
+    );
+    $form['clean_url_test_execute'] = array(
+      '#type' => 'hidden',
+      '#value' => 1,
     );
   }
 
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index ae13d49..9cc091b 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -544,7 +544,7 @@ function hook_cron() {
 
   // Long-running operation example, leveraging a queue:
   // Fetch feeds from other sites.
-  $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh != :never', array(
+  $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh <> :never', array(
     ':time' => REQUEST_TIME,
     ':never' => AGGREGATOR_CLEAR_NEVER,
   ));
@@ -672,8 +672,8 @@ function hook_element_info_alter(&$type) {
  * page logging and specialized cleanup. This hook MUST NOT print anything.
  *
  * Only use this hook if your code must run even for cached page views.
- * If you have code which must run once on all non cached pages, use
- * hook_init instead. Thats the usual case. If you implement this hook
+ * If you have code which must run once on all non-cached pages, use
+ * hook_init() instead. That is the usual case. If you implement this hook
  * and see an error like 'Call to undefined function', it is likely that
  * you are depending on the presence of a module which has not been loaded yet.
  * It is not loaded because Drupal is still in bootstrap mode.
@@ -1053,24 +1053,24 @@ function hook_menu_get_item_alter(&$router_item, $path, $original_map) {
  * MENU_LOCAL_TASK. Example:
  * @code
  * // Make "Foo settings" appear on the admin Config page
- * $items['admin/config/foo'] = array(
+ * $items['admin/config/system/foo'] = array(
  *   'title' => 'Foo settings',
  *   'type' => MENU_NORMAL_ITEM,
  *   // Page callback, etc. need to be added here.
  * );
- * // Make "Global settings" the main tab on the "Foo settings" page
- * $items['admin/config/foo/global'] = array(
- *   'title' => 'Global settings',
+ * // Make "Tab 1" the main tab on the "Foo settings" page
+ * $items['admin/config/system/foo/tab1'] = array(
+ *   'title' => 'Tab 1',
  *   'type' => MENU_DEFAULT_LOCAL_TASK,
  *   // Access callback, page callback, and theme callback will be inherited
- *   // from 'admin/config/foo', if not specified here to override.
+ *   // from 'admin/config/system/foo', if not specified here to override.
  * );
- * // Make an additional tab called "Node settings" on "Foo settings"
- * $items['admin/config/foo/node'] = array(
- *   'title' => 'Node settings',
+ * // Make an additional tab called "Tab 2" on "Foo settings"
+ * $items['admin/config/system/foo/tab2'] = array(
+ *   'title' => 'Tab 2',
  *   'type' => MENU_LOCAL_TASK,
  *   // Page callback and theme callback will be inherited from
- *   // 'admin/config/foo', if not specified here to override.
+ *   // 'admin/config/system/foo', if not specified here to override.
  *   // Need to add access callback or access arguments.
  * );
  * @endcode
@@ -1744,32 +1744,36 @@ function hook_forms($form_id, $args) {
 }
 
 /**
- * Perform setup tasks. See also, hook_init.
+ * Perform setup tasks for all page requests.
  *
  * This hook is run at the beginning of the page request. It is typically
- * used to set up global parameters which are needed later in the request.
+ * used to set up global parameters that are needed later in the request.
  *
- * Only use this hook if your code must run even for cached page views.This hook
- * is called before modules or most include files are loaded into memory.
+ * Only use this hook if your code must run even for cached page views. This
+ * hook is called before modules or most include files are loaded into memory.
  * It happens while Drupal is still in bootstrap mode.
+ *
+ * @see hook_init()
  */
 function hook_boot() {
-  // we need user_access() in the shutdown function. make sure it gets loaded
+  // We need user_access() in the shutdown function. Make sure it gets loaded.
   drupal_load('module', 'user');
   drupal_register_shutdown_function('devel_shutdown');
 }
 
 /**
- * Perform setup tasks. See also, hook_boot.
+ * Perform setup tasks for non-cached page requests.
  *
  * This hook is run at the beginning of the page request. It is typically
- * used to set up global parameters which are needed later in the request.
- * when this hook is called, all modules are already loaded in memory.
+ * used to set up global parameters that are needed later in the request.
+ * When this hook is called, all modules are already loaded in memory.
  *
  * This hook is not run on cached pages.
  *
  * To add CSS or JS that should be present on all pages, modules should not
  * implement this hook, but declare these files in their .info file.
+ *
+ * @see hook_boot()
  */
 function hook_init() {
   // Since this file should only be loaded on the front page, it cannot be
@@ -2627,17 +2631,21 @@ function hook_file_presave($file) {
 /**
  * Respond to a file being added.
  *
- * This hook is called before a file has been added to the database. The hook
+ * This hook is called after a file has been added to the database. The hook
  * doesn't distinguish between files created as a result of a copy or those
  * created by an upload.
  *
  * @param $file
- *   The file that is about to be saved.
+ *   The file that has been added.
  *
  * @see file_save()
  */
 function hook_file_insert($file) {
-
+  // Add a message to the log, if the file is a jpg
+  $validate = file_validate_extensions($file, 'jpg');
+  if (empty($validate)) {
+    watchdog('file', 'A jpg has been added.');
+  }
 }
 
 /**
diff --git a/modules/system/system.module b/modules/system/system.module
index 922035d..d0a542e 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -1359,7 +1359,7 @@ function system_library() {
     ),
   );
   $libraries['ui.mouse'] = array(
-    'title' => 'jQuery UI: Droppable',
+    'title' => 'jQuery UI: Mouse',
     'website' => 'http://docs.jquery.com/UI/Mouse',
     'version' => '1.8.7',
     'js' => array(
@@ -2912,7 +2912,7 @@ function system_get_module_admin_tasks($module, $info) {
       ->condition('ml.hidden', 0, '>=')
       ->condition('ml.module', 'system')
       ->condition('m.number_parts', 1, '>')
-      ->condition('m.page_callback', 'system_admin_menu_block_page', '!=');
+      ->condition('m.page_callback', 'system_admin_menu_block_page', '<>');
     foreach ($query->execute() as $link) {
       _menu_link_translate($link);
       if ($link['access']) {
diff --git a/modules/update/tests/update_test.module b/modules/update/tests/update_test.module
index 4e32d33..4acb6ef 100644
--- a/modules/update/tests/update_test.module
+++ b/modules/update/tests/update_test.module
@@ -12,6 +12,12 @@ function update_test_menu() {
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
+  $items['503-error'] = array(
+    'title' => t('503 Service unavailable'),
+    'page callback' => 'update_callback_service_unavailable',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
@@ -148,3 +154,11 @@ class UpdateTestFileTransfer {
     return $form;
   }
 }
+
+/**
+ * Return an Error 503 (Service unavailable) page.
+ */
+function update_callback_service_unavailable() {
+  drupal_add_http_header('Status', '503 Service unavailable');
+  print "503 Service Temporarily Unavailable";
+}
diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc
index ff69cbb..7ac0dbe 100644
--- a/modules/update/update.fetch.inc
+++ b/modules/update/update.fetch.inc
@@ -143,7 +143,7 @@ function _update_process_fetch_task($project) {
 
   if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) {
     $xml = drupal_http_request($url);
-    if (isset($xml->data)) {
+    if (!isset($xml->error) && isset($xml->data)) {
       $data = $xml->data;
     }
   }
diff --git a/modules/update/update.test b/modules/update/update.test
index 997650d..c0f471a 100644
--- a/modules/update/update.test
+++ b/modules/update/update.test
@@ -32,9 +32,9 @@ class UpdateTestHelper extends DrupalWebTestCase {
    *
    * @see update_test_mock_page()
    */
-  protected function refreshUpdateStatus($xml_map) {
+  protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
     // Tell update module to fetch from the URL provided by update_test module.
-    variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE)));
+    variable_set('update_fetch_url', url($url, array('absolute' => TRUE)));
     // Save the map for update_test_mock_page() to use.
     variable_set('update_test_xml_map', $xml_map);
     // Manually check the update status.
@@ -215,6 +215,16 @@ class UpdateCoreTestCase extends UpdateTestHelper {
     $this->assertNoText(t('There is a security update available for your version of Drupal.'));
   }
 
+  /**
+   * Tests the update module when the update server returns 503 (Service unavailable) errors.
+   */
+  function testServiceUnavailable() {
+    $this->refreshUpdateStatus(array(), '503-error');
+    // Ensure that no "Warning: SimpleXMLElement..." parse errors are found.
+    $this->assertNoText('SimpleXMLElement');
+    $this->assertUniqueText(t('Failed to get available update data for one project.'));
+  }
+
   protected function setSystemInfo7_0() {
     $setting = array(
       '#all' => array(
diff --git a/modules/user/user-profile-category.tpl.php b/modules/user/user-profile-category.tpl.php
index 0de7d5d..0a86c76 100644
--- a/modules/user/user-profile-category.tpl.php
+++ b/modules/user/user-profile-category.tpl.php
@@ -24,7 +24,7 @@
  * @see template_preprocess_user_profile_category()
  */
 ?>
-<?php if ($title) : ?>
+<?php if ($title): ?>
   <h3><?php print $title; ?></h3>
 <?php endif; ?>
 
diff --git a/modules/user/user-profile.tpl.php b/modules/user/user-profile.tpl.php
index 50e6111..b609429 100644
--- a/modules/user/user-profile.tpl.php
+++ b/modules/user/user-profile.tpl.php
@@ -18,11 +18,11 @@
  * Available variables:
  *   - $user_profile: An array of profile items. Use render() to print them.
  *   - Field variables: for each field instance attached to the user a
- *     corresponding variable is defined; e.g., $user->field_example has a
+ *     corresponding variable is defined; e.g., $account->field_example has a
  *     variable $field_example defined. When needing to access a field's raw
  *     values, developers/themers are strongly encouraged to use these
  *     variables. Otherwise they will have to explicitly specify the desired
- *     field language, e.g. $user->field_example['en'], thus overriding any
+ *     field language, e.g. $account->field_example['en'], thus overriding any
  *     language negotiation rule that was previously applied.
  *
  * @see user-profile-category.tpl.php
diff --git a/modules/user/user.module b/modules/user/user.module
index 5983b67..e09e774 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -211,19 +211,19 @@ function user_field_extra_fields() {
   $return['user']['user'] = array(
     'form' => array(
       'account' => array(
-        'label' => 'User name and password',
-        'description' => t('User module account form elements'),
+        'label' => t('User name and password'),
+        'description' => t('User module account form elements.'),
         'weight' => -10,
       ),
       'timezone' => array(
-        'label' => 'Timezone',
+        'label' => t('Timezone'),
         'description' => t('User module timezone form element.'),
         'weight' => 6,
       ),
     ),
     'display' => array(
       'summary' => array(
-        'label' => 'History',
+        'label' => t('History'),
         'description' => t('User module history view element.'),
         'weight' => 5,
       ),
diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
index 02e897e..3059823 100755
--- a/scripts/run-tests.sh
+++ b/scripts/run-tests.sh
@@ -67,6 +67,8 @@ if ($args['list']) {
   exit;
 }
 
+$test_list = simpletest_script_get_test_list();
+
 // Try to allocate unlimited time to run the tests.
 drupal_set_time_limit(0);
 
@@ -485,12 +487,13 @@ function simpletest_script_reporter_init() {
     echo "\n";
   }
 
-  echo "Test run started: " . format_date($_SERVER['REQUEST_TIME'], 'long') . "\n";
+  echo "Test run started:\n";
+  echo " " . format_date($_SERVER['REQUEST_TIME'], 'long') . "\n";
   timer_start('run-tests');
   echo "\n";
 
-  echo "Test summary:\n";
-  echo "-------------\n";
+  echo "Test summary\n";
+  echo "------------\n";
   echo "\n";
 }
 
@@ -571,7 +574,7 @@ function simpletest_script_reporter_timer_stop() {
   echo "\n";
   $end = timer_stop('run-tests');
   echo "Test run duration: " . format_interval($end['time'] / 1000);
-  echo "\n";
+  echo "\n\n";
 }
 
 /**
diff --git a/themes/garland/comment.tpl.php b/themes/garland/comment.tpl.php
index 900afc1..952cc01 100644
--- a/themes/garland/comment.tpl.php
+++ b/themes/garland/comment.tpl.php
@@ -6,7 +6,7 @@
 
     <span class="submitted"><?php print $submitted ?></span>
 
-  <?php if ($new) : ?>
+  <?php if ($new): ?>
     <span class="new"><?php print drupal_ucfirst($new) ?></span>
   <?php endif; ?>
 
