diff --git a/composer.lock b/composer.lock
index 32535367b..a406a5d05 100644
--- a/composer.lock
+++ b/composer.lock
@@ -2627,23 +2627,23 @@
         },
         {
             "name": "jcalderonzumba/mink-phantomjs-driver",
-            "version": "dev-master",
+            "version": "v0.3.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/jcalderonzumba/MinkPhantomJSDriver.git",
-                "reference": "10d7c48c9a4129463052321b52450d98983c4332"
+                "reference": "782892dbea4af7d04024374672b3790b6c008def"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/jcalderonzumba/MinkPhantomJSDriver/zipball/10d7c48c9a4129463052321b52450d98983c4332",
-                "reference": "10d7c48c9a4129463052321b52450d98983c4332",
+                "url": "https://api.github.com/repos/jcalderonzumba/MinkPhantomJSDriver/zipball/782892dbea4af7d04024374672b3790b6c008def",
+                "reference": "782892dbea4af7d04024374672b3790b6c008def",
                 "shasum": ""
             },
             "require": {
                 "behat/mink": "~1.6",
                 "jcalderonzumba/gastonjs": "~1.0",
                 "php": ">=5.4",
-                "twig/twig": "~1.8"
+                "twig/twig": "~1.20|~2.0"
             },
             "require-dev": {
                 "phpunit/phpunit": "~4.6",
@@ -2684,7 +2684,7 @@
                 "phantomjs",
                 "testing"
             ],
-            "time": "2015-10-05 18:24:44"
+            "time": "2015-12-04 13:55:02"
         },
         {
             "name": "mikey179/vfsStream",
@@ -3740,39 +3740,7 @@
     "aliases": [],
     "minimum-stability": "dev",
     "stability-flags": {
-        "php": 0,
-        "symfony/class-loader": 0,
-        "symfony/console": 0,
-        "symfony/dependency-injection": 0,
-        "symfony/event-dispatcher": 0,
-        "symfony/http-foundation": 0,
-        "symfony/http-kernel": 0,
-        "symfony/routing": 0,
-        "symfony/serializer": 0,
-        "symfony/translation": 0,
-        "symfony/validator": 0,
-        "symfony/process": 0,
-        "symfony/yaml": 0,
-        "twig/twig": 0,
-        "doctrine/common": 0,
-        "doctrine/annotations": 0,
-        "guzzlehttp/guzzle": 0,
-        "symfony-cmf/routing": 0,
-        "easyrdf/easyrdf": 0,
-        "zendframework/zend-feed": 0,
-        "stack/builder": 0,
-        "egulias/email-validator": 0,
-        "masterminds/html5": 0,
-        "symfony/psr-http-message-bridge": 0,
-        "zendframework/zend-diactoros": 0,
-        "composer/semver": 0,
-        "behat/mink": 0,
-        "behat/mink-goutte-driver": 0,
-        "jcalderonzumba/gastonjs": 20,
-        "jcalderonzumba/mink-phantomjs-driver": 20,
-        "mikey179/vfsstream": 0,
-        "phpunit/phpunit": 0,
-        "symfony/css-selector": 0
+        "jcalderonzumba/gastonjs": 20
     },
     "prefer-stable": true,
     "prefer-lowest": false,
diff --git a/core/CHANGELOG.txt b/core/CHANGELOG.txt
index 6b8e812d5..01a3dd484 100644
--- a/core/CHANGELOG.txt
+++ b/core/CHANGELOG.txt
@@ -341,7 +341,7 @@ Drupal 7.0, 2011-01-05
 - Improved time zone support:
     * Drupal now uses PHP's time zone database when rendering dates in local
       time. Site-wide and user-configured time zone offsets have been converted
-      to time zone names, e.g. Africa/Abidjan.
+      to time zone names; for example, Africa/Abidjan.
     * In some cases the upgrade and install scripts do not choose the preferred
       site default time zone. The automatically-selected time zone can be
       corrected at admin/config/regional/settings.
@@ -399,7 +399,7 @@ Drupal 7.0, 2011-01-05
       preserved but renamed to file_unmanaged_*().
     * Rewrote file handling to use PHP stream wrappers to enable support for
       both public and private files and to support pluggable storage mechanisms
-      and access to remote resources (e.g. S3 storage or Flickr photos).
+      and access to remote resources (for example, S3 storage or Flickr photos).
     * The mime_extension_mapping variable has been removed. Modules that need to
       alter the default MIME type extension mappings should implement
       hook_file_mimetype_mapping_alter().
@@ -816,7 +816,7 @@ Drupal 4.7.0, 2006-05-01
 - Added support for PHP5's 'mysqli' extension.
 - Search module:
     * Made indexer smarter and more robust.
-    * Added advanced search operators (e.g., phrase, node type, etc.).
+    * Added advanced search operators (phrase, node type, etc.).
     * Added customizable result ranking.
 - PostgreSQL support:
     * Removed dependency on PL/pgSQL procedural language.
diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt
index 1fa3118a6..18556e33e 100644
--- a/core/MAINTAINERS.txt
+++ b/core/MAINTAINERS.txt
@@ -87,7 +87,6 @@ Cron system
 
 CSS
 - John Albin Wilkins 'JohnAlbin' https://www.drupal.org/u/johnalbin
-- Lewis Nyman 'LewisNyman' https://www.drupal.org/u/lewisnyman
 
 Database system
 - Larry Garfield 'Crell' https://www.drupal.org/u/crell
@@ -486,7 +485,10 @@ Classy theme
 - Morten Birch Heide-Jørgensen 'mortendk' https://www.drupal.org/u/mortendk
 
 Seven theme
-- Lewis Nyman 'LewisNyman' https://www.drupal.org/u/lewisnyman
+- ?
+
+Stable theme
+- Scott Reeves 'Cottser' https://www.drupal.org/u/cottser
 
 Stark theme
 - John Albin Wilkins 'JohnAlbin' https://www.drupal.org/u/johnalbin
diff --git a/core/composer.json b/core/composer.json
index afb170ad5..1eabf49ea 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -35,7 +35,7 @@
     "behat/mink": "~1.6",
     "behat/mink-goutte-driver": "~1.2",
     "jcalderonzumba/gastonjs": "^1.1@dev",
-    "jcalderonzumba/mink-phantomjs-driver": "dev-master#10d7c48c9a4129463052321b52450d98983c4332",
+    "jcalderonzumba/mink-phantomjs-driver": "~0.3.1",
     "mikey179/vfsStream": "~1.2",
     "phpunit/phpunit": "~4.8",
     "symfony/css-selector": "2.7.*"
diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml
index 3edb8057a..4ab0fd769 100644
--- a/core/config/schema/core.data_types.schema.yml
+++ b/core/config/schema/core.data_types.schema.yml
@@ -87,12 +87,22 @@ color_hex:
 # Complex extended data types:
 
 # Root of a configuration object.
+
+_core_config_info:
+  type: mapping
+  mapping:
+    default_config_hash:
+      type: string
+      label: 'Default configuration hash'
+
 config_object:
   type: mapping
   mapping:
     langcode:
       type: string
       label: 'Language code'
+    _core:
+      type: _core_config_info
 
 # Mail text with subject and body parts.
 mail:
@@ -281,6 +291,8 @@ config_entity:
       label: 'Third party settings'
       sequence:
         type: '[%parent.%parent.%type].third_party.[%key]'
+    _core:
+      type: _core_config_info
 
 block_settings:
   type: mapping
diff --git a/core/core.api.php b/core/core.api.php
index 962a0c010..ef04faf2d 100644
--- a/core/core.api.php
+++ b/core/core.api.php
@@ -344,7 +344,7 @@
  *   Configuration entity classes expose dependencies by overriding the
  *   \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies()
  *   method.
- * - On routes for paths staring with '/admin' or otherwise designated as
+ * - On routes for paths starting with '/admin' or otherwise designated as
  *   administration paths (such as node editing when it is set as an admin
  *   operation), if they have configuration entity placeholders, configuration
  *   entities are normally loaded in their original language, without
@@ -567,7 +567,7 @@
  *
  * By default cached data is stored in the database. This can be configured
  * though so that all cached data, or that of an individual cache bin, uses a
- * different cache backend, such as APC or Memcache, for storage.
+ * different cache backend, such as APCu or Memcache, for storage.
  *
  * In a settings.php file, you can override the service used for a particular
  * cache bin. For example, if your service implementation of
@@ -692,7 +692,7 @@
  * "service" (such as accessing the database, sending email, or translating user
  * interface text) is defined (given a name and an interface or at least a
  * class that defines the methods that may be called), and a default class is
- * defined to provide the service. These two steps must be done together, and
+ * designated to provide the service. These two steps must be done together, and
  * can be done by Drupal Core or a module. Other modules can then define
  * alternative classes to provide the same services, overriding the default
  * classes. Classes and functions that need to use the service should always
@@ -843,6 +843,32 @@
  * @}
  */
 
+/**
+ * @defgroup listing_page_service Page header for Services page
+ * @{
+ * Introduction to services
+ *
+ * A "service" (such as accessing the database, sending email, or translating
+ * user interface text) can be defined by a module or Drupal core. Defining a
+ * service means giving it a name and designating a default class to provide the
+ * service; ideally, there should also be an interface that defines the methods
+ * that may be called. Services are collected into the Dependency Injection
+ * Container, and can be overridden to use different classes or different
+ * instantiation by modules. See the
+ * @link container Services and Dependency Injection Container topic @endlink
+ * for details.
+ *
+ * Some services have tags, which are defined in the service definition. Tags
+ * are used to define a group of related services, or to specify some aspect of
+ * how the service behaves. See the
+ * @link service_tag Service Tags topic @endlink for more information.
+ *
+ * @see container
+ * @see service_tag
+ *
+ * @}
+ */
+
 /**
  * @defgroup typed_data Typed Data API
  * @{
@@ -1441,6 +1467,38 @@
  * @}
  */
 
+/**
+ * @defgroup listing_page_class Page header for Classes page
+ * @{
+ * Introduction to classes
+ *
+ * A lot of the PHP code in Drupal is object oriented (OO), making use of
+ * @link http://php.net/manual/language.oop5.php PHP classes, interfaces, and traits. @endlink
+ * See the
+ * @link oo_conventions Objected-oriented programming conventions @endlink
+ * for more information.
+ *
+ * @see oo_conventions
+ *
+ * @}
+ */
+
+/**
+ * @defgroup listing_page_namespace Page header for Namespaces page
+ * @{
+ * Introduction to namespaces
+ *
+ * PHP classes, interfaces, and traits in Drupal are
+ * @link http://php.net/manual/en/language.namespaces.rationale.php namespaced. @endlink
+ * See the
+ * @link oo_conventions Objected-oriented programming conventions @endlink
+ * for more information.
+ *
+ * @see oo_conventions
+ *
+ * @}
+ */
+
 /**
  * @defgroup best_practices Best practices for developers
  * @{
@@ -1667,16 +1725,13 @@
  *     _form: '\Drupal\mymodule\Form\ExampleForm'
  * @endcode
  *
- * The $form argument to form-related functions is a structured array containing
- * the elements and properties of the form. For information on the array
- * components and format, and more detailed explanations of the Form API
- * workflow, see the
- * @link forms_api_reference.html Form API reference @endlink
- * and the
+ * The $form argument to form-related functions is a specialized render array
+ * containing the elements and properties of the form. For more about render
+ * arrays, see the @link theme_render Render API topic. @endlink For more
+ * detailed explanations of the Form API workflow, see the
  * @link https://www.drupal.org/node/2117411 Form API documentation section. @endlink
- * In addition, there is a set of Form API tutorials in
- * @link form_example_tutorial.inc the Form Example Tutorial @endlink which
- * provide basics all the way up through multistep forms.
+ * In addition, there is a set of Form API tutorials in the
+ * @link https://www.drupal.org/project/examples Examples for Developers project. @endlink
  *
  * In the form builder, validation, submission, and other form methods,
  * $form_state is the primary influence on the processing of the form and is
diff --git a/core/includes/batch.inc b/core/includes/batch.inc
index 6d0c8356c..a4b5378df 100644
--- a/core/includes/batch.inc
+++ b/core/includes/batch.inc
@@ -203,7 +203,7 @@ function _batch_progress_page() {
  * exceeded. It will continue with the next operation of the same batch set in
  * the next request.
  *
- * @return
+ * @return array
  *   An array containing a completion value (in percent) and a status message.
  */
 function _batch_process() {
@@ -337,15 +337,15 @@ function _batch_process() {
 /**
  * Formats the percent completion for a batch set.
  *
- * @param $total
+ * @param int $total
  *   The total number of operations.
- * @param $current
+ * @param int|float $current
  *   The number of the current operation. This may be a floating point number
  *   rather than an integer in the case of a multi-step operation that is not
  *   yet complete; in that case, the fractional part of $current represents the
  *   fraction of the operation that has been completed.
  *
- * @return
+ * @return string
  *   The properly formatted percentage, as a string. We output percentages
  *   using the correct number of decimal places so that we never print "100%"
  *   until we are finished, but we also never print more decimal places than
@@ -372,8 +372,9 @@ function &_batch_current_set() {
  * process and execute its form submit handler (if defined), which may add
  * further sets to this batch.
  *
- * @return
- *   TRUE if a subsequent set was found in the batch.
+ * @return true|null
+ *   TRUE if a subsequent set was found in the batch; no value will be returned
+ *   if no subsequent set was found.
  */
 function _batch_next_set() {
   $batch = &batch_get();
diff --git a/core/includes/database.inc b/core/includes/database.inc
index 477e8437a..ff03885a2 100644
--- a/core/includes/database.inc
+++ b/core/includes/database.inc
@@ -32,8 +32,8 @@ use Drupal\Core\Site\Settings;
  *   The prepared statement query to run. Although it will accept both named and
  *   unnamed placeholders, named placeholders are strongly preferred as they are
  *   more self-documenting. If the argument corresponding to a placeholder is
- *   an array of values to be expanded, e.g. for an IN query, the placeholder
- *   should be named with a trailing bracket like :example[]
+ *   an array of values to be expanded (for example, with an IN query), the
+ *   placeholder should be named with a trailing bracket like :example[].
  * @param array $args
  *   An array of values to substitute into the query. If the query uses named
  *   placeholders, this is an associative array in any order. If the query uses
@@ -47,7 +47,7 @@ use Drupal\Core\Site\Settings;
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call query() on it. E.g.
+ *   call query() on it. For example,
  *   $injected_database->query($query, $args, $options);
  *
  * @see \Drupal\Core\Database\Connection::query()
@@ -85,7 +85,7 @@ function db_query($query, array $args = array(), array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call queryRange() on it. E.g.
+ *   call queryRange() on it. For example,
  *   $injected_database->queryRange($query, $from, $count, $args, $options);
  *
  * @see \Drupal\Core\Database\Connection::queryRange()
@@ -121,7 +121,7 @@ function db_query_range($query, $from, $count, array $args = array(), array $opt
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call queryTemporary() on it. E.g.
+ *   call queryTemporary() on it. For example,
  *   $injected_database->queryTemporary($query, $args, $options);
  *
  * @see \Drupal\Core\Database\Connection::queryTemporary()
@@ -148,7 +148,8 @@ function db_query_temporary($query, array $args = array(), array $options = arra
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call insert() on it. E.g. $injected_database->insert($table, $options);
+ *   call insert() on it. For example,
+ *   $injected_database->insert($table, $options);
  *
  * @see \Drupal\Core\Database\Connection::insert()
  * @see \Drupal\Core\Database\Connection::defaultOptions()
@@ -173,7 +174,8 @@ function db_insert($table, array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call merge() on it. E.g. $injected_database->merge($table, $options);
+ *   call merge() on it. For example,
+ *   $injected_database->merge($table, $options);
  *
  * @see \Drupal\Core\Database\Connection::merge()
  * @see \Drupal\Core\Database\Connection::defaultOptions()
@@ -198,7 +200,8 @@ function db_merge($table, array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call update() on it. E.g. $injected_database->update($table, $options);
+ *   call update() on it. For example,
+ *   $injected_database->update($table, $options);
  *
  * @see \Drupal\Core\Database\Connection::update()
  * @see \Drupal\Core\Database\Connection::defaultOptions()
@@ -223,7 +226,8 @@ function db_update($table, array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call delete() on it. E.g. $injected_database->delete($table, $options);
+ *   call delete() on it. For example,
+ *   $injected_database->delete($table, $options);
  *
  * @see \Drupal\Core\Database\Connection::delete()
  * @see \Drupal\Core\Database\Connection::defaultOptions()
@@ -248,7 +252,8 @@ function db_delete($table, array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call truncate() on it. E.g. $injected_database->truncate($table, $options);
+ *   call truncate() on it. For example,
+ *   $injected_database->truncate($table, $options);
  *
  * @see \Drupal\Core\Database\Connection::truncate()
  * @see \Drupal\Core\Database\Connection::defaultOptions()
@@ -277,7 +282,7 @@ function db_truncate($table, array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call select() on it. E.g.
+ *   call select() on it. For example,
  *   $injected_database->select($table, $alias, $options);
  *
  * @see \Drupal\Core\Database\Connection::select()
@@ -304,7 +309,7 @@ function db_select($table, $alias = NULL, array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call startTransaction() on it. E.g.
+ *   call startTransaction() on it. For example,
  *   $injected_database->startTransaction($name);
  *
  * @see \Drupal\Core\Database\Connection::startTransaction()
@@ -346,7 +351,8 @@ function db_set_active($key = 'default') {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call escapeTable() on it. E.g. $injected_database->escapeTable($table);
+ *   call escapeTable() on it. For example,
+ *   $injected_database->escapeTable($table);
  *
  * @see \Drupal\Core\Database\Connection::escapeTable()
  */
@@ -367,7 +373,8 @@ function db_escape_table($table) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call escapeTable() on it. E.g. $injected_database->escapeTable($table);
+ *   call escapeTable() on it. For example,
+ *   $injected_database->escapeTable($table);
  *
  * @see \Drupal\Core\Database\Connection::escapeField()
  */
@@ -407,7 +414,8 @@ function db_escape_field($field) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call escapeLike() on it. E.g. $injected_database->escapeLike($string);
+ *   call escapeLike() on it. For example,
+ *   $injected_database->escapeLike($string);
  *
  * @see \Drupal\Core\Database\Connection::escapeLike()
  */
@@ -423,7 +431,7 @@ function db_like($string) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call driver() on it. E.g. $injected_database->driver($string);
+ *   call driver() on it. For example, $injected_database->driver($string);
  *
  * @see \Drupal\Core\Database\Connection::driver()
  */
@@ -467,7 +475,7 @@ function db_close(array $options = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container and
- *   call nextId() on it. E.g. $injected_database->nextId($existing_id);
+ *   call nextId() on it. For example, $injected_database->nextId($existing_id);
  *
  * @see \Drupal\Core\Database\Connection::nextId()
  */
@@ -565,7 +573,7 @@ function db_condition($conjunction) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call createTable() on it. E.g.
+ *   its schema driver, and call createTable() on it. For example,
  *   $injected_database->schema()->createTable($name, $table);
  *
  * @see \Drupal\Core\Database\Schema::createTable()
@@ -588,7 +596,7 @@ function db_create_table($name, $table) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call fieldNames() on it. E.g.
+ *   its schema driver, and call fieldNames() on it. For example,
  *   $injected_database->schema()->fieldNames($fields);
  *
  * @see \Drupal\Core\Database\Schema::fieldNames()
@@ -610,7 +618,7 @@ function db_field_names($fields) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call indexExists() on it. E.g.
+ *   its schema driver, and call indexExists() on it. For example,
  *   $injected_database->schema()->indexExists($table, $name);
  *
  * @see \Drupal\Core\Database\Schema::indexExists()
@@ -630,7 +638,7 @@ function db_index_exists($table, $name) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call tableExists() on it. E.g.
+ *   its schema driver, and call tableExists() on it. For example,
  *   $injected_database->schema()->tableExists($table);
  *
  * @see \Drupal\Core\Database\Schema::tableExists()
@@ -652,7 +660,7 @@ function db_table_exists($table) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call fieldExists() on it. E.g.
+ *   its schema driver, and call fieldExists() on it. For example,
  *   $injected_database->schema()->fieldExists($table, $field);
  *
  * @see \Drupal\Core\Database\Schema::fieldExists()
@@ -672,7 +680,7 @@ function db_field_exists($table, $field) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call findTables() on it. E.g.
+ *   its schema driver, and call findTables() on it. For example,
  *   $injected_database->schema()->findTables($table_expression);
  *
  * @see \Drupal\Core\Database\Schema::findTables()
@@ -691,7 +699,7 @@ function db_find_tables($table_expression) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call renameTable() on it. E.g.
+ *   its schema driver, and call renameTable() on it. For example,
  *   $injected_database->schema()->renameTable($table, $new_name);
  *
  * @see \Drupal\Core\Database\Schema::renameTable()
@@ -708,7 +716,7 @@ function db_rename_table($table, $new_name) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call dropTable() on it. E.g.
+ *   its schema driver, and call dropTable() on it. For example,
  *   $injected_database->schema()->dropTable($table);
  *
  * @see \Drupal\Core\Database\Schema::dropTable()
@@ -738,7 +746,7 @@ function db_drop_table($table) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call addField() on it. E.g.
+ *   its schema driver, and call addField() on it. For example,
  *   $injected_database->schema()->addField($table, $field, $spec, $keys_new);
  *
  * @see \Drupal\Core\Database\Schema::addField()
@@ -762,7 +770,7 @@ function db_add_field($table, $field, $spec, $keys_new = array()) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call dropField() on it. E.g.
+ *   its schema driver, and call dropField() on it. For example,
  *   $injected_database->schema()->dropField($table, $field);
  *
  * @see \Drupal\Core\Database\Schema::dropField()
@@ -783,7 +791,7 @@ function db_drop_field($table, $field) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call fieldSetDefault() on it. E.g.
+ *   its schema driver, and call fieldSetDefault() on it. For example,
  *   $injected_database->schema()->fieldSetDefault($table, $field, $default);
  *
  * @see \Drupal\Core\Database\Schema::fieldSetDefault()
@@ -802,7 +810,7 @@ function db_field_set_default($table, $field, $default) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call fieldSetNoDefault() on it. E.g.
+ *   its schema driver, and call fieldSetNoDefault() on it. For example,
  *   $injected_database->schema()->fieldSetNoDefault($table, $field);
  *
  * @see \Drupal\Core\Database\Schema::fieldSetNoDefault()
@@ -821,7 +829,7 @@ function db_field_set_no_default($table, $field) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call addPrimaryKey() on it. E.g.
+ *   its schema driver, and call addPrimaryKey() on it. For example,
  *   $injected_database->schema()->addPrimaryKey($table, $fields);
  *
  * @see \Drupal\Core\Database\Schema::addPrimaryKey()
@@ -842,7 +850,7 @@ function db_add_primary_key($table, $fields) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call dropPrimaryKey() on it. E.g.
+ *   its schema driver, and call dropPrimaryKey() on it. For example,
  *   $injected_database->schema()->dropPrimaryKey($table);
  *
  * @see \Drupal\Core\Database\Schema::dropPrimaryKey()
@@ -863,7 +871,7 @@ function db_drop_primary_key($table) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call addUniqueKey() on it. E.g.
+ *   its schema driver, and call addUniqueKey() on it. For example,
  *   $injected_database->schema()->addUniqueKey($table, $name, $fields);
  *
  * @see \Drupal\Core\Database\Schema::addUniqueKey()
@@ -886,7 +894,7 @@ function db_add_unique_key($table, $name, $fields) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call dropUniqueKey() on it. E.g.
+ *   its schema driver, and call dropUniqueKey() on it. For example,
  *   $injected_database->schema()->dropUniqueKey($table, $name);
  *
  * @see \Drupal\Core\Database\Schema::dropUniqueKey()
@@ -911,7 +919,7 @@ function db_drop_unique_key($table, $name) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call addIndex() on it. E.g.
+ *   its schema driver, and call addIndex() on it. For example,
  *   $injected_database->schema()->addIndex($table, $name, $fields, $spec);
  *
  * @see hook_schema()
@@ -936,7 +944,7 @@ function db_add_index($table, $name, $fields, array $spec) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call dropIndex() on it. E.g.
+ *   its schema driver, and call dropIndex() on it. For example,
  *   $injected_database->schema()->dropIndex($table, $name);
  *
  * @see \Drupal\Core\Database\Schema::dropIndex()
@@ -1007,7 +1015,7 @@ function db_drop_index($table, $name) {
  *
  * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
  *   a database connection injected into your service from the container, get
- *   its schema driver, and call changeField() on it. E.g.
+ *   its schema driver, and call changeField() on it. For example,
  *   $injected_database->schema()->changeField($table, $field, $field_new, $spec, $keys_new);
  *
  * @see \Drupal\Core\Database\Schema::changeField()
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 5da67fb07..769e34cf5 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -727,7 +727,8 @@ function template_preprocess_links(&$variables) {
  *     to an empty string, but can be set to NULL for the attribute to be
  *     omitted. Usually, neither omission nor an empty string satisfies
  *     accessibility requirements, so it is strongly encouraged for code
- *     calling _theme('image') to pass a meaningful value for this variable.
+ *     building variables for image.html.twig templates to pass a meaningful
+ *     value for this variable.
  *     - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
  *     - http://www.w3.org/TR/xhtml1/dtds.html
  *     - http://dev.w3.org/html5/spec/Overview.html#alt
@@ -1519,7 +1520,7 @@ function template_preprocess_field(&$variables, $hook) {
   }
 
   // Merge attributes when a single-value field has a hidden label.
-  if ($element['#label_display'] == 'hidden' && !$variables['multiple']) {
+  if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && !empty($element['#items'][0]->_attributes)) {
     $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], (array) $element['#items'][0]->_attributes);
   }
 
@@ -1721,11 +1722,12 @@ function drupal_common_theme() {
     'image' => array(
       // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
       // allows the alt attribute to be omitted in some cases. Therefore,
-      // default the alt attribute to an empty string, but allow code calling
-      // _theme('image') to pass explicit NULL for it to be omitted. Usually,
-      // neither omission nor an empty string satisfies accessibility
-      // requirements, so it is strongly encouraged for code calling
-      // _theme('image') to pass a meaningful value for the alt variable.
+      // default the alt attribute to an empty string, but allow code providing
+      // variables to image.html.twig templates to pass explicit NULL for it to
+      // be omitted. Usually, neither omission nor an empty string satisfies
+      // accessibility requirements, so it is strongly encouraged for code
+      // building variables for image.html.twig templates to pass a meaningful
+      // value for the alt variable.
       // - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
       // - http://www.w3.org/TR/xhtml1/dtds.html
       // - http://dev.w3.org/html5/spec/Overview.html#alt
@@ -1765,7 +1767,7 @@ function drupal_common_theme() {
       'render element' => 'page',
     ),
     'maintenance_task_list' => array(
-      'variables' => array('items' => NULL, 'active' => NULL,  'variant' => NULL),
+      'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
     ),
     'authorize_report' => array(
       'variables' => ['messages' => [], 'attributes' => []],
diff --git a/core/install.php b/core/install.php
index 5940fbebe..b70cec530 100644
--- a/core/install.php
+++ b/core/install.php
@@ -26,6 +26,11 @@ if (version_compare(PHP_VERSION, '5.5.9') < 0) {
   exit;
 }
 
+if (function_exists('opcache_get_status') && opcache_get_status()['opcache_enabled'] && !ini_get('opcache.save_comments')) {
+  print 'Systems with OPcache installed must have <a href="http://php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments">opcache.save_comments</a> enabled.';
+  exit();
+}
+
 // Start the installer.
 $class_loader = require_once 'autoload.php';
 require_once __DIR__ . '/includes/install.core.inc';
diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php
index b955142c7..8a7ddb0e1 100644
--- a/core/lib/Drupal.php
+++ b/core/lib/Drupal.php
@@ -63,8 +63,8 @@ use Drupal\Core\Url;
  *   class StuffDoingClass implements StuffDoingInterface {
  *     protected $lockBackend;
  *
- *     public function __construct(LockBackendInterface $lockBackend) {
- *       $this->lockBackend = $lockBackend;
+ *     public function __construct(LockBackendInterface $lock_backend) {
+ *       $this->lockBackend = $lock_backend;
  *     }
  *
  *     public function doStuff() {
@@ -81,7 +81,7 @@ class Drupal {
   /**
    * The current system version.
    */
-  const VERSION = '8.0.1';
+  const VERSION = '8.0.2';
 
   /**
    * Core API compatibility.
@@ -423,11 +423,11 @@ class Drupal {
    * Returns the entity query object for this entity type.
    *
    * @param string $entity_type
-   *   The entity type, e.g. node, for which the query object should be
+   *   The entity type (for example, node) for which the query object should be
    *   returned.
    * @param string $conjunction
-   *   AND if all conditions in the query need to apply, OR if any of them is
-   *   enough. Optional, defaults to AND.
+   *   (optional) Either 'AND' if all conditions in the query need to apply, or
+   *   'OR' if any of them is sufficient. Defaults to 'AND'.
    *
    * @return \Drupal\Core\Entity\Query\QueryInterface
    *   The query object that can query the given entity type.
@@ -440,11 +440,11 @@ class Drupal {
    * Returns the entity query aggregate object for this entity type.
    *
    * @param string $entity_type
-   *   The entity type, e.g. node, for which the query object should be
+   *   The entity type (for example, node) for which the query object should be
    *   returned.
    * @param string $conjunction
-   *   AND if all conditions in the query need to apply, OR if any of them is
-   *   enough. Optional, defaults to AND.
+   *   (optional) Either 'AND' if all conditions in the query need to apply, or
+   *   'OR' if any of them is sufficient. Defaults to 'AND'.
    *
    * @return \Drupal\Core\Entity\Query\QueryAggregateInterface
    *   The query object that can query the given entity type.
diff --git a/core/lib/Drupal/Component/FileCache/ApcuFileCacheBackend.php b/core/lib/Drupal/Component/FileCache/ApcuFileCacheBackend.php
index 25b609750..b82e1acfe 100644
--- a/core/lib/Drupal/Component/FileCache/ApcuFileCacheBackend.php
+++ b/core/lib/Drupal/Component/FileCache/ApcuFileCacheBackend.php
@@ -16,21 +16,21 @@ class ApcuFileCacheBackend implements FileCacheBackendInterface {
    * {@inheritdoc}
    */
   public function fetch(array $cids) {
-    return apc_fetch($cids);
+    return apcu_fetch($cids);
   }
 
   /**
    * {@inheritdoc}
    */
   public function store($cid, $data) {
-    apc_store($cid, $data);
+    apcu_store($cid, $data);
   }
 
   /**
    * {@inheritdoc}
    */
   public function delete($cid) {
-    apc_delete($cid);
+    apcu_delete($cid);
   }
 
 }
diff --git a/core/lib/Drupal/Component/Gettext/PoHeader.php b/core/lib/Drupal/Component/Gettext/PoHeader.php
index aa8ea201e..ebd366ffb 100644
--- a/core/lib/Drupal/Component/Gettext/PoHeader.php
+++ b/core/lib/Drupal/Component/Gettext/PoHeader.php
@@ -471,10 +471,10 @@ class PoHeader {
    *
    * @param array $element_stack
    *   Array of plural formula values and operators create by parseArithmetic().
-   * @param integer $n
+   * @param int $n
    *   The @count number for which we are determining the right plural position.
    *
-   * @return integer
+   * @return int
    *   Number of the plural string to be used for the given plural value.
    *
    * @see parseArithmetic()
diff --git a/core/lib/Drupal/Component/Utility/Number.php b/core/lib/Drupal/Component/Utility/Number.php
index 453ed4aba..99bedc873 100644
--- a/core/lib/Drupal/Component/Utility/Number.php
+++ b/core/lib/Drupal/Component/Utility/Number.php
@@ -21,11 +21,11 @@ class Number {
    *
    * This is based on the number/range verification methods of webkit.
    *
-   * @param numeric $value
+   * @param float $value
    *   The value that needs to be checked.
-   * @param numeric $step
+   * @param float $step
    *   The step scale factor. Must be positive.
-   * @param numeric $offset
+   * @param float $offset
    *   (optional) An offset, to which the difference must be a multiple of the
    *   given step.
    *
diff --git a/core/lib/Drupal/Component/Utility/OpCodeCache.php b/core/lib/Drupal/Component/Utility/OpCodeCache.php
index 90b28e7ec..576f3bd03 100644
--- a/core/lib/Drupal/Component/Utility/OpCodeCache.php
+++ b/core/lib/Drupal/Component/Utility/OpCodeCache.php
@@ -30,16 +30,6 @@ class OpCodeCache {
     if (function_exists('opcache_invalidate')) {
       opcache_invalidate($pathname, TRUE);
     }
-    // If apcu extension is enabled in PHP 5.5 or greater it emulates apc.
-    // This is to provide an easy upgrade path if you are using apc's user
-    // caching however the emulation does not extend to opcode caching.
-    // Therefore we need to check if the function exists as well.
-    if (extension_loaded('apc') && function_exists('apc_delete_file')) {
-      // apc_delete_file() throws a PHP warning in case the specified file was
-      // not compiled yet.
-      // @see http://php.net/manual/en/function.apc-delete-file.php
-      @apc_delete_file($pathname);
-    }
   }
 
 }
diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php
index 1763c2361..9166b34a5 100644
--- a/core/lib/Drupal/Component/Utility/UrlHelper.php
+++ b/core/lib/Drupal/Component/Utility/UrlHelper.php
@@ -36,10 +36,11 @@ class UrlHelper {
    *   http_build_query() directly.
    *
    * @param array $query
-   *   The query parameter array to be processed,
-   *   e.g. \Drupal::request()->query->all().
+   *   The query parameter array to be processed; for instance,
+   *   \Drupal::request()->query->all().
    * @param string $parent
-   *   Internal use only. Used to build the $query array key for nested items.
+   *   (optional) Internal use only. Used to build the $query array key for
+   *   nested items. Defaults to an empty string.
    *
    * @return string
    *   A rawurlencoded string which can be used as or appended to the URL query
@@ -168,8 +169,8 @@ class UrlHelper {
     }
     // Internal URLs.
     else {
-      // parse_url() does not support relative URLs, so make it absolute. E.g. the
-      // relative URL "foo/bar:1" isn't properly parsed.
+      // parse_url() does not support relative URLs, so make it absolute. For
+      // instance, the relative URL "foo/bar:1" isn't properly parsed.
       $parts = parse_url('http://example.com/' . $url);
       // Strip the leading slash that was just added.
       $options['path'] = substr($parts['path'], 1);
@@ -200,10 +201,11 @@ class UrlHelper {
   }
 
   /**
-   * Determines whether a path is external to Drupal (e.g. http://example.com).
+   * Determines whether a path is external to Drupal.
    *
-   * If a path cannot be assessed by Drupal's menu handler, then we must
-   * treat it as potentially insecure.
+   * An example of an external path is http://example.com. If a path cannot be
+   * assessed by Drupal's menu handler, then we must treat it as potentially
+   * insecure.
    *
    * @param string $path
    *   The internal path or external URL being linked to, such as "node/34" or
@@ -296,7 +298,7 @@ class UrlHelper {
   }
 
   /**
-   * Strips dangerous protocols (e.g. 'javascript:') from a URI.
+   * Strips dangerous protocols (for example, 'javascript:') from a URI.
    *
    * This function must be called for all URIs within user-entered input prior
    * to being output to an HTML attribute value. It is often called as part of
@@ -316,8 +318,8 @@ class UrlHelper {
    *   for well-formed URLs will be invoked, which strips most substrings that
    *   precede a ":". The result can be used in URL attributes such as "href"
    *   or "src" (only after calling Html::escape() separately), but this may not
-   *   produce valid HTML (e.g., malformed URLs within "href" attributes fail
-   *   HTML validation). This can be avoided by using
+   *   produce valid HTML (for example, malformed URLs within "href" attributes
+   *   fail HTML validation). This can be avoided by using
    *   Url::fromUri($possibly_not_a_url)->toString(), which either throws an
    *   exception or returns a well-formed URL.
    *
diff --git a/core/lib/Drupal/Core/Access/CustomAccessCheck.php b/core/lib/Drupal/Core/Access/CustomAccessCheck.php
index fb2ccddb4..3722d2328 100644
--- a/core/lib/Drupal/Core/Access/CustomAccessCheck.php
+++ b/core/lib/Drupal/Core/Access/CustomAccessCheck.php
@@ -55,6 +55,8 @@ class CustomAccessCheck implements RoutingAccessInterface {
   /**
    * Checks access for the account and route using the custom access checker.
    *
+   * @param \Symfony\Component\Routing\Route $route
+   *   The route.
    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
    *   The route match object to be checked.
    * @param \Drupal\Core\Session\AccountInterface $account
diff --git a/core/lib/Drupal/Core/Annotation/QueueWorker.php b/core/lib/Drupal/Core/Annotation/QueueWorker.php
index 85a2296fd..89150c5d2 100644
--- a/core/lib/Drupal/Core/Annotation/QueueWorker.php
+++ b/core/lib/Drupal/Core/Annotation/QueueWorker.php
@@ -10,18 +10,21 @@ namespace Drupal\Core\Annotation;
 use Drupal\Component\Annotation\Plugin;
 
 /**
- * Declare queue workers that need to be run periodically.
+ * Declare a worker class for processing a queue item.
  *
- * While there can be only one hook_cron() process running at the same time,
- * there can be any number of processes defined here running. Because of
- * this, long running tasks are much better suited for this API. Items queued
- * in hook_cron() might be processed in the same cron run if there are not many
- * items in the queue, otherwise it might take several requests, which can be
- * run in parallel.
+ * Worker plugins are used by some queues for processing the individual items
+ * in the queue. In that case, the ID of the worker plugin needs to match the
+ * machine name of a queue, so that you can retrieve the queue back end by
+ * calling \Drupal\Core\Queue\QueueFactory::get($plugin_id).
  *
- * You can create queues, add items to them, claim them, etc. without using a
- * QueueWorker plugin if you want, however, you need to take care of processing
- * the items in the queue in that case. See \Drupal\Core\Cron for an example.
+ * \Drupal\Core\Cron::processQueues() processes queues that use workers; they
+ * can also be processed outside of the cron process.
+ *
+ * Some queues do not use worker plugins: you can create queues, add items to
+ * them, claim them, etc. without using a QueueWorker plugin. However, you will
+ * need to take care of processing the items in the queue in that case. You can
+ * look at \Drupal\Core\Cron::processQueues() for an example of how to process
+ * a queue that uses workers, and adapt it to your queue.
  *
  * Plugin Namespace: Plugin\QueueWorker
  *
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php
index a4ec33615..a5a0ad3a8 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php
@@ -51,14 +51,14 @@ class LibraryDiscoveryCollector extends CacheCollector {
   /**
    * Constructs a CacheCollector object.
    *
-   * @param string $cid
-   *   The cid for the array being cached.
    * @param \Drupal\Core\Cache\CacheBackendInterface $cache
    *   The cache backend.
    * @param \Drupal\Core\Lock\LockBackendInterface $lock
    *   The lock backend.
    * @param \Drupal\Core\Asset\LibraryDiscoveryParser $discovery_parser
    *   The library discovery parser.
+   * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
+   *   The theme manager.
    */
   public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, LibraryDiscoveryParser $discovery_parser, ThemeManagerInterface $theme_manager) {
     $this->themeManager = $theme_manager;
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 9d6e796e9..f25b7b03b 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -50,6 +50,8 @@ class LibraryDiscoveryParser {
    *   The app root.
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    *   The module handler.
+   * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
+   *   The theme manager.
    */
   public function __construct($root, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) {
     $this->root = $root;
diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationProviderFilterInterface.php b/core/lib/Drupal/Core/Authentication/AuthenticationProviderFilterInterface.php
index 99f8e1050..002d5204b 100644
--- a/core/lib/Drupal/Core/Authentication/AuthenticationProviderFilterInterface.php
+++ b/core/lib/Drupal/Core/Authentication/AuthenticationProviderFilterInterface.php
@@ -13,8 +13,9 @@ use Symfony\Component\HttpFoundation\Request;
  * Restrict authentication methods to a subset of the site.
  *
  * Some authentication methods should not be available throughout a whole site.
- * E.g., there are good reasons to restrict insecure methods like HTTP basic
- * auth or an URL token authentication method to API-only routes.
+ * For instance, there are good reasons to restrict insecure methods like HTTP
+ * basic authentication or an URL token authentication method to API-only
+ * routes.
  */
 interface AuthenticationProviderFilterInterface {
 
diff --git a/core/lib/Drupal/Core/Cache/Apcu4Backend.php b/core/lib/Drupal/Core/Cache/Apcu4Backend.php
new file mode 100644
index 000000000..537d5848e
--- /dev/null
+++ b/core/lib/Drupal/Core/Cache/Apcu4Backend.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Cache\Apcu4Backend.
+ */
+
+namespace Drupal\Core\Cache;
+
+/**
+ * Stores cache items in the Alternative PHP Cache User Cache (APCu).
+ *
+ * This class is used with APCu versions >= 4.0.0 and < 5.0.0.
+ */
+class Apcu4Backend extends ApcuBackend {
+
+  /**
+   * {@inheritdoc}
+   *
+   * @return \APCIterator
+   */
+  protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE) {
+    return new \APCIterator('user', $search, $format, $chunk_size, $list);
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php
index b64fd7177..4d7a4d765 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackend.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php
@@ -60,7 +60,7 @@ class ApcuBackend implements CacheBackendInterface {
   }
 
   /**
-   * Prepends the APC user variable prefix for this bin to a cache item ID.
+   * Prepends the APCu user variable prefix for this bin to a cache item ID.
    *
    * @param string $cid
    *   The cache item ID to prefix.
@@ -76,7 +76,7 @@ class ApcuBackend implements CacheBackendInterface {
    * {@inheritdoc}
    */
   public function get($cid, $allow_invalid = FALSE) {
-    $cache = apc_fetch($this->getApcuKey($cid));
+    $cache = apcu_fetch($this->getApcuKey($cid));
     return $this->prepareItem($cache, $allow_invalid);
   }
 
@@ -90,7 +90,7 @@ class ApcuBackend implements CacheBackendInterface {
       $map[$this->getApcuKey($cid)] = $cid;
     }
 
-    $result = apc_fetch(array_keys($map));
+    $result = apcu_fetch(array_keys($map));
     $cache = array();
     if ($result) {
       foreach ($result as $key => $item) {
@@ -112,18 +112,18 @@ class ApcuBackend implements CacheBackendInterface {
    * APCu is a memory cache, shared across all server processes. To prevent
    * cache item clashes with other applications/installations, every cache item
    * is prefixed with a unique string for this site. Therefore, functions like
-   * apc_clear_cache() cannot be used, and instead, a list of all cache items
+   * apcu_clear_cache() cannot be used, and instead, a list of all cache items
    * belonging to this application need to be retrieved through this method
    * instead.
    *
    * @param string $prefix
    *   (optional) A cache ID prefix to limit the result to.
    *
-   * @return \APCIterator
-   *   An APCIterator containing matched items.
+   * @return \APCUIterator
+   *   An APCUIterator containing matched items.
    */
   protected function getAll($prefix = '') {
-    return new \APCIterator('user', '/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
+    return $this->getIterator('/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
   }
 
   /**
@@ -174,12 +174,12 @@ class ApcuBackend implements CacheBackendInterface {
     $cache->expire = $expire;
     $cache->tags = implode(' ', $tags);
     $cache->checksum = $this->checksumProvider->getCurrentChecksum($tags);
-    // APC serializes/unserializes any structure itself.
+    // APCu serializes/unserializes any structure itself.
     $cache->serialized = 0;
     $cache->data = $data;
 
     // Expiration is handled by our own prepareItem(), not APCu.
-    apc_store($this->getApcuKey($cid), $cache);
+    apcu_store($this->getApcuKey($cid), $cache);
   }
 
   /**
@@ -195,35 +195,35 @@ class ApcuBackend implements CacheBackendInterface {
    * {@inheritdoc}
    */
   public function delete($cid) {
-    apc_delete($this->getApcuKey($cid));
+    apcu_delete($this->getApcuKey($cid));
   }
 
   /**
    * {@inheritdoc}
    */
   public function deleteMultiple(array $cids) {
-    apc_delete(array_map(array($this, 'getApcuKey'), $cids));
+    apcu_delete(array_map(array($this, 'getApcuKey'), $cids));
   }
 
   /**
    * {@inheritdoc}
    */
   public function deleteAll() {
-    apc_delete(new \APCIterator('user', '/^' . preg_quote($this->binPrefix, '/') . '/'));
+    apcu_delete($this->getIterator('/^' . preg_quote($this->binPrefix, '/') . '/'));
   }
 
   /**
    * {@inheritdoc}
    */
   public function garbageCollection() {
-    // APC performs garbage collection automatically.
+    // APCu performs garbage collection automatically.
   }
 
   /**
    * {@inheritdoc}
    */
   public function removeBin() {
-    apc_delete(new \APCIterator('user', '/^' . preg_quote($this->binPrefix, '/') . '/'));
+    apcu_delete($this->getIterator('/^' . preg_quote($this->binPrefix, '/') . '/'));
   }
 
   /**
@@ -252,4 +252,25 @@ class ApcuBackend implements CacheBackendInterface {
     }
   }
 
+  /**
+   * Instantiates and returns the APCUIterator class.
+   *
+   * @param mixed $search
+   *   A PCRE regular expression that matches against APC key names, either as a
+   *   string for a single regular expression, or as an array of regular
+   *   expressions. Or, optionally pass in NULL to skip the search.
+   * @param int $format
+   *   The desired format, as configured with one or more of the APC_ITER_*
+   *   constants.
+   * @param int $chunk_size
+   *   The chunk size. Must be a value greater than 0. The default value is 100.
+   * @param int $list
+   *   The type to list. Either pass in APC_LIST_ACTIVE or APC_LIST_DELETED.
+   *
+   * @return \APCUIterator
+   */
+  protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE) {
+    return new \APCUIterator($search, $format, $chunk_size, $list);
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php b/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php
index f744edc25..dae24dcfa 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackendFactory.php
@@ -25,6 +25,13 @@ class ApcuBackendFactory implements CacheFactoryInterface {
    */
   protected $checksumProvider;
 
+  /**
+   * The APCU backend class to use.
+   *
+   * @var string
+   */
+  protected $backendClass;
+
   /**
    * Constructs an ApcuBackendFactory object.
    *
@@ -38,6 +45,12 @@ class ApcuBackendFactory implements CacheFactoryInterface {
   public function __construct($root, $site_path, CacheTagsChecksumInterface $checksum_provider) {
     $this->sitePrefix = Settings::getApcuPrefix('apcu_backend', $root, $site_path);
     $this->checksumProvider = $checksum_provider;
+    if (version_compare(phpversion('apcu'), '5.0.0', '>=')) {
+      $this->backendClass = 'Drupal\Core\Cache\ApcuBackend';
+    }
+    else {
+      $this->backendClass = 'Drupal\Core\Cache\Apcu4Backend';
+    }
   }
 
   /**
@@ -50,7 +63,7 @@ class ApcuBackendFactory implements CacheFactoryInterface {
    *   The cache backend object for the specified cache bin.
    */
   public function get($bin) {
-    return new ApcuBackend($bin, $this->sitePrefix, $this->checksumProvider);
+    return new $this->backendClass($bin, $this->sitePrefix, $this->checksumProvider);
   }
 
 }
diff --git a/core/lib/Drupal/Core/Cache/CacheFactory.php b/core/lib/Drupal/Core/Cache/CacheFactory.php
index a8a5c41ea..a5acf7c84 100644
--- a/core/lib/Drupal/Core/Cache/CacheFactory.php
+++ b/core/lib/Drupal/Core/Cache/CacheFactory.php
@@ -14,7 +14,7 @@ use Drupal\Core\Site\Settings;
 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 
-class CacheFactory implements CacheFactoryInterface,  ContainerAwareInterface {
+class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
 
   use ContainerAwareTrait;
 
diff --git a/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php b/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php
index 0bca8d1fc..c43085e1f 100644
--- a/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php
@@ -17,9 +17,9 @@ interface CacheableResponseInterface {
   /**
    * Adds a dependency on an object: merges its cacheability metadata.
    *
-   * E.g. when a response depends on some configuration, an entity, or an access
-   * result, we must make sure their cacheability metadata is present on the
-   * response. This method makes doing that simple.
+   * For instance, when a response depends on some configuration, an entity, or
+   * an access result, we must make sure their cacheability metadata is present
+   * on the response. This method makes doing that simple.
    *
    * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
    *   The dependency. If the object implements CacheableDependencyInterface,
diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php
index bba9d9409..ca38ca0be 100644
--- a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php
+++ b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php
@@ -53,7 +53,7 @@ class ChainedFastBackendFactory implements CacheFactoryInterface {
     }
 
     // Default the fast backend to APCu if it's available.
-    if (!isset($fast_service_name) && function_exists('apc_fetch')) {
+    if (!isset($fast_service_name) && function_exists('apcu_fetch')) {
       $fast_service_name = 'cache.backend.apcu';
     }
 
diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
index 81d67350a..c8752716c 100644
--- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
+++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
@@ -92,9 +92,10 @@ class CacheContextsManager {
    *
    * A cache context token is either:
    * - a cache context ID (if the service ID is 'cache_context.foo', then 'foo'
-   *   is a cache context ID), e.g. 'foo'
-   * - a calculated cache context ID, followed by a double colon, followed by
-   *   the parameter for the calculated cache context, e.g. 'bar:some_parameter'
+   *   is a cache context ID); for example, 'foo'.
+   * - a calculated cache context ID, followed by a colon, followed by
+   *   the parameter for the calculated cache context; for example,
+   *   'bar:some_parameter'.
    *
    * @param string[] $context_tokens
    *   An array of cache context tokens.
@@ -142,11 +143,12 @@ class CacheContextsManager {
    * If a cache context is being optimized away, it is able to set cacheable
    * metadata for itself which will be bubbled up.
    *
-   * E.g. when caching per user ('user'), also caching per role ('user.roles')
-   * is meaningless because "per role" is implied by "per user".
+   * For example, when caching per user ('user'), also caching per role
+   * ('user.roles') is meaningless because "per role" is implied by "per user".
    *
-   * Examples — remember that the period indicates hierarchy and the colon can
-   * be used to get a specific value of a calculated cache context:
+   * In the following examples, remember that the period indicates hierarchy and
+   * the colon can be used to get a specific value of a calculated cache
+   * context:
    * - ['a', 'a.b'] -> ['a']
    * - ['a', 'a.b.c'] -> ['a']
    * - ['a.b', 'a.b.c'] -> ['a.b']
diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php
index 96cc00e0a..a351c7029 100644
--- a/core/lib/Drupal/Core/Condition/ConditionManager.php
+++ b/core/lib/Drupal/Core/Condition/ConditionManager.php
@@ -49,7 +49,7 @@ class ConditionManager extends DefaultPluginManager implements ExecutableManager
   }
 
   /**
-   * Override of Drupal\Component\Plugin\PluginManagerBase::createInstance().
+   * {@inheritdoc}
    */
   public function createInstance($plugin_id, array $configuration = array()) {
     $plugin = $this->getFactory()->createInstance($plugin_id, $configuration);
diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php
index ae12c9186..a77bb1c2f 100644
--- a/core/lib/Drupal/Core/Config/ConfigInstaller.php
+++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Config;
 
+use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Config\Entity\ConfigDependencyManager;
 use Drupal\Core\Config\Entity\ConfigEntityDependency;
@@ -279,6 +280,12 @@ class ConfigInstaller implements ConfigInstallerInterface {
       }
       if ($config_to_create[$name] !== FALSE) {
         $new_config->setData($config_to_create[$name]);
+        // Add a hash to configuration created through the installer so it is
+        // possible to know if the configuration was created by installing an
+        // extension and to track which version of the default config was used.
+        if (!$this->isSyncing() && $collection == StorageInterface::DEFAULT_COLLECTION) {
+          $new_config->set('_core.default_config_hash', Crypt::hashBase64(serialize($config_to_create[$name])));
+        }
       }
       if ($collection == StorageInterface::DEFAULT_COLLECTION && $entity_type = $this->configManager->getEntityTypeIdByName($name)) {
         // If we are syncing do not create configuration entities. Pluggable
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index bb396e6d4..8c0c376c8 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -103,6 +103,17 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
    */
   protected $third_party_settings = array();
 
+  /**
+   * Information maintained by Drupal core about configuration.
+   *
+   * Keys:
+   * - default_config_hash: A hash calculated by the config.installer service
+   *   and added during installation.
+   *
+   * @var array
+   */
+  protected $_core = [];
+
   /**
    * Trust supplied data and not use configuration schema on save.
    *
@@ -296,6 +307,9 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
     if (empty($this->third_party_settings)) {
       unset($properties['third_party_settings']);
     }
+    if (empty($this->_core)) {
+      unset($properties['_core']);
+    }
     return $properties;
   }
 
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php
index 8e27aef73..47a8f308a 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php
@@ -54,6 +54,7 @@ abstract class ConfigEntityBundleBase extends ConfigEntityBase {
       }
       // Entity bundle field definitions may depend on bundle settings.
       $entity_manager->clearCachedFieldDefinitions();
+      $entity_manager->clearCachedBundles();
     }
   }
 
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php
index 55c119323..10b8142be 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php
@@ -18,10 +18,10 @@ interface ConfigEntityStorageInterface extends EntityStorageInterface {
    * Extracts the configuration entity ID from the full configuration name.
    *
    * @param string $config_name
-   *   The full configuration name to extract the ID from. E.g.
+   *   The full configuration name to extract the ID from; for example,
    *   'views.view.archive'.
    * @param string $config_prefix
-   *   The config prefix of the configuration entity. E.g. 'views.view'
+   *   The config prefix of the configuration entity; for example, 'views.view'.
    *
    * @return string
    *   The ID of the configuration entity.
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
index 527a336f3..785b31454 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
@@ -157,6 +157,7 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
           'status' => 'status',
           'dependencies' => 'dependencies',
           'third_party_settings' => 'third_party_settings',
+          '_core' => '_core',
         ];
         foreach ($this->config_export as $property => $name) {
           if (is_numeric($property)) {
diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php
index a1d967d06..ca96bd77a 100644
--- a/core/lib/Drupal/Core/Config/InstallStorage.php
+++ b/core/lib/Drupal/Core/Config/InstallStorage.php
@@ -80,9 +80,9 @@ class InstallStorage extends FileStorage {
    *   The path to the configuration file.
    *
    * @todo Improve this when figuring out how we want to handle configuration in
-   *   installation profiles. E.g., a config object actually has to be searched
-   *   in the profile first (whereas the profile is never the owner), only
-   *   afterwards check for a corresponding module or theme.
+   *   installation profiles. For instance, a config object actually has to be
+   *   searched in the profile first (whereas the profile is never the owner);
+   *   only afterwards check for a corresponding module or theme.
    */
   public function getFilePath($name) {
     $folders = $this->getAllFolders();
diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php
index 101c3bcff..82e8bd57d 100644
--- a/core/lib/Drupal/Core/CoreServiceProvider.php
+++ b/core/lib/Drupal/Core/CoreServiceProvider.php
@@ -105,8 +105,8 @@ class CoreServiceProvider implements ServiceProviderInterface  {
   /**
    * Determines and registers the UUID service.
    *
-   * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
-   *   The container.
+   * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
+   *   The container builder.
    *
    * @return string
    *   Class name for the UUID service.
@@ -131,6 +131,9 @@ class CoreServiceProvider implements ServiceProviderInterface  {
 
   /**
    * Registers services and event subscribers for a site under test.
+   *
+   * @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
+   *   The container builder.
    */
   protected function registerTest(ContainerBuilder $container) {
     // Do nothing if we are not in a test environment.
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 03335773c..2aa63151a 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -90,7 +90,7 @@ abstract class Connection {
   /**
    * An index used to generate unique temporary table names.
    *
-   * @var integer
+   * @var int
    */
   protected $temporaryNameIndex = 0;
 
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index c59e2e43e..d12788f10 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -39,7 +39,7 @@ class Schema extends DatabaseSchema {
    * Value will usually be set to a 63 chars limit but PostgreSQL allows
    * to higher this value before compiling, so we need to check for that.
    *
-   * @var integer
+   * @var int
    */
   protected $maxIdentifierLength;
 
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 278826e0f..06938a49b 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -428,7 +428,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
       ];
       // @todo Use extension_loaded('apcu') for non-testbot
       //  https://www.drupal.org/node/2447753.
-      if (function_exists('apc_fetch')) {
+      if (function_exists('apcu_fetch')) {
         $configuration['default']['cache_backend_class'] = '\Drupal\Component\FileCache\ApcuFileCacheBackend';
       }
     }
@@ -968,11 +968,11 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
       }
     }
 
-    // If the class loader is still the same, possibly upgrade to the APC class
+    // If the class loader is still the same, possibly upgrade to the APCu class
     // loader.
     if ($class_loader_class == get_class($this->classLoader)
         && Settings::get('class_loader_auto_detect', TRUE)
-        && function_exists('apc_fetch')) {
+        && function_exists('apcu_fetch')) {
       $prefix = Settings::getApcuPrefix('class_loader', $this->root);
       $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $this->classLoader);
       $this->classLoader->unregister();
@@ -1307,7 +1307,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
    *
    * @return array
    *   Array where each key is a module name, and each value is a path to the
-   *   respective *.module or *.profile file.
+   *   respective *.info.yml file.
    */
   protected function getModuleFileNames() {
     $filenames = array();
@@ -1324,7 +1324,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
    *
    * @param string[] $module_file_names
    *   Array where each key is a module name, and each value is a path to the
-   *   respective *.module or *.profile file.
+   *   respective *.info.yml file.
    *
    * @return string[]
    *   Array where each key is a module namespace like 'Drupal\system', and each
diff --git a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
index 4c7524bc1..658b426ca 100644
--- a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
+++ b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
@@ -6,15 +6,14 @@
  */
 
 namespace Drupal\Core\Entity\Annotation;
+
 use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Defines a config entity type annotation object.
  *
- * Config Entity type plugins use an object-based annotation method, rather than an
- * array-type annotation method (as commonly used on other annotation types).
  * The annotation properties of entity types are found on
- * \Drupal\Core\Entity\ConfigEntityType and are accessed using
+ * \Drupal\Core\Config\Entity\ConfigEntityType and are accessed using
  * get/set methods defined in \Drupal\Core\Entity\EntityTypeInterface.
  *
  * @ingroup entity_api
diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
index 6dd6e10cf..4273a4165 100644
--- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
+++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
@@ -10,6 +10,7 @@ namespace Drupal\Core\Entity\Element;
 use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Utility\Tags;
 use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface;
 use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\Element\Textfield;
@@ -146,6 +147,7 @@ class EntityAutocomplete extends Textfield {
         'handler' => $element['#selection_handler'],
         'handler_settings' => $element['#selection_settings'],
       );
+      /** @var /Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */
       $handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options);
       $autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface;
 
@@ -164,6 +166,7 @@ class EntityAutocomplete extends Textfield {
           );
         }
         elseif ($autocreate) {
+          /** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */
           // Auto-create item. See an example of how this is handled in
           // \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave().
           $value[] = array(
@@ -211,6 +214,7 @@ class EntityAutocomplete extends Textfield {
           }
 
           foreach ($invalid_new_entities as $entity) {
+            /** @var \Drupal\Core\Entity\EntityInterface $entity */
             $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', array('%type' => $element['#target_type'], '%label' => $entity->label())));
           }
         }
@@ -233,6 +237,8 @@ class EntityAutocomplete extends Textfield {
    * The method will return an entity ID if one single entity unambuguously
    * matches the incoming input, and sill assign form errors otherwise.
    *
+   * @param \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler
+   *   Entity reference selection plugin.
    * @param string $input
    *   Single string from autocomplete element.
    * @param array $element
@@ -243,10 +249,10 @@ class EntityAutocomplete extends Textfield {
    *   Whether to trigger a form error if an element from $input (eg. an entity)
    *   is not found.
    *
-   * @return integer|null
+   * @return int|null
    *   Value of a matching entity ID, or NULL if none.
    */
-  protected static function matchEntityByTitle($handler, $input, &$element, FormStateInterface $form_state, $strict) {
+  protected static function matchEntityByTitle(SelectionInterface $handler, $input, array &$element, FormStateInterface $form_state, $strict) {
     $entities_by_bundle = $handler->getReferenceableEntities($input, '=', 6);
     $entities = array_reduce($entities_by_bundle, function ($flattened, $bundle_entities) {
       return $flattened + $bundle_entities;
diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php
index 8164d7c1a..b49f3d48c 100644
--- a/core/lib/Drupal/Core/Entity/Entity.php
+++ b/core/lib/Drupal/Core/Entity/Entity.php
@@ -320,11 +320,6 @@ abstract class Entity implements EntityInterface {
 
   /**
    * {@inheritdoc}
-   *
-   * Returns a list of URI relationships supported by this entity.
-   *
-   * @return array
-   *   An array of link relationships supported by this entity.
    */
   public function uriRelationships() {
     return array_keys($this->linkTemplates());
@@ -497,9 +492,6 @@ abstract class Entity implements EntityInterface {
 
   /**
    * {@inheritdoc}
-   *
-   * @return static|null
-   *   The entity object or NULL if there is no entity with the given ID.
    */
   public static function load($id) {
     $entity_manager = \Drupal::entityManager();
@@ -508,10 +500,6 @@ abstract class Entity implements EntityInterface {
 
   /**
    * {@inheritdoc}
-   *
-   * @return static[]
-   *   An array of entity objects indexed by their IDs. Returns an empty array
-   *   if no matching entities are found.
    */
   public static function loadMultiple(array $ids = NULL) {
     $entity_manager = \Drupal::entityManager();
@@ -520,9 +508,6 @@ abstract class Entity implements EntityInterface {
 
   /**
    * {@inheritdoc}
-   *
-   * @return static
-   *   The entity object.
    */
   public static function create(array $values = array()) {
     $entity_manager = \Drupal::entityManager();
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
index 6d8d7fb3b..27fda29eb 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
@@ -206,6 +206,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
   public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE) {
     $account = $this->prepareUser($account);
     $context += array(
+      'entity_type_id' => $this->entityTypeId,
       'langcode' => LanguageInterface::LANGCODE_DEFAULT,
     );
 
diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php
index 62a8f4476..89b99ac97 100644
--- a/core/lib/Drupal/Core/Entity/EntityInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityInterface.php
@@ -113,7 +113,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
    *   The URL object.
    *
    * @deprecated in Drupal 8.0.0, intended to be removed in Drupal 9.0.0
-   *   Use toUrl() instead.
+   *   Use \Drupal\Core\Entity\EntityInterface::toUrl() instead.
    *
    * @see \Drupal\Core\Entity\EntityInterface::toUrl
    */
diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php
index 00590a545..365fa5633 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php
@@ -41,7 +41,7 @@ class EntityReference extends DataReferenceBase {
   /**
    * The entity ID.
    *
-   * @var integer|string
+   * @var int|string
    */
   protected $id;
 
diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
index 63f8c69af..b108bb45e 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
@@ -257,7 +257,7 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
     $entities = $this->entityManager->getStorage($target_type)->loadMultiple($result);
     foreach ($entities as $entity_id => $entity) {
       $bundle = $entity->bundle();
-      $options[$bundle][$entity_id] = Html::escape($entity->label());
+      $options[$bundle][$entity_id] = Html::escape($this->entityManager->getTranslationFromContext($entity)->label());
     }
 
     return $options;
diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php
index 686271d5f..d33b422be 100644
--- a/core/lib/Drupal/Core/Entity/entity.api.php
+++ b/core/lib/Drupal/Core/Entity/entity.api.php
@@ -592,7 +592,8 @@ function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $o
  *   The account trying to access the entity.
  * @param array $context
  *   An associative array of additional context values. By default it contains
- *   language:
+ *   language and the entity type ID:
+ *   - entity_type_id - the entity type ID.
  *   - langcode - the current language code.
  * @param string $entity_bundle
  *   The entity bundle name.
@@ -1964,7 +1965,7 @@ function hook_ENTITY_TYPE_field_values_init(\Drupal\Core\Entity\FieldableEntityI
  *
  * @return array
  *   The array structure is identical to that of the return value of
- *   \Drupal\Core\Entity\EntityManagerInterface::getExtraFields().
+ *   \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields().
  */
 function hook_entity_extra_field_info() {
   $extra = array();
diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php
index 2ae21143b..46336e0a2 100644
--- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php
@@ -70,7 +70,7 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
   }
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   protected function getHandledFormats() {
     return ['html'];
diff --git a/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php
index da6327d55..0daf17675 100644
--- a/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php
@@ -160,8 +160,8 @@ class EarlyRenderingControllerWrapperSubscriber implements EventSubscriberInterf
       }
       else {
         // A Response or domain object is returned that does not care about
-        // attachments nor cacheability. E.g. a RedirectResponse. It is safe to
-        // discard any early rendering metadata.
+        // attachments nor cacheability; for instance, a RedirectResponse. It is
+        // safe to discard any early rendering metadata.
       }
     }
 
diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php
index 0aefe961c..c06adee40 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php
@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 class ExceptionJsonSubscriber extends HttpExceptionSubscriberBase {
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   protected function getHandledFormats() {
     return ['json'];
diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
index 17c87a34c..73b5ac055 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php
@@ -23,7 +23,7 @@ class ExceptionTestSiteSubscriber extends HttpExceptionSubscriberBase {
   }
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   protected function getHandledFormats() {
     return ['html'];
diff --git a/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php
index 3f095b0f1..d3ae5d340 100644
--- a/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/Fast404ExceptionHtmlSubscriber.php
@@ -59,7 +59,7 @@ class Fast404ExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
   }
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   protected function getHandledFormats() {
     return ['html'];
diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
index c088eedb7..3d68561b9 100644
--- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
+++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
@@ -15,6 +15,13 @@ use Symfony\Component\HttpFoundation\Request;
 
 /**
  * Discovers available extensions in the filesystem.
+ *
+ * To also discover test modules, add
+ * @code
+ * $settings['extension_discovery_scan_tests'] = TRUE;
+ * @encode
+ * to your settings.php.
+ *
  */
 class ExtensionDiscovery {
 
@@ -134,6 +141,12 @@ class ExtensionDiscovery {
    * - the site-wide directory; i.e., /
    * - the site-specific directory; e.g., /sites/example.com
    *
+   * To also find test modules, add
+   * @code
+   * $settings['extension_discovery_scan_tests'] = TRUE;
+   * @encode
+   * to your settings.php.
+   *
    * The information is returned in an associative array, keyed by the extension
    * name (without .info.yml extension). Extensions found later in the search
    * will take precedence over extensions found earlier - unless they are not
diff --git a/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php b/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php
index bd2923a6d..048b9e639 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php
@@ -23,6 +23,12 @@ interface ModuleInstallerInterface {
    *   - Invoke hook_install() and add it to the list of installed modules.
    * - Invoke hook_modules_installed().
    *
+   * To install test modules add
+   * @code
+   * $settings['extension_discovery_scan_tests'] = TRUE;
+   * @encode
+   * to your settings.php.
+   *
    * @param string[] $module_list
    *   An array of module names.
    * @param bool $enable_dependencies
diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php
index c3d868428..59cfd993c 100644
--- a/core/lib/Drupal/Core/Extension/ThemeHandler.php
+++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php
@@ -19,9 +19,12 @@ class ThemeHandler implements ThemeHandlerInterface {
    * Contains the features enabled for themes by default.
    *
    * @var array
+   *
+   * @see _system_default_theme_features()
    */
   protected $defaultFeatures = array(
     'favicon',
+    'logo',
     'node_user_picture',
     'comment_user_picture',
     'comment_user_verification',
diff --git a/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php b/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php
index 8dcadca69..d2c69e06d 100644
--- a/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php
+++ b/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php
@@ -61,7 +61,7 @@ final class FieldFilteredMarkup implements MarkupInterface, \Countable {
    *   A list of allowed tags.
    */
   public static function allowedTags() {
-    return ['a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img'];
+    return ['a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img'];
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index 2121334a7..c64a60727 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -115,7 +115,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
    * {@inheritdoc}
    */
   public function setValue($values, $notify = TRUE) {
-    // Support passing in only the value of the first item, either as a litteral
+    // Support passing in only the value of the first item, either as a literal
     // (value of the first property) or as an array of properties.
     if (isset($values) && (!is_array($values) || (!empty($values) && !is_numeric(current(array_keys($values)))))) {
       $values = array(0 => $values);
diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php
index 3d896b275..f99948a8f 100644
--- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php
+++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php
@@ -156,7 +156,7 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl
   }
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   public function getPluginClass($type) {
     $plugin_definition = $this->getDefinition($type, FALSE);
diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php
index e6054a9a9..1d6b27e45 100644
--- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php
+++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php
@@ -136,7 +136,7 @@ class FormatterPluginManager extends DefaultPluginManager {
    *
    * @param string $field_type
    *   The field type.
-   * @param array $properties
+   * @param array $configuration
    *   An array of formatter configuration.
    *
    * @return array
diff --git a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
index c4cfeb184..e675286f5 100644
--- a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
+++ b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php
@@ -42,7 +42,7 @@ class FieldItemDeriver implements ContainerDeriverInterface {
    *
    * @param string $base_plugin_id
    *   The base plugin ID.
-   * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
+   * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager
    *   The field type plugin manager.
    */
   public function __construct($base_plugin_id, FieldTypePluginManagerInterface $field_type_plugin_manager) {
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
index 8a4a60279..c2f23cf1b 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
@@ -52,8 +52,6 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
    *   The view mode.
    * @param array $third_party_settings
    *   Any third party settings settings.
-   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
-   *   The entity manager.
    * @param LoggerChannelFactoryInterface $logger_factory
    *   The logger factory.
    */
diff --git a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php
index 14bd16b83..cd605bcd5 100644
--- a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php
+++ b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php
@@ -30,7 +30,7 @@ class FTPExtension extends FTP implements ChmodInterface {
    * {@inheritdoc}
    */
   protected function copyFileJailed($source, $destination) {
-    if (!@ftp_put($this->connection,  $destination, $source, FTP_BINARY)) {
+    if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) {
       throw new FileTransferException("Cannot move @source to @destination", NULL, array("@source" => $source, "@destination" => $destination));
     }
   }
diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php
index bd47f1e44..a71e342bf 100644
--- a/core/lib/Drupal/Core/Form/FormState.php
+++ b/core/lib/Drupal/Core/Form/FormState.php
@@ -212,9 +212,8 @@ class FormState implements FormStateInterface {
    *
    * The validation functions and submit functions use this array for nearly all
    * their decision making. (Note that #tree determines whether the values are a
-   * flat array or an array whose structure parallels the $form array. See the
-   * @link forms_api_reference.html Form API reference @endlink for more
-   * information.)
+   * flat array or an array whose structure parallels the $form array. See
+   * \Drupal\Core\Render\Element\FormElement for more information.)
    *
    * This property is uncacheable.
    *
diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php
index afead3d3e..26d739203 100644
--- a/core/lib/Drupal/Core/Form/FormValidator.php
+++ b/core/lib/Drupal/Core/Form/FormValidator.php
@@ -346,7 +346,7 @@ class FormValidator implements FormValidatorInterface {
         foreach ($value as $v) {
           if (!isset($options[$v])) {
             $form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.'));
-            $this->logger->error('Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
+            $this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $v, '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
           }
         }
       }
diff --git a/core/lib/Drupal/Core/Form/form.api.php b/core/lib/Drupal/Core/Form/form.api.php
index b950ccb3f..adb2d34d8 100644
--- a/core/lib/Drupal/Core/Form/form.api.php
+++ b/core/lib/Drupal/Core/Form/form.api.php
@@ -53,7 +53,7 @@
  *     such as how many total items were processed.
  */
 function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
-  $node_storage = $this->container->get('entity.manager')->getStorage('node');
+  $node_storage = \Drupal::entityTypeManager()->getStorage('node');
 
   if (!isset($context['sandbox']['progress'])) {
     $context['sandbox']['progress'] = 0;
@@ -194,7 +194,8 @@ function hook_ajax_render_alter(array &$data) {
  *
  * @see hook_form_BASE_FORM_ID_alter()
  * @see hook_form_FORM_ID_alter()
- * @see forms_api_reference.html
+ *
+ * @ingroup form_api
  */
 function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
   if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
@@ -237,7 +238,8 @@ function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_stat
  * @see hook_form_alter()
  * @see hook_form_BASE_FORM_ID_alter()
  * @see \Drupal\Core\Form\FormBuilderInterface::prepareForm()
- * @see forms_api_reference.html
+ *
+ * @ingroup form_api
  */
 function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
   // Modification for the form with the given form ID goes here. For example, if
@@ -286,6 +288,8 @@ function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $f
  * @see hook_form_alter()
  * @see hook_form_FORM_ID_alter()
  * @see \Drupal\Core\Form\FormBuilderInterface::prepareForm()
+ *
+ * @ingroup form_api
  */
 function hook_form_BASE_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
   // Modification for the form with the given BASE_FORM_ID goes here. For
diff --git a/core/lib/Drupal/Core/Image/ImageInterface.php b/core/lib/Drupal/Core/Image/ImageInterface.php
index da8496b20..2c953f53a 100644
--- a/core/lib/Drupal/Core/Image/ImageInterface.php
+++ b/core/lib/Drupal/Core/Image/ImageInterface.php
@@ -86,9 +86,12 @@ interface ImageInterface {
    * @param string $operation
    *   The operation to be performed against the image.
    * @param array $arguments
-   *   An associative array of arguments to be passed to the toolkit
-   *   operation, e.g. array('width' => 50, 'height' => 100,
-   *   'upscale' => TRUE).
+   *   (optional) An associative array of arguments to be passed to the toolkit
+   *   operation; for instance,
+   *   @code
+   *     ['width' => 50, 'height' => 100, 'upscale' => TRUE]
+   *   @endcode
+   *   Defaults to an empty array.
    *
    * @return bool
    *   TRUE on success, FALSE on failure.
@@ -120,11 +123,11 @@ interface ImageInterface {
    * @param int $height
    *   The height of the new image, in pixels.
    * @param string $extension
-   *   (Optional) The extension of the image file (e.g. 'png', 'gif', etc.).
-   *   Allowed values depend on the implementation of the image toolkit.
+   *   (optional) The extension of the image file (for instance, 'png', 'gif',
+   *   etc.). Allowed values depend on the implementation of the image toolkit.
    *   Defaults to 'png'.
    * @param string $transparent_color
-   *   (Optional) The hexadecimal string representing the color to be used
+   *   (optional) The hexadecimal string representing the color to be used
    *   for transparency, needed for GIF images. Defaults to '#ffffff' (white).
    *
    * @return bool
@@ -176,8 +179,8 @@ interface ImageInterface {
    * extension.
    *
    * @param string $extension
-   *   The extension to convert to (e.g. 'jpeg' or 'png'). Allowed values depend
-   *   on the current image toolkit.
+   *   The extension to convert to (for instance, 'jpeg' or 'png'). Allowed
+   *   values depend on the current image toolkit.
    *
    * @return bool
    *   TRUE on success, FALSE on failure.
@@ -231,10 +234,10 @@ interface ImageInterface {
    *   The number of (clockwise) degrees to rotate the image.
    * @param string|null $background
    *   (optional) An hexadecimal integer specifying the background color to use
-   *   for the uncovered area of the image after the rotation. E.g. 0x000000 for
-   *   black, 0xff00ff for magenta, and 0xffffff for white. For images that
-   *   support transparency, this will default to transparent. Otherwise it will
-   *   be white.
+   *   for the uncovered area of the image after the rotation; for example,
+   *   0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. When
+   *   NULL (the default) is specified, for images that support transparency,
+   *   this will default to transparent; otherwise, it will default to white.
    *
    * @return bool
    *   TRUE on success, FALSE on failure.
diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php
index 46fb892f8..675ca4777 100644
--- a/core/lib/Drupal/Core/Language/Language.php
+++ b/core/lib/Drupal/Core/Language/Language.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Core\Language;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
 /**
  * An object containing the information for an interface language.
  *
@@ -151,7 +153,17 @@ class Language implements LanguageInterface {
       $a_weight = $a->getWeight();
       $b_weight = $b->getWeight();
       if ($a_weight == $b_weight) {
-        return strnatcasecmp($a->getName(), $b->getName());
+        $a_name = $a->getName();
+        $b_name = $b->getName();
+        // If either name is a TranslatableMarkup object it can not be converted
+        // to a string. This is because translation requires a sorted list of
+        // languages thereby causing an infinite loop. Determine the order based
+        // on ID if this is the case.
+        if ($a_name instanceof TranslatableMarkup || $b_name instanceof TranslatableMarkup) {
+          $a_name = $a->getId();
+          $b_name = $b->getId();
+        }
+        return strnatcasecmp($a_name, $b_name);
       }
       return ($a_weight < $b_weight) ? -1 : 1;
     });
diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php
index 092e9fe2f..4c0172dfd 100644
--- a/core/lib/Drupal/Core/Language/LanguageManager.php
+++ b/core/lib/Drupal/Core/Language/LanguageManager.php
@@ -224,7 +224,7 @@ class LanguageManager implements LanguageManagerInterface {
   }
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   public static function getStandardLanguageList() {
     // This list is based on languages available from localize.drupal.org. See
diff --git a/core/lib/Drupal/Core/Link.php b/core/lib/Drupal/Core/Link.php
index f739ad1c2..0bf24e84d 100644
--- a/core/lib/Drupal/Core/Link.php
+++ b/core/lib/Drupal/Core/Link.php
@@ -140,11 +140,15 @@ class Link implements RenderableInterface {
   /**
    * Generates the HTML for this Link object.
    *
+   * Do not use this method to render a link in an HTML context. In an HTML
+   * context, self::toRenderable() should be used so that render cache
+   * information is maintained. However, there might be use cases such as tests
+   * and non-HTML contexts where calling this method directly makes sense.
+   *
    * @return \Drupal\Core\GeneratedLink
    *   The link HTML markup.
    *
-   * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. Use
-   *   self::toRenderable() instead.
+   * @see \Drupal\Core\Link::toRenderable()
    */
   public function toString() {
     return $this->getLinkGenerator()->generateFromLink($this);
diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
index 86e85531a..6ea977f4a 100644
--- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php
+++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
@@ -297,8 +297,8 @@ class MailFormatHelper {
    * Note that we are skipping MIME content header lines, because attached
    * files, especially applications, could have long MIME types or long
    * filenames which result in line length longer than the 77 characters limit
-   * and wrapping that line will break the email format. E.g., the attached file
-   * hello_drupal.docx will produce the following Content-Type:
+   * and wrapping that line will break the email format. For instance, the
+   * attached file hello_drupal.docx will produce the following Content-Type:
    * @code
    * Content-Type:
    * application/vnd.openxmlformats-officedocument.wordprocessingml.document;
diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextInterface.php b/core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
index 067e76a46..5cda9be05 100644
--- a/core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
+++ b/core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
@@ -32,9 +32,9 @@ interface ContextInterface extends ComponentContextInterface, CacheableDependenc
   /**
    * Adds a dependency on an object: merges its cacheability metadata.
    *
-   * E.g. when a context depends on some configuration, an entity, or an access
-   * result, we must make sure their cacheability metadata is present on the
-   * response. This method makes doing that simple.
+   * For example, when a context depends on some configuration, an entity, or an
+   * access result, we must make sure their cacheability metadata is present on
+   * the response. This method makes doing that simple.
    *
    * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
    *   The dependency. If the object implements CacheableDependencyInterface,
diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
index 558556d2d..26b716173 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -289,7 +289,7 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
    * Invokes the hook to alter the definitions if the alter hook is set.
    *
    * @param $definitions
-   *   The discovered plugin defintions.
+   *   The discovered plugin definitions.
    */
   protected function alterDefinitions(&$definitions) {
     if ($this->alterHook) {
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
index 6bc3bbbf6..8cb4888d7 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php
@@ -120,13 +120,13 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
     if ($this->namespaceSuffix) {
       foreach ($this->rootNamespacesIterator as $namespace => $dirs) {
         // Append the namespace suffix to the base namespace, to obtain the
-        // plugin namespace. E.g. 'Drupal\Views' may become
+        // plugin namespace; for example, 'Drupal\Views' may become
         // 'Drupal\Views\Plugin\Block'.
         $namespace .= $this->namespaceSuffix;
         foreach ((array) $dirs as $dir) {
           // Append the directory suffix to the PSR-4 base directory, to obtain
-          // the directory where plugins are found.
-          // E.g. DRUPAL_ROOT . '/core/modules/views/src' may become
+          // the directory where plugins are found. For example,
+          // DRUPAL_ROOT . '/core/modules/views/src' may become
           // DRUPAL_ROOT . '/core/modules/views/src/Plugin/Block'.
           $plugin_namespaces[$namespace][] = $dir . $this->directorySuffix;
         }
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
index 97ea37460..058c752c8 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
@@ -47,8 +47,8 @@ class YamlDiscovery implements DiscoveryInterface {
    * Construct a YamlDiscovery object.
    *
    * @param string $name
-   *   The file name suffix to use for discovery. E.g. 'test' will become
-   *   'MODULE.test.yml'.
+   *   The file name suffix to use for discovery; for example, 'test' will
+   *   become 'MODULE.test.yml'.
    * @param array $directories
    *   An array of directories to scan.
    */
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php
index 2957dc04c..332e740a4 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php
@@ -30,8 +30,8 @@ class YamlDiscoveryDecorator extends YamlDiscovery {
    * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
    *   The discovery object that is being decorated.
    * @param string $name
-   *   The file name suffix to use for discovery. E.g. 'test' will become
-   *   'MODULE.test.yml'.
+   *   The file name suffix to use for discovery; for instance, 'test' will
+   *   become 'MODULE.test.yml'.
    * @param array $directories
    *   An array of directories to scan.
    */
diff --git a/core/lib/Drupal/Core/Plugin/PluginFormInterface.php b/core/lib/Drupal/Core/Plugin/PluginFormInterface.php
index fee05ec58..06dbbad6c 100644
--- a/core/lib/Drupal/Core/Plugin/PluginFormInterface.php
+++ b/core/lib/Drupal/Core/Plugin/PluginFormInterface.php
@@ -27,8 +27,7 @@ interface PluginFormInterface {
    * callback and build the rest of the form in the callback. By the time the
    * callback is executed, the element's #parents and #array_parents properties
    * will have been set by the form API. For more documentation on #parents and
-   * #array_parents, see
-   * https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/8.
+   * #array_parents, see \Drupal\Core\Render\Element\FormElement.
    *
    * @param array $form
    *   An associative array containing the initial structure of the plugin form.
diff --git a/core/lib/Drupal/Core/Render/Element/HtmlTag.php b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
index f2bcacf7e..5ec0d3f77 100644
--- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php
+++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
@@ -16,6 +16,24 @@ use Drupal\Core\Template\Attribute;
 /**
  * Provides a render element for any HTML tag, with properties and value.
  *
+ * Properties:
+ * - #tag: The tag name to output.
+ * - #attributes: (array, optional) HTML attributes to apply to the tag. The
+ *   attributes are escaped, see \Drupal\Core\Template\Attribute.
+ * - #value: (string, optional) A string containing the textual contents of
+ *   the tag.
+ * - #noscript: (bool, optional) When set to TRUE, the markup
+ *   (including any prefix or suffix) will be wrapped in a <noscript> element.
+ *
+ * Usage example:
+ * @code
+ * $build['hello'] = [
+ *   '#type' => 'html_tag'
+ *   '#tag' => 'p',
+ *   '#value' => $this->t('Hello World'),
+ * ];
+ * @endcode
+ *
  * @RenderElement("html_tag")
  */
 class HtmlTag extends RenderElement {
diff --git a/core/lib/Drupal/Core/Render/Element/InlineTemplate.php b/core/lib/Drupal/Core/Render/Element/InlineTemplate.php
index 7d2d553ed..4189bab40 100644
--- a/core/lib/Drupal/Core/Render/Element/InlineTemplate.php
+++ b/core/lib/Drupal/Core/Render/Element/InlineTemplate.php
@@ -10,6 +10,22 @@ namespace Drupal\Core\Render\Element;
 /**
  * Provides a render element where the user supplies an in-line Twig template.
  *
+ * Properties:
+ * - #template: The inline Twig template used to render the element.
+ * - #context: (array) The variables to substitute into the Twig template.
+ *   Each variable may be a string or a render array.
+ *
+ * Usage example:
+ * @code
+ * $build['hello']  = [
+ *   '#type' => 'inline_template',
+ *   '#template' => "{% trans %} Hello {% endtrans %} <strong>{{name}}</strong>",
+ *   '#context' => [
+ *     'name' => $name,
+ *   ]
+ * ];
+ * @endcode
+ *
  * @RenderElement("inline_template")
  */
 class InlineTemplate extends RenderElement {
diff --git a/core/lib/Drupal/Core/Render/Element/Label.php b/core/lib/Drupal/Core/Render/Element/Label.php
index 7f90605c0..06c5b0164 100644
--- a/core/lib/Drupal/Core/Render/Element/Label.php
+++ b/core/lib/Drupal/Core/Render/Element/Label.php
@@ -11,7 +11,8 @@ namespace Drupal\Core\Render\Element;
  * Provides a render element for displaying the label for a form element.
  *
  * Labels are generated automatically from element properties during processing
- * of most form elements.
+ * of most form elements. This element is used internally by the form system
+ * to render labels for form elements.
  *
  * @RenderElement("label")
  */
diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php
index 8f908d2ee..589675269 100644
--- a/core/lib/Drupal/Core/Render/Element/Link.php
+++ b/core/lib/Drupal/Core/Render/Element/Link.php
@@ -15,6 +15,20 @@ use Drupal\Core\Url as CoreUrl;
 /**
  * Provides a link render element.
  *
+ * Properties:
+ * - #title: The link text.
+ * - #url: \Drupal\Url object containing URL information pointing to a internal
+ *   or external link . See \Drupal\Core\Utility\LinkGeneratorInterface.
+ *
+ * Usage example:
+ * @code
+ * $build['examples_link'] = [
+ *   '#title' => $this->t('Examples'),
+ *   '#type' => 'link',
+ *   '#url' => Url::fromRoute('examples.description')
+ * ];
+ * @endcode
+ *
  * @RenderElement("link")
  */
 class Link extends RenderElement {
diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php
index 995c7072a..db9c6854a 100644
--- a/core/lib/Drupal/Core/Render/Element/MoreLink.php
+++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php
@@ -10,6 +10,19 @@ namespace Drupal\Core\Render\Element;
 /**
  * Provides a link render element for a "more" link, like those used in blocks.
  *
+ * Properties:
+ * - #title: The text of the link to generate (defaults to 'More').
+ *
+ * See \Drupal\Core\Render\Element\Link for additional properties.
+ *
+ * Usage Example:
+ * @code
+ * $build['more'] = [
+ *   '#type' => 'more_link',
+ *   '#url' => Url::fromRoute('examples.more_examples')
+ * ]
+ * @endcode
+ *
  * @RenderElement("more_link")
  */
 class MoreLink extends Link {
diff --git a/core/lib/Drupal/Core/Render/Element/Pager.php b/core/lib/Drupal/Core/Render/Element/Pager.php
index 8e87ccaa5..72c98a9e2 100644
--- a/core/lib/Drupal/Core/Render/Element/Pager.php
+++ b/core/lib/Drupal/Core/Render/Element/Pager.php
@@ -12,6 +12,29 @@ use Drupal\Core\Render\Element;
 /**
  * Provides a render element for a pager.
  *
+ * The pager must be initialized with a call to pager_default_initialize() in
+ * order to render properly. When used with database queries, this is performed
+ * for you when you extend a select query with
+ * \Drupal\Core\Database\Query\PagerSelectExtender.
+ *
+ * Properties:
+ * - #element: (optional, int) The pager ID, to distinguish between multiple
+ *   pagers on the same page (defaults to 0).
+ * - #parameters: (optional) An associative array of query string parameters to
+ *   append to the pager.
+ * - #quantity: The maximum number of numbered page links to create (defaults
+ *   to 9).
+ * - #tags: (optional) An array of labels for the controls in the pages.
+ * - #route_name: (optional) The name of the route to be used to build pager
+ *   links. Defaults to '<none>', which will make links relative to the current
+ *   URL. This makes the page more effectively cacheable.
+ *
+ * @code
+ * $build['pager'] = [
+ *   '#type' => 'pager',
+ * ];
+ * @endcode
+ *
  * @RenderElement("pager")
  */
 class Pager extends RenderElement{
diff --git a/core/lib/Drupal/Core/Render/Element/Select.php b/core/lib/Drupal/Core/Render/Element/Select.php
index b028c428a..314873722 100644
--- a/core/lib/Drupal/Core/Render/Element/Select.php
+++ b/core/lib/Drupal/Core/Render/Element/Select.php
@@ -14,12 +14,30 @@ use Drupal\Core\Render\Element;
  * Provides a form element for a drop-down menu or scrolling selection box.
  *
  * Properties:
- * - #options: An associative array, where the keys are the retured values for
- *   each option, and the values are the options to be shown in the drop-down
- *   list.
+ * - #options: An associative array, where the keys are the values for each
+ *   option, and the values are the option labels to be shown in the drop-down
+ *   list. If a value is an array, it will be rendered similarly, but as an
+ *   optgroup. The key of the sub-array will be used as the label for the
+ *   optgroup. Nesting optgroups is not allowed.
  * - #empty_option: The label that will be displayed to denote no selection.
  * - #empty_value: The value of the option that is used to denote no selection.
  *
+ * Usage example:
+ * @code
+ * $form['example_select'] = [
+ *   '#type' => 'select',
+ *   '#title' => t('Select element'),
+ *   '#options' => [
+ *     '1' => t('One'),
+ *     '2' => [
+ *       '2.1' => t('Two point one'),
+ *       '2.2' => t('Two point two'),
+ *     ],
+ *     '3' => t('Three'),
+ *   ],
+ * ];
+ * @endcode
+ *
  * @FormElement("select")
  */
 class Select extends FormElement {
diff --git a/core/lib/Drupal/Core/Render/Element/StatusMessages.php b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
index 41538496b..8b8e52b4f 100644
--- a/core/lib/Drupal/Core/Render/Element/StatusMessages.php
+++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
@@ -10,6 +10,15 @@ namespace Drupal\Core\Render\Element;
 /**
  * Provides a messages element.
  *
+ * Used to display results of drupal_set_message() calls.
+ *
+ * Usage example:
+ * @code
+ * $build['status_messages'] = [
+ *   '#type' => 'status_messages',
+ * ];
+ * @end
+ *
  * @RenderElement("status_messages")
  */
 class StatusMessages extends RenderElement {
diff --git a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
index fa701b0d0..377762f0f 100644
--- a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
+++ b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
@@ -11,7 +11,14 @@ use Drupal\Core\Url as BaseUrl;
 use Drupal\Component\Utility\NestedArray;
 
 /**
- * Provides a link render element to show or hide inline help descriptions.
+ * Provides a link to show or hide help text on administration pages.
+ *
+ * Usage example:
+ * @code
+ * $form['system_compact_link'] = [
+ *   '#type' => 'system_compact_link',
+ * ];
+ * @endcode
  *
  * @RenderElement("system_compact_link")
  */
diff --git a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
index a6c4a2343..442ad6b5f 100644
--- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
+++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
@@ -49,19 +49,19 @@ class PlaceholderGenerator implements PlaceholderGeneratorInterface {
    * {@inheritdoc}
    */
   public function shouldAutomaticallyPlaceholder(array $element) {
+    // Auto-placeholder if the max-age, cache context or cache tag is specified
+    // in the auto-placeholder conditions in the 'renderer.config' container
+    // parameter.
     $conditions = $this->rendererConfig['auto_placeholder_conditions'];
 
-    // Auto-placeholder if max-age is at or below the configured threshold.
     if (isset($element['#cache']['max-age']) && $element['#cache']['max-age'] !== Cache::PERMANENT && $element['#cache']['max-age'] <= $conditions['max-age']) {
       return TRUE;
     }
 
-    // Auto-placeholder if a high-cardinality cache context is set.
     if (isset($element['#cache']['contexts']) && array_intersect($element['#cache']['contexts'], $conditions['contexts'])) {
       return TRUE;
     }
 
-    // Auto-placeholder if a high-invalidation frequency cache tag is set.
     if (isset($element['#cache']['tags']) && array_intersect($element['#cache']['tags'], $conditions['tags'])) {
       return TRUE;
     }
diff --git a/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php b/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php
index 89802a2ef..224bcbf55 100644
--- a/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Render/PlaceholderGeneratorInterface.php
@@ -35,6 +35,11 @@ interface PlaceholderGeneratorInterface {
   /**
    * Whether the given render array should be automatically placeholdered.
    *
+   * The render array should be placeholdered if its cacheability either has a
+   * cache context with too high cardinality, a cache tag with a too high
+   * invalidation rate, or a max-age that is too low. Either of these would make
+   * caching ineffective, and thus we choose to placeholder instead.
+   *
    * @param array $element
    *   The render array whose cacheability to analyze.
    *
diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php
index 3cd1ff063..48cece445 100644
--- a/core/lib/Drupal/Core/Render/RendererInterface.php
+++ b/core/lib/Drupal/Core/Render/RendererInterface.php
@@ -42,9 +42,9 @@ interface RendererInterface {
    *
    * Calls ::render() in such a way that placeholders are replaced.
    *
-   * Useful for e.g. rendering the values of tokens or emails, which need a
-   * render array being turned into a string, but don't need any of the
-   * bubbleable metadata (the attached assets the cache tags).
+   * Useful for instance when rendering the values of tokens or emails, which
+   * need a render array being turned into a string, but do not need any of the
+   * bubbleable metadata (the attached assets and cache tags).
    *
    * Some of these are a relatively common use case and happen *within* a
    * ::renderRoot() call, but that is generally highly problematic (and hence an
@@ -138,8 +138,8 @@ interface RendererInterface {
    *     - 'keys': An array of one or more keys that identify the element. If
    *       'keys' is set, the cache ID is created automatically from these keys.
    *     - 'contexts': An array of one or more cache context IDs. These are
-   *       converted to a final value depending on the request. (e.g. 'user' is
-   *       mapped to the current user's ID.)
+   *       converted to a final value depending on the request. (For instance,
+   *       'user' is mapped to the current user's ID.)
    *     - 'max-age': A time in seconds. Zero seconds means it is not cacheable.
    *       \Drupal\Core\Cache\Cache::PERMANENT means it is cacheable forever.
    *     - 'bin': Specify a cache bin to cache the element in. Default is
@@ -298,14 +298,14 @@ interface RendererInterface {
    *     placeholder element containing a #lazy_builder function is rendered in
    *     isolation. The resulting markup is used to replace the placeholder, and
    *     any bubbleable metadata is merged.
-   *     Placeholders must be unique, to guarantee that e.g. samples of
+   *     Placeholders must be unique, to guarantee that for instance, samples of
    *     placeholders are not replaced as well.
    *   - Just before finishing the rendering of this element, this element's
    *     stack frame (the topmost one) is bubbled: the two topmost frames are
    *     popped from the stack, they are merged and the result is pushed back
    *     onto the stack.
-   *     So if this element e.g. was a child element, then a new frame was
-   *     pushed onto the stack element at the beginning of rendering this
+   *     So if for instance this element was a child element, then a new frame
+   *     was pushed onto the stack element at the beginning of rendering this
    *     element, it was updated when the rendering was completed, and now we
    *     merge it with the frame for the parent, so that the parent now has the
    *     bubbleable rendering metadata for its child.
@@ -401,9 +401,9 @@ interface RendererInterface {
   /**
    * Adds a dependency on an object: merges its cacheability metadata.
    *
-   * E.g. when a render array depends on some configuration, an entity, or an
-   * access result, we must make sure their cacheability metadata is present on
-   * the render array. This method makes doing that simple.
+   * For instance, when a render array depends on some configuration, an entity,
+   * or an access result, we must make sure their cacheability metadata is
+   * present on the render array. This method makes doing that simple.
    *
    * @param array &$elements
    *   The render array to update.
diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php
index e0617f3da..d9c0fc9a2 100644
--- a/core/lib/Drupal/Core/Render/theme.api.php
+++ b/core/lib/Drupal/Core/Render/theme.api.php
@@ -37,16 +37,16 @@
  * http://twig.sensiolabs.org/doc/templates.html
  *
  * @section sec_theme_hooks Theme Hooks
- * The theme system is invoked in drupal_render() by calling the internal
- * _theme() function, which operates on the concept of "theme hooks". Theme
- * hooks define how a particular type of data should be rendered. They are
- * registered by modules by implementing hook_theme(), which specifies the name
- * of the hook, the input "variables" used to provide data and options, and
- * other information. Modules implementing hook_theme() also need to provide a
- * default implementation for each of their theme hooks, normally in a Twig
- * file, and they may also provide preprocessing functions. For example, the
- * core Search module defines a theme hook for a search result item in
- * search_theme():
+ * The theme system is invoked in \Drupal\Core\Render\Renderer::doRender() by
+ * calling the \Drupal\Core\Theme\ThemeManagerInterface::render() function,
+ * which operates on the concept of "theme hooks". Theme hooks define how a
+ * particular type of data should be rendered. They are registered by modules by
+ * implementing hook_theme(), which specifies the name of the hook, the input
+ * "variables" used to provide data and options, and other information. Modules
+ * implementing hook_theme() also need to provide a default implementation for
+ * each of their theme hooks, normally in a Twig file, and they may also provide
+ * preprocessing functions. For example, the core Search module defines a theme
+ * hook for a search result item in search_theme():
  * @code
  * return array(
  *   'search_result' => array(
@@ -366,7 +366,7 @@
  * @code
  *   '#cache' => [
  *     'keys' => ['entity_view', 'node', $node->id()],
- *     'contexts' => ['language'],
+ *     'contexts' => ['languages'],
  *     'tags' => ['node:' . $node->id()],
  *     'max-age' => Cache::PERMANENT,
  *   ],
@@ -429,9 +429,10 @@
  *
  * @section render_pipeline The render pipeline
  * The term "render pipeline" refers to the process Drupal uses to take
- * information provided by modules and render it into a response. For more
- * details on this process, see https://www.drupal.org/developing/api/8/render;
- * for background on routing concepts, see @ref sec_controller.
+ * information provided by modules and render it into a response. See
+ * https://www.drupal.org/developing/api/8/render for more details on this
+ * process. For background on routing concepts, see
+ * @link routing Routing API. @endlink
  *
  * There are in fact multiple render pipelines:
  * - Drupal always uses the Symfony render pipeline. See
@@ -472,6 +473,36 @@
  * @}
  */
 
+/**
+ * @defgroup listing_page_element Page header for Elements page
+ * @{
+ * Introduction to form and render elements
+ *
+ * Render elements are referenced in render arrays. Render arrays contain data
+ * to be rendered, along with meta-data and attributes that specify how to
+ * render the data into markup; see the
+ * @link theme_render Render API topic @endlink for an overview of render
+ * arrays and render elements. Form arrays are a subset of render arrays,
+ * representing HTML forms; form elements are a subset of render elements,
+ * representing HTML elements for forms. See the
+ * @link form_api Form API topic @endlink for an overview of forms, form
+ * processing, and form arrays.
+ *
+ * Each form and render element type corresponds to an element plugin class;
+ * each of them either extends \Drupal\Core\Render\Element\RenderElement
+ * (render elements) or \Drupal\Core\Render\Element\FormElement (form
+ * elements). Usage and properties are documented on the individual classes,
+ * and the two base classes list common properties shared by all render
+ * elements and the form element subset, respectively.
+ *
+ * @see theme_render
+ * @see form_api
+ * @see \Drupal\Core\Render\Element\RenderElement
+ * @see \Drupal\Core\Render\Element\FormElement
+ *
+ * @}
+ */
+
 /**
  * @addtogroup hooks
  * @{
@@ -512,7 +543,8 @@ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormSta
  * preprocess variables for a specific theme hook, whether implemented as a
  * template or function.
  *
- * For more detailed information, see _theme().
+ * For more detailed information, see the
+ * @link themeable Theme system overview topic @endlink.
  *
  * @param $variables
  *   The variables array (modify in place).
@@ -560,7 +592,8 @@ function hook_preprocess(&$variables, $hook) {
  * hook. It should only be used if a module needs to override or add to the
  * theme preprocessing for a theme hook it didn't define.
  *
- * For more detailed information, see _theme().
+ * For more detailed information, see the
+ * @link themeable Theme system overview topic @endlink.
  *
  * @param $variables
  *   The variables array (modify in place).
diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index 62ece640d..9979b73b2 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -432,7 +432,7 @@ class UrlGenerator implements UrlGeneratorInterface {
   }
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   public function supports($name) {
     // Support a route object and any string as route name.
@@ -440,7 +440,7 @@ class UrlGenerator implements UrlGeneratorInterface {
   }
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   public function getRouteDebugMessage($name, array $parameters = array()) {
     if (is_scalar($name)) {
diff --git a/core/lib/Drupal/Core/Session/SessionManager.php b/core/lib/Drupal/Core/Session/SessionManager.php
index 079eec43c..7a2e23dd5 100644
--- a/core/lib/Drupal/Core/Session/SessionManager.php
+++ b/core/lib/Drupal/Core/Session/SessionManager.php
@@ -331,8 +331,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
    * Migrates the current session to a new session id.
    *
    * @param string $old_session_id
-   *   The old session id. The new session id is $this->getId() unless
-   *   $new_insecure_session_id is not empty.
+   *   The old session ID. The new session ID is $this->getId().
    */
   protected function migrateStoredSession($old_session_id) {
     $fields = array('sid' => Crypt::hashBase64($this->getId()));
diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php
index ee786db89..471f52bcf 100644
--- a/core/lib/Drupal/Core/Site/Settings.php
+++ b/core/lib/Drupal/Core/Site/Settings.php
@@ -149,24 +149,24 @@ final class Settings {
   }
 
   /**
-   * Generates a prefix for APC user cache keys.
+   * Generates a prefix for APCu user cache keys.
    *
-   * A standardized prefix is useful to allow visual inspection of an APC user
+   * A standardized prefix is useful to allow visual inspection of an APCu user
    * cache. By default, this method will produce a unique prefix per site using
    * the hash salt. If the setting 'apcu_ensure_unique_prefix' is set to FALSE
    * then if the caller does not provide a $site_path only the Drupal root will
    * be used. This allows WebTestBase to use the same prefix ensuring that the
-   * number of APC items created during a full test run is kept to a minimum.
+   * number of APCu items created during a full test run is kept to a minimum.
    * Additionally, if a multi site implementation does not use site specific
    * module directories setting apcu_ensure_unique_prefix would allow the sites
-   * to share APC cache items.
+   * to share APCu cache items.
    *
    * @param $identifier
    *   An identifier for the prefix. For example, 'class_loader' or
    *   'cache_backend'.
    *
    * @return string
-   *   The prefix for APC user cache keys.
+   *   The prefix for APCu user cache keys.
    */
   public static function getApcuPrefix($identifier, $root, $site_path = '') {
     if (static::get('apcu_ensure_unique_prefix', TRUE)) {
diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php
index 34dc3331f..f13cfb80f 100644
--- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php
+++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php
@@ -66,8 +66,10 @@ interface StreamWrapperInterface extends PhpStreamWrapperInterface {
    */
 
   /**
-   * Not visible in the UI or accessible via web, but readable and writable.
-   * E.g. the temporary directory for uploads.
+   * Defines the stream wrapper bit flag for a hidden file.
+   *
+   * This is not visible in the UI or accessible via web, but readable and
+   * writable; for instance, the temporary directory for file uploads.
    */
   const HIDDEN = 0x000C;
 
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index d0d6e6545..69f329805 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -315,8 +315,8 @@ class TwigExtension extends \Twig_Extension {
    * ampersand ("&") which separates query params. Thus we cannot mark
    * the generated URL as always safe, but only when we are sure there won't be
    * multiple query params. This is the case when there are none or only one
-   * constant parameter given. E.g. we know beforehand this will not need to
-   * be escaped:
+   * constant parameter given. For instance, we know beforehand this will not
+   * need to be escaped:
    * - path('route')
    * - path('route', {'param': 'value'})
    * But the following may need to be escaped:
diff --git a/core/lib/Drupal/Core/Template/TwigSandboxPolicy.php b/core/lib/Drupal/Core/Template/TwigSandboxPolicy.php
index 5423bde59..a7bb43fc6 100644
--- a/core/lib/Drupal/Core/Template/TwigSandboxPolicy.php
+++ b/core/lib/Drupal/Core/Template/TwigSandboxPolicy.php
@@ -81,8 +81,10 @@ class TwigSandboxPolicy implements \Twig_Sandbox_SecurityPolicyInterface {
    * {@inheritdoc}
    */
   public function checkMethodAllowed($obj, $method) {
-    if (isset($this->whitelisted_classes[get_class($obj)])) {
-      return TRUE;
+    foreach ($this->whitelisted_classes as $class => $key) {
+      if ($obj instanceof $class) {
+        return TRUE;
+      }
     }
 
     // Return quickly for an exact match of the method name.
diff --git a/core/lib/Drupal/Core/Template/TwigTransTokenParser.php b/core/lib/Drupal/Core/Template/TwigTransTokenParser.php
index 009cc9c02..e87bd65bd 100644
--- a/core/lib/Drupal/Core/Template/TwigTransTokenParser.php
+++ b/core/lib/Drupal/Core/Template/TwigTransTokenParser.php
@@ -84,7 +84,7 @@ class TwigTransTokenParser extends \Twig_TokenParser {
    *
    * @param \Twig_Node $body
    *   The expression to check.
-   * @param integer $lineno
+   * @param int $lineno
    *   The source line.
    *
    * @throws \Twig_Error_Syntax
diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index 0167a7474..e2a89a90d 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -47,12 +47,12 @@ class Registry implements DestructableInterface {
    *   - name: The name of the extension the original theme hook originates
    *     from; e.g., 'node' for theme hook 'node' of Node module.
    *   - theme path: The effective \Drupal\Core\Theme\ActiveTheme::getPath()
-   *      during _theme(), available as
-   *      'directory' variable in templates. For functions, it should point to
-   *      the respective theme.For templates, it should point to the directory
-   *      that contains the template.
+   *      during \Drupal\Core\Theme\ThemeManagerInterface::render(), available
+   *      as 'directory' variable in templates. For functions, it should point
+   *      to the respective theme. For templates, it should point to the
+   *      directory that contains the template.
    *   - includes: (optional) An array of include files to load when the theme
-   *     hook is executed by _theme().
+   *     hook is executed by \Drupal\Core\Theme\ThemeManagerInterface::render().
    *   - file: (optional) A filename to add to 'includes', either prefixed with
    *     the value of 'path', or the path of the extension implementing
    *     hook_theme().
@@ -389,7 +389,8 @@ class Registry implements DestructableInterface {
    *     in hook_theme(). If there is more than one implementation and
    *     'render element' is not specified in a later one, then the previous
    *     definition is kept.
-   *   - 'preprocess functions': See _theme() for detailed documentation.
+   *   - See the @link themeable Theme system overview topic @endlink for
+   *     detailed documentation.
    * @param string $name
    *   The name of the module, theme engine, base theme engine, theme or base
    *   theme implementing hook_theme().
@@ -530,7 +531,8 @@ class Registry implements DestructableInterface {
           }
           foreach ($prefixes as $prefix) {
             // Only use non-hook-specific variable preprocessors for theming
-            // hooks implemented as templates. See _theme().
+            // hooks implemented as templates. See the @defgroup themeable
+            // topic.
             if (isset($info['template']) && function_exists($prefix . '_preprocess')) {
               $info['preprocess functions'][] = $prefix . '_preprocess';
             }
@@ -566,7 +568,7 @@ class Registry implements DestructableInterface {
             $cache[$hook]['preprocess functions'] = array();
           }
           // Only use non-hook-specific variable preprocessors for theme hooks
-          // implemented as templates. See _theme().
+          // implemented as templates. See the @defgroup themeable topic.
           if (isset($info['template']) && function_exists($name . '_preprocess')) {
             $cache[$hook]['preprocess functions'][] = $name . '_preprocess';
           }
diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
index d0c91662e..88c06e2c7 100644
--- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php
+++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -267,7 +267,7 @@ class ThemeInitialization implements ThemeInitializationInterface {
    */
   protected function getExtensions() {
     if (!isset($this->extensions)) {
-      $this->extensions = array_merge($this->moduleHandler->getModuleList(),  $this->themeHandler->listInfo());
+      $this->extensions = array_merge($this->moduleHandler->getModuleList(), $this->themeHandler->listInfo());
     }
     return $this->extensions;
   }
diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php
index 7e0e0b48c..d4c6a2c04 100644
--- a/core/lib/Drupal/Core/Theme/ThemeManager.php
+++ b/core/lib/Drupal/Core/Theme/ThemeManager.php
@@ -138,11 +138,11 @@ class ThemeManager implements ThemeManagerInterface {
 
     $active_theme = $this->getActiveTheme();
 
-    // If called before all modules are loaded, we do not necessarily have a full
-    // theme registry to work with, and therefore cannot process the theme
+    // If called before all modules are loaded, we do not necessarily have a
+    // full theme registry to work with, and therefore cannot process the theme
     // request properly. See also \Drupal\Core\Theme\Registry::get().
     if (!$this->moduleHandler->isLoaded() && !defined('MAINTENANCE_MODE')) {
-      throw new \Exception(t('_theme() may not be called until all modules are loaded.'));
+      throw new \Exception('The theme implementations may not be rendered until all modules are loaded.');
     }
 
     $theme_registry = $this->themeRegistry->getRuntime();
@@ -180,9 +180,10 @@ class ThemeManager implements ThemeManagerInterface {
           \Drupal::logger('theme')->warning('Theme hook %hook not found.', array('%hook' => $hook));
         }
         // There is no theme implementation for the hook passed. Return FALSE so
-        // the function calling _theme() can differentiate between a hook that
-        // exists and renders an empty string and a hook that is not
-        // implemented.
+        // the function calling
+        // \Drupal\Core\Theme\ThemeManagerInterface::render() can differentiate
+        // between a hook that exists and renders an empty string, and a hook
+        // that is not implemented.
         return FALSE;
       }
     }
@@ -233,8 +234,8 @@ class ThemeManager implements ThemeManagerInterface {
 
     // Invoke hook_theme_suggestions_HOOK().
     $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, array($variables));
-    // If _theme() was invoked with a direct theme suggestion like
-    // '#theme' => 'node__article', add it to the suggestions array before
+    // If the theme implementation was invoked with a direct theme suggestion
+    // like '#theme' => 'node__article', add it to the suggestions array before
     // invoking suggestion alter hooks.
     if (isset($info['base hook'])) {
       $suggestions[] = $hook;
@@ -250,10 +251,10 @@ class ThemeManager implements ThemeManagerInterface {
     $this->alter($hooks, $suggestions, $variables, $base_theme_hook);
 
     // Check if each suggestion exists in the theme registry, and if so,
-    // use it instead of the hook that _theme() was called with. For example, a
-    // function may call _theme('node', ...), but a module can add
-    // 'node__article' as a suggestion via hook_theme_suggestions_HOOK_alter(),
-    // enabling a theme to have an alternate template file for article nodes.
+    // use it instead of the base hook. For example, a function may use
+    // '#theme' => 'node', but a module can add 'node__article' as a suggestion
+    // via hook_theme_suggestions_HOOK_alter(), enabling a theme to have
+    // an alternate template file for article nodes.
     foreach (array_reverse($suggestions) as $suggestion) {
       if ($theme_registry->has($suggestion)) {
         $info = $theme_registry->get($suggestion);
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
index 49a95e04f..a98a0d7e9 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
@@ -23,7 +23,7 @@ class Timestamp extends IntegerData implements DateTimeInterface {
   /**
    * The data value as a UNIX timestamp.
    *
-   * @var integer
+   * @var int
    */
   protected $value;
 
diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
index be5bcd4e5..adf91c925 100644
--- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php
+++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php
@@ -260,7 +260,7 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
       $constraints['NotNull'] = array();
     }
     // Check if the class provides allowed values.
-    if (is_subclass_of($definition->getClass(),'Drupal\Core\TypedData\OptionsProviderInterface')) {
+    if (is_subclass_of($definition->getClass(), 'Drupal\Core\TypedData\OptionsProviderInterface')) {
       $constraints['AllowedValues'] = array();
     }
     return $constraints;
diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php b/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php
index 3a0220161..73ad54154 100644
--- a/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php
+++ b/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php
@@ -26,11 +26,13 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
    *   The plugin configuration array, i.e. an array with the following keys:
    *   - data_definition: The data definition object, i.e. an instance of
    *     \Drupal\Core\TypedData\DataDefinitionInterface.
-   *   - name: (optional) If a property or list item is to be created, the name
-   *     of the property or the delta of the list item.
-   *   - parent: (optional) If a property or list item is to be created, the
-   *     parent typed data object implementing either the ListInterface or the
-   *     ComplexDataInterface.
+   *   - name: The name of the property or the delta of the list item if a
+   *     property or list item is to be created. Otherwise, this should be set
+   *     to NULL, but the key must be specified.
+   *   - parent: The parent typed data object implementing either the
+   *     ListInterface or the ComplexDataInterface if a property or list item is
+   *     to be created. Otherwise, this should be set to NULL, but the key must
+   *     be specified.
    *
    * @return \Drupal\Core\TypedData\TypedDataInterface
    *   The instantiated typed data object.
@@ -78,7 +80,7 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
    * class used by a data type is known, this method allows the creation of data
    * definitions for any given data type.
    *
-   * E.g., if a definition for a map is to be created, the following code
+   * For example, if a definition for a map is to be created, the following code
    * could be used instead of calling this method with the argument 'map':
    * @code
    *   $map_definition = \Drupal\Core\TypedData\MapDataDefinition::create();
@@ -137,9 +139,10 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
    * Get a typed data instance for a property of a given typed data object.
    *
    * This method will use prototyping for fast and efficient instantiation of
-   * many property objects with the same property path; e.g.,
+   * many property objects with the same property path; for example,
    * when multiple comments are used comment_body.0.value needs to be
    * instantiated very often.
+   *
    * Prototyping is done by the root object's data type and the given
    * property path, i.e. all property instances having the same property path
    * and inheriting from the same data type are prototyped.
@@ -203,9 +206,10 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
    * Gets default constraints for the given data definition.
    *
    * This generates default constraint definitions based on the data definition;
-   * e.g. a NotNull constraint is generated if the data is defined as required.
-   * Besides that any constraints defined for the data type, i.e. below the
-   * 'constraint' key of the type's plugin definition, are taken into account.
+   * for example, a NotNull constraint is generated if the data is defined as
+   * required. Besides that, any constraints defined for the data type (that is,
+   * below the 'constraint' key of the type's plugin definition) are taken into
+   * account.
    *
    * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition
    *   A data definition.
@@ -222,12 +226,12 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
    *
    * The canonical representation is typically used when data is passed on to
    * other code components. In many use cases, the TypedData object is mostly
-   * unified adapter wrapping a primary value (e.g. a string, an entity...)
-   * which is the canonical representation that consuming code like constraint
+   * unified adapter wrapping a primary value (a string, an entity, etc.) which
+   * is the canonical representation that consuming code like constraint
    * validators are really interested in. For some APIs, though, the domain
-   * object (e.g. Field API's FieldItem and FieldItemList) directly implements
-   * TypedDataInterface, and the canonical representation is thus the data
-   * object itself.
+   * object (for example, Field API's FieldItem and FieldItemList) directly
+   * implements TypedDataInterface, and the canonical representation is thus the
+   * data object itself.
    *
    * When a TypedData object gets validated, for example, its canonical
    * representation is passed on to constraint validators, which thus receive
diff --git a/core/lib/Drupal/Core/Utility/Error.php b/core/lib/Drupal/Core/Utility/Error.php
index ecadc9ba0..965fbac9c 100644
--- a/core/lib/Drupal/Core/Utility/Error.php
+++ b/core/lib/Drupal/Core/Utility/Error.php
@@ -52,7 +52,7 @@ class Error {
       // The first element in the stack is the call, the second element gives us
       // the caller. We skip calls that occurred in one of the classes of the
       // database layer or in one of its global functions.
-      $db_functions = array('db_query',  'db_query_range');
+      $db_functions = array('db_query', 'db_query_range');
       while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
         ((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
           in_array($caller['function'], $db_functions))) {
diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php
index 1dd9a0314..631a3d1a6 100644
--- a/core/lib/Drupal/Core/Validation/ConstraintManager.php
+++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php
@@ -22,8 +22,8 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
  * plugin configuration during plugin instantiation.
  *
  * While core does not prefix constraint plugins, modules have to prefix them
- * with the module name in order to avoid any naming conflicts. E.g. a "profile"
- * module would have to prefix any constraints with "Profile".
+ * with the module name in order to avoid any naming conflicts; for example, a
+ * "profile" module would have to prefix any constraints with "Profile".
  *
  * Constraint plugins may specify data types to which support is limited via the
  * 'type' key of plugin definitions. See
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php
index a85fbf206..e2521664e 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php
@@ -68,8 +68,8 @@ class AllowedValuesConstraintValidator extends ChoiceValidator implements Contai
 
     // The parent implementation ignores values that are not set, but makes
     // sure some choices are available firstly. However, we want to support
-    // empty choices for undefined values, e.g. if a term reference field
-    // points to an empty vocabulary.
+    // empty choices for undefined values; for instance, if a term reference
+    // field points to an empty vocabulary.
     if (!isset($value)) {
       return;
     }
diff --git a/core/misc/states.js b/core/misc/states.js
index 4f3da8df7..30c938ff0 100644
--- a/core/misc/states.js
+++ b/core/misc/states.js
@@ -635,7 +635,7 @@
   $(document).on('state:collapsed', function (e) {
     if (e.trigger) {
       if ($(e.target).is('[open]') === e.value) {
-        $(e.target).find('> summary a').trigger('click');
+        $(e.target).find('> summary').trigger('click');
       }
     }
   });
diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js
index fb82ec054..2011374ce 100644
--- a/core/misc/tableselect.js
+++ b/core/misc/tableselect.js
@@ -42,12 +42,17 @@
     var updateSelectAll = function (state) {
       // Update table's select-all checkbox (and sticky header's if available).
       $table.prev('table.sticky-header').addBack().find('th.select-all input[type="checkbox"]').each(function () {
-        $(this).attr('title', state ? strings.selectNone : strings.selectAll);
+        var $checkbox = $(this);
+        var stateChanged = $checkbox.prop('checked') !== state;
+
+        $checkbox.attr('title', state ? strings.selectNone : strings.selectAll);
 
         /**
-         * @this {HTMLElement}
+         * @checkbox {HTMLElement}
          */
-        this.checked = state;
+        if (stateChanged) {
+          $checkbox.prop('checked', state).trigger('change');
+        }
       });
     };
 
@@ -57,18 +62,22 @@
         // Loop through all checkboxes and set their state to the select all
         // checkbox' state.
         checkboxes.each(function () {
+          var $checkbox = $(this);
+          var stateChanged = $checkbox.prop('checked') !== event.target.checked;
 
           /**
-           * @this {HTMLElement}
+           * @checkbox {HTMLElement}
            */
-          this.checked = event.target.checked;
+          if (stateChanged) {
+            $checkbox.prop('checked', event.target.checked).trigger('change');
+          }
           // Either add or remove the selected class based on the state of the
           // check all checkbox.
 
           /**
-           * @this {HTMLElement}
+           * @checkbox {HTMLElement}
            */
-          $(this).closest('tr').toggleClass('selected', this.checked);
+          $checkbox.closest('tr').toggleClass('selected', this.checked);
         });
         // Update the title and the state of the check all box.
         updateSelectAll(event.target.checked);
diff --git a/core/modules/action/migration_templates/d6_action.yml b/core/modules/action/migration_templates/d6_action.yml
new file mode 100644
index 000000000..592ed1805
--- /dev/null
+++ b/core/modules/action/migration_templates/d6_action.yml
@@ -0,0 +1,39 @@
+id: d6_action
+label: Actions
+migration_tags:
+  - Drupal 6
+source:
+  plugin: action
+process:
+  id:
+    -
+      plugin: machine_name
+      source: aid
+  label: description
+  type: type
+  plugin:
+    -
+      plugin: static_map
+      source: callback
+      map:
+        system_goto_action: action_goto_action
+        system_send_email_action: action_send_email_action
+        system_message_action: action_message_action
+        user_block_ip_action: 0
+        imagecache_flush_action: 0
+        imagecache_generate_all_action: 0
+        imagecache_generate_action: 0
+      bypass: true
+    -
+      plugin: skip_on_empty
+      method: row
+  configuration:
+    -
+      plugin: default_value
+      source: parameters
+      default_value: "a:0:{}"
+    -
+      plugin: callback
+      callable: unserialize
+destination:
+  plugin: entity:action
diff --git a/core/modules/action/migration_templates/d7_action.yml b/core/modules/action/migration_templates/d7_action.yml
new file mode 100644
index 000000000..03b869af1
--- /dev/null
+++ b/core/modules/action/migration_templates/d7_action.yml
@@ -0,0 +1,36 @@
+id: d7_action
+label: Actions
+migration_tags:
+  - Drupal 7
+source:
+  plugin: action
+process:
+  id:
+    -
+      plugin: machine_name
+      source: aid
+  label: label
+  type: type
+  plugin:
+    -
+      plugin: static_map
+      source: callback
+      map:
+        system_goto_action: action_goto_action
+        system_send_email_action: action_send_email_action
+        system_message_action: action_message_action
+        system_block_ip_action: 0
+      bypass: true
+    -
+      plugin: skip_on_empty
+      method: row
+  configuration:
+    -
+      plugin: default_value
+      source: parameters
+      default_value: "a:0:{}"
+    -
+      plugin: callback
+      callable: unserialize
+destination:
+  plugin: entity:action
diff --git a/core/modules/action/src/Plugin/migrate/source/Action.php b/core/modules/action/src/Plugin/migrate/source/Action.php
new file mode 100644
index 000000000..b9cb2c719
--- /dev/null
+++ b/core/modules/action/src/Plugin/migrate/source/Action.php
@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\action\Plugin\migrate\source\Action.
+ */
+
+namespace Drupal\action\Plugin\migrate\source;
+
+use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
+use Drupal\migrate\Row;
+
+/**
+ * Drupal action source from database.
+ *
+ * @MigrateSource(
+ *   id = "action",
+ *   source_provider = "system"
+ * )
+ */
+class Action extends DrupalSqlBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function query() {
+    return $this->select('actions', 'a')
+      ->fields('a');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function fields() {
+    $fields = array(
+      'aid' => $this->t('Action ID'),
+      'type' => $this->t('Module'),
+      'callback' => $this->t('Callback function'),
+      'parameters' => $this->t('Action configuration'),
+    );
+    if ($this->getModuleSchemaVersion('system') >= 7000) {
+      $fields['label'] = $this->t('Label of the action');
+    }
+    else {
+      $fields['description'] = $this->t('Action description');
+    }
+    return $fields;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getIds() {
+    $ids['aid']['type'] = 'string';
+    return $ids;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function prepareRow(Row $row) {
+    $aid = $row->getSourceProperty('aid');
+    if (is_numeric($aid)) {
+      if ($this->getModuleSchemaVersion('system') >= 7000) {
+        $label = $row->getSourceProperty('label');
+      }
+      else {
+        $label = $row->getSourceProperty('description');
+      }
+      $row->setSourceProperty('aid', $label);
+    }
+  }
+
+}
diff --git a/core/modules/action/src/Plugin/migrate/source/d6/Action.php b/core/modules/action/src/Plugin/migrate/source/d6/Action.php
deleted file mode 100644
index 2ca774117..000000000
--- a/core/modules/action/src/Plugin/migrate/source/d6/Action.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\action\Plugin\migrate\source\d6\Action.
- */
-
-namespace Drupal\action\Plugin\migrate\source\d6;
-
-use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
-
-/**
- * Drupal 6 action source from database.
- *
- * @MigrateSource(
- *   id = "d6_action"
- * )
- */
-class Action extends DrupalSqlBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function query() {
-    $query = $this->select('actions', 'a')
-      ->fields('a', array(
-        'aid',
-        'type',
-        'callback',
-        'parameters',
-        'description',
-      )
-    );
-    return $query;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function fields() {
-    return array(
-      'aid' => $this->t('Action ID'),
-      'type' => $this->t('Module'),
-      'callback' => $this->t('Callback function'),
-      'parameters' => $this->t('Action configuration'),
-      'description' => $this->t('Action description'),
-    );
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getIds() {
-    $ids['aid']['type'] = 'string';
-    return $ids;
-  }
-
-}
diff --git a/core/modules/action/src/Tests/Migrate/d6/MigrateActionsTest.php b/core/modules/action/src/Tests/Migrate/d6/MigrateActionsTest.php
new file mode 100644
index 000000000..c37a9a771
--- /dev/null
+++ b/core/modules/action/src/Tests/Migrate/d6/MigrateActionsTest.php
@@ -0,0 +1,77 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\action\Tests\Migrate\d6\MigrateActionsTest.
+ */
+
+namespace Drupal\action\Tests\Migrate\d6;
+
+use Drupal\system\Entity\Action;
+use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
+
+/**
+ * Tests migration of action items.
+ *
+ * @group migrate_drupal_6
+ */
+class MigrateActionsTest extends MigrateDrupal6TestBase {
+
+  public static $modules = ['action', 'comment', 'node'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->executeMigration('d6_action');
+  }
+
+  /**
+   * Test Drupal 6 action migration to Drupal 8.
+   */
+  public function testActions() {
+    // Test default actions.
+    $this->assertEntity('node_publish_action', 'Publish post', 'node', []);
+    $this->assertEntity('node_make_sticky_action', 'Make post sticky', 'node', []);
+    $this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
+    $this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
+
+    // Test advanced actions.
+    $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
+    $this->assertEntity('change_the_author_of_a_post', 'Change the author of a post', 'node', ["owner_uid" => "2"]);
+    $this->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
+    $this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
+    $this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
+      "recipient" => "test@example.com",
+      "subject" => "Drupal migration test",
+      "message" => "Drupal migration test"
+    ]);
+    $this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
+
+  }
+
+  /**
+   * Asserts various aspects of an Action entity.
+   *
+   * @param string $id
+   *   The expected Action ID.
+   * @param string $label
+   *   The expected Action label.
+   * @param string $type
+   *   The expected Action type.
+   * @param array $configuration
+   *   The expected Action configuration.
+   */
+  protected function assertEntity($id, $label, $type, $configuration) {
+    $action = Action::load($id);
+
+    $this->assertTrue($action instanceof Action);
+    /** @var \Drupal\system\Entity\Action $action */
+    $this->assertIdentical($id, $action->id());
+    $this->assertIdentical($label, $action->label());
+    $this->assertIdentical($type, $action->getType());
+    $this->assertIdentical($configuration, $action->get('configuration'));
+  }
+
+}
diff --git a/core/modules/action/src/Tests/Migrate/d7/MigrateActionsTest.php b/core/modules/action/src/Tests/Migrate/d7/MigrateActionsTest.php
new file mode 100644
index 000000000..1d5421901
--- /dev/null
+++ b/core/modules/action/src/Tests/Migrate/d7/MigrateActionsTest.php
@@ -0,0 +1,77 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\action\Tests\Migrate\d7\MigrateActionsTest.
+ */
+
+namespace Drupal\action\Tests\Migrate\d7;
+
+use Drupal\system\Entity\Action;
+use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
+
+/**
+ * Tests migration of action items.
+ *
+ * @group action
+ */
+class MigrateActionsTest extends MigrateDrupal7TestBase {
+
+  public static $modules = ['action', 'comment', 'node'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->executeMigration('d7_action');
+  }
+
+  /**
+   * Test Drupal 7 action migration to Drupal 8.
+   */
+  public function testActions() {
+    // Test default actions.
+    $this->assertEntity('node_publish_action', 'Publish content', 'node', []);
+    $this->assertEntity('node_make_sticky_action', 'Make content sticky', 'node', []);
+    $this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
+    $this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
+
+    // Test advanced actions.
+    $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
+    $this->assertEntity('change_the_author_of_content', 'Change the author of content', 'node', ["owner_uid" => "2"]);
+    $this->assertEntity('unpublish_content_containing_keyword_s_', 'Unpublish content containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
+    $this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
+    $this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
+      "recipient" => "test@example.com",
+      "subject" => "Drupal migration test",
+      "message" => "Drupal migration test"
+    ]);
+    $this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
+
+  }
+
+  /**
+   * Asserts various aspects of an Action entity.
+   *
+   * @param string $id
+   *   The expected Action ID.
+   * @param string $label
+   *   The expected Action label.
+   * @param string $type
+   *   The expected Action type.
+   * @param array $configuration
+   *   The expected Action configuration.
+   */
+  protected function assertEntity($id, $label, $type, $configuration) {
+    $action = Action::load($id);
+
+    $this->assertTrue($action instanceof Action);
+    /** @var \Drupal\system\Entity\Action $action */
+    $this->assertIdentical($id, $action->id());
+    $this->assertIdentical($label, $action->label());
+    $this->assertIdentical($type, $action->getType());
+    $this->assertIdentical($configuration, $action->get('configuration'));
+  }
+
+}
diff --git a/core/modules/action/tests/src/Unit/Plugin/migrate/source/d6/ActionTest.php b/core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php
similarity index 76%
rename from core/modules/action/tests/src/Unit/Plugin/migrate/source/d6/ActionTest.php
rename to core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php
index 148865aa2..44b8fbad3 100644
--- a/core/modules/action/tests/src/Unit/Plugin/migrate/source/d6/ActionTest.php
+++ b/core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php
@@ -2,15 +2,15 @@
 
 /**
  * @file
- * Contains \Drupal\Tests\action\Unit\Plugin\migrate\source\d6\ActionTest.
+ * Contains \Drupal\Tests\action\Unit\Plugin\migrate\source\ActionTest.
  */
 
-namespace Drupal\Tests\action\Unit\Plugin\migrate\source\d6;
+namespace Drupal\Tests\action\Unit\Plugin\migrate\source;
 
 use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
 
 /**
- * Tests D6 actions source plugin.
+ * Tests actions source plugin.
  *
  * @group action
  */
@@ -18,14 +18,14 @@ class ActionTest extends MigrateSqlSourceTestCase {
 
   // The plugin system is not working during unit testing so the source plugin
   // class needs to be manually specified.
-  const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\d6\Action';
+  const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\Action';
 
   // The fake Migration configuration entity.
   protected $migrationConfiguration = array(
     // The ID of the entity, can be any string.
     'id' => 'test',
     'source' => array(
-      'plugin' => 'd6_action',
+      'plugin' => 'action',
     ),
   );
 
@@ -33,14 +33,14 @@ class ActionTest extends MigrateSqlSourceTestCase {
 
   protected $expectedResults = array(
     array(
-      'aid' => '1',
+      'aid' => 'Redirect to node list page',
       'type' => 'system',
       'callback' => 'system_goto_action',
       'parameters' => 'a:1:{s:3:"url";s:4:"node";}',
       'description' => 'Redirect to node list page',
     ),
     array(
-      'aid' => '2',
+      'aid' => 'Test notice email',
       'type' => 'system',
       'callback' => 'system_send_email_action',
       'parameters' => 'a:3:{s:9:"recipient";s:7:"%author";s:7:"subject";s:4:"Test";s:7:"message";s:4:"Test',
@@ -50,15 +50,15 @@ class ActionTest extends MigrateSqlSourceTestCase {
       'aid' => 'comment_publish_action',
       'type' => 'comment',
       'callback' => 'comment_publish_action',
-      'parameters' => null,
-      'description' => null,
+      'parameters' => NULL,
+      'description' => NULL,
     ),
     array(
       'aid' => 'node_publish_action',
       'type' => 'comment',
       'callback' => 'node_publish_action',
-      'parameters' => null,
-      'description' => null,
+      'parameters' => NULL,
+      'description' => NULL,
     ),
   );
 
diff --git a/core/modules/automated_cron/automated_cron.info.yml b/core/modules/automated_cron/automated_cron.info.yml
index a7480e964..dd947279c 100644
--- a/core/modules/automated_cron/automated_cron.info.yml
+++ b/core/modules/automated_cron/automated_cron.info.yml
@@ -4,3 +4,4 @@ description: 'Provides an automated way to run cron jobs, by executing them at t
 package: Core
 version: VERSION
 core: 8.x
+configure: system.cron_settings
diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php
index 078aac64c..5a28bad6a 100644
--- a/core/modules/block/block.api.php
+++ b/core/modules/block/block.api.php
@@ -190,7 +190,8 @@ function hook_block_build_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\
  * @param \Drupal\block\Entity\Block $block
  *   The block instance.
  * @param string $operation
- *   The operation to be performed, e.g., 'view', 'create', 'delete', 'update'.
+ *   The operation to be performed; for instance, 'view', 'create', 'delete', or
+ *   'update'.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The user object to perform the access check operation on.
  *
diff --git a/core/modules/block/src/BlockAccessControlHandler.php b/core/modules/block/src/BlockAccessControlHandler.php
index 92b54a4ae..4529647d6 100644
--- a/core/modules/block/src/BlockAccessControlHandler.php
+++ b/core/modules/block/src/BlockAccessControlHandler.php
@@ -127,7 +127,22 @@ class BlockAccessControlHandler extends EntityAccessControlHandler implements En
       }
       elseif ($this->resolveConditions($conditions, 'and') !== FALSE) {
         // Delegate to the plugin.
-        $access = $entity->getPlugin()->access($account, TRUE);
+        $block_plugin = $entity->getPlugin();
+        try {
+          if ($block_plugin instanceof ContextAwarePluginInterface) {
+            $contexts = $this->contextRepository->getRuntimeContexts(array_values($block_plugin->getContextMapping()));
+            $this->contextHandler->applyContextMapping($block_plugin, $contexts);
+          }
+          $access = $block_plugin->access($account, TRUE);
+        }
+        catch (ContextException $e) {
+          // Setting access to forbidden if any context is missing for the same
+          // reasons as with conditions (described in the comment above).
+          // @todo Avoid setting max-age 0 for some or all cases, for example by
+          //   treating available contexts without value differently in
+          //   https://www.drupal.org/node/2521956.
+          $access = AccessResult::forbidden()->setCacheMaxAge(0);
+        }
       }
       else {
         $access = AccessResult::forbidden();
diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php
index a7cb441f7..e7279ceb6 100644
--- a/core/modules/block/src/BlockViewBuilder.php
+++ b/core/modules/block/src/BlockViewBuilder.php
@@ -211,14 +211,15 @@ class BlockViewBuilder extends EntityViewBuilder {
     if ($content !== NULL && !Element::isEmpty($content)) {
       // Place the $content returned by the block plugin into a 'content' child
       // element, as a way to allow the plugin to have complete control of its
-      // properties and rendering (e.g., its own #theme) without conflicting
-      // with the properties used above, or alternate ones used by alternate
-      // block rendering approaches in contrib (e.g., Panels). However, the use
-      // of a child element is an implementation detail of this particular block
-      // rendering approach. Semantically, the content returned by the plugin
-      // "is the" block, and in particular, #attributes and #contextual_links is
-      // information about the *entire* block. Therefore, we must move these
-      // properties from $content and merge them into the top-level element.
+      // properties and rendering (for instance, its own #theme) without
+      // conflicting with the properties used above, or alternate ones used by
+      // alternate block rendering approaches in contrib (for instance, Panels).
+      // However, the use of a child element is an implementation detail of this
+      // particular block rendering approach. Semantically, the content returned
+      // by the plugin "is the" block, and in particular, #attributes and
+      // #contextual_links is information about the *entire* block. Therefore,
+      // we must move these properties from $content and merge them into the
+      // top-level element.
       foreach (array('#attributes', '#contextual_links') as $property) {
         if (isset($content[$property])) {
           $build[$property] += $content[$property];
@@ -232,8 +233,8 @@ class BlockViewBuilder extends EntityViewBuilder {
     else {
       // Abort rendering: render as the empty string and ensure this block is
       // render cached, so we can avoid the work of having to repeatedly
-      // determine whether the block is empty. E.g. modifying or adding entities
-      // could cause the block to no longer be empty.
+      // determine whether the block is empty. For instance, modifying or adding
+      // entities could cause the block to no longer be empty.
       $build = array(
         '#markup' => '',
         '#cache' => $build['#cache'],
diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php
index 4d0f03a1e..6b5566790 100644
--- a/core/modules/block/src/Tests/BlockUiTest.php
+++ b/core/modules/block/src/Tests/BlockUiTest.php
@@ -241,6 +241,7 @@ class BlockUiTest extends WebTestBase {
 
     $this->drupalGet('');
     $this->assertText('Test context-aware block');
+    $this->assertText('User context found.');
     $this->assertRaw($expected_text);
 
     // Test context mapping allows empty selection for optional contexts.
@@ -251,6 +252,7 @@ class BlockUiTest extends WebTestBase {
     $this->drupalPostForm(NULL, $edit, 'Save block');
     $this->drupalGet('');
     $this->assertText('No context mapping selected.');
+    $this->assertNoText('User context found.');
   }
 
   /**
diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
index f7b3ffe76..3adefe0bb 100644
--- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php
+++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
@@ -265,7 +265,7 @@ class DisplayBlockTest extends ViewTestBase {
     $result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
     $this->assertTrue(empty($result), 'The title is not visible.');
 
-    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:system.site', 'config:views.view.test_view_block' ,'rendered']));
+    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:system.site', 'config:views.view.test_view_block' , 'rendered']));
   }
 
   /**
@@ -291,7 +291,7 @@ class DisplayBlockTest extends ViewTestBase {
     $this->assertEqual(0, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
     // Ensure that the view cachability metadata is propagated even, for an
     // empty block.
-    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
+    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
     $this->assertCacheContexts(['url.query_args:_wrapper_format']);
 
     // Add a header displayed on empty result.
@@ -309,7 +309,7 @@ class DisplayBlockTest extends ViewTestBase {
 
     $this->drupalGet($url);
     $this->assertEqual(1, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
-    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
+    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
     $this->assertCacheContexts(['url.query_args:_wrapper_format']);
 
     // Hide the header on empty results.
@@ -327,7 +327,7 @@ class DisplayBlockTest extends ViewTestBase {
 
     $this->drupalGet($url);
     $this->assertEqual(0, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
-    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
+    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
     $this->assertCacheContexts(['url.query_args:_wrapper_format']);
 
     // Add an empty text.
@@ -344,7 +344,7 @@ class DisplayBlockTest extends ViewTestBase {
 
     $this->drupalGet($url);
     $this->assertEqual(1, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
-    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' ,'rendered']));
+    $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'rendered']));
     $this->assertCacheContexts(['url.query_args:_wrapper_format']);
   }
 
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
index 013dbae75..dcb79bdb4 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
@@ -8,6 +8,8 @@
 namespace Drupal\block_test\Plugin\Block;
 
 use Drupal\Core\Block\BlockBase;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\user\UserInterface;
 
 /**
  * Provides a context-aware block.
@@ -35,4 +37,15 @@ class TestContextAwareBlock extends BlockBase {
     );
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function blockAccess(AccountInterface $account) {
+    if ($this->getContextValue('user') instanceof UserInterface) {
+      drupal_set_message('User context found.');
+    }
+
+    return parent::blockAccess($account);
+  }
+
 }
diff --git a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php
index bd943eef4..44f7c751d 100644
--- a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php
+++ b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php
@@ -24,7 +24,7 @@ class RevisionRelationshipsTest extends ViewTestBase {
    *
    * @var array
    */
-  public static $modules = array('block_content' ,'block_content_test_views');
+  public static $modules = array('block_content' , 'block_content_test_views');
 
   /**
    * Views used by this test.
diff --git a/core/modules/book/src/BookExport.php b/core/modules/book/src/BookExport.php
index 8a49368a9..420b8c563 100644
--- a/core/modules/book/src/BookExport.php
+++ b/core/modules/book/src/BookExport.php
@@ -58,9 +58,9 @@ class BookExport {
    * The given node is embedded to its absolute depth in a top level section. For
    * example, a child node with depth 2 in the hierarchy is contained in
    * (otherwise empty) <div> elements corresponding to depth 0 and depth 1.
-   * This is intended to support WYSIWYG output - e.g., level 3 sections always
-   * look like level 3 sections, no matter their depth relative to the node
-   * selected to be exported as printer-friendly HTML.
+   * This is intended to support WYSIWYG output; for instance, level 3 sections
+   * always look like level 3 sections, no matter their depth relative to the
+   * node selected to be exported as printer-friendly HTML.
    *
    * @param \Drupal\node\NodeInterface $node
    *   The node to export.
diff --git a/core/modules/book/src/Plugin/migrate/source/d6/Book.php b/core/modules/book/src/Plugin/migrate/source/d6/Book.php
index a1ecbb6b3..86fdeeeb2 100644
--- a/core/modules/book/src/Plugin/migrate/source/d6/Book.php
+++ b/core/modules/book/src/Plugin/migrate/source/d6/Book.php
@@ -53,15 +53,15 @@ class Book extends DrupalSqlBase {
       'mlid' => $this->t('Menu link ID'),
       'plid' => $this->t('Parent link ID'),
       'weight' => $this->t('Weight'),
-      'p1' => $this->t('The first mlid in the materialized path.'),
-      'p2' => $this->t('The second mlid in the materialized path.'),
-      'p3' => $this->t('The third mlid in the materialized path.'),
-      'p4' => $this->t('The fourth mlid in the materialized path.'),
-      'p5' => $this->t('The fifth mlid in the materialized path.'),
-      'p6' => $this->t('The sixth mlid in the materialized path.'),
-      'p7' => $this->t('The seventh mlid in the materialized path.'),
-      'p8' => $this->t('The eight mlid in the materialized path.'),
-      'p9' => $this->t('The nine mlid in the materialized path.'),
+      'p1' => $this->t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
+      'p2' => $this->t('The second mlid in the materialized path. See p1.'),
+      'p3' => $this->t('The third mlid in the materialized path. See p1.'),
+      'p4' => $this->t('The fourth mlid in the materialized path. See p1.'),
+      'p5' => $this->t('The fifth mlid in the materialized path. See p1.'),
+      'p6' => $this->t('The sixth mlid in the materialized path. See p1.'),
+      'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
+      'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
+      'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
     );
   }
 
diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php
index b1c9fa3f2..54d0fafd1 100644
--- a/core/modules/book/src/Tests/BookTest.php
+++ b/core/modules/book/src/Tests/BookTest.php
@@ -338,6 +338,9 @@ class BookTest extends WebTestBase {
    *   A book node ID or set to 'new' to create a new book.
    * @param int|null $parent
    *   (optional) Parent book reference ID. Defaults to NULL.
+   *
+   * @return \Drupal\node\NodeInterface
+   *   The created node.
    */
   function createBookNode($book_nid, $parent = NULL) {
     // $number does not use drupal_static as it should not be reset
diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
index d2f5ef17a..73876ec5f 100644
--- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
+++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
@@ -101,6 +101,32 @@
           return element;
         };
 
+        // Overrides default implementation. Used to populate the "classes"
+        // property of the widget's "data" property, which is used for the
+        // "widget styles" functionality
+        // (http://docs.ckeditor.com/#!/guide/dev_styles-section-widget-styles).
+        // Is applied to whatever the main element of the widget is (<figure> or
+        // <img>). The classes in image2_captionedClass are always added due to
+        // a bug in CKEditor. In the case of drupalimage, we don't ever want to
+        // add that class, because the widget template already contains it.
+        // @see http://dev.ckeditor.com/ticket/13888
+        // @see https://www.drupal.org/node/2268941
+        var originalGetClasses = widgetDefinition.getClasses;
+        widgetDefinition.getClasses = function () {
+          var classes = originalGetClasses.call(this);
+          var captionedClasses = (this.editor.config.image2_captionedClass || '').split(/\s+/);
+
+          if (captionedClasses.length && classes) {
+            for (var i = 0; i < captionedClasses.length; i++) {
+              if (captionedClasses[i] in classes) {
+                delete classes[captionedClasses[i]];
+              }
+            }
+          }
+
+          return classes;
+        };
+
         // Protected; keys of the widget data to be sent to the Drupal dialog.
         // Keys in the hash are the keys for image2's data, values are the keys
         // that the Drupal dialog uses.
diff --git a/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
index 44e89dffd..d1d666c5b 100644
--- a/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
+++ b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
@@ -244,6 +244,27 @@
         };
       // Low priority to ensure drupalimage's event handler runs first.
       }, null, null, 20);
+    },
+
+    afterInit: function (editor) {
+      var disableButtonIfOnWidget = function (evt) {
+        var widget = editor.widgets.focused;
+        if (widget && widget.name === 'image') {
+          this.setState(CKEDITOR.TRISTATE_DISABLED);
+          evt.cancel();
+        }
+      };
+
+      // Disable alignment buttons if the align filter is not enabled.
+      if (editor.plugins.justify && !editor.config.drupalImageCaption_alignFilterEnabled) {
+        var cmd;
+        var commands = ['justifyleft', 'justifycenter', 'justifyright', 'justifyblock'];
+        for (var n = 0; n < commands.length; n++) {
+          cmd = editor.getCommand(commands[n]);
+          cmd.contextSensitive = 1;
+          cmd.on('refresh', disableButtonIfOnWidget, null, null, 4);
+        }
+      }
     }
   });
 
diff --git a/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php b/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php
index 8c8d2c95f..5bd397fe4 100644
--- a/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php
+++ b/core/modules/ckeditor/src/CKEditorPluginContextualInterface.php
@@ -16,9 +16,10 @@ use Drupal\editor\Entity\Editor;
  * or enable themselves based on the configuration of another setting, such as
  * enabling based on a particular button being present in the toolbar.
  *
- * If a contextually enabled CKEditor plugin must also be configurable (e.g. in
- * the case where it must be enabled based on an explicit setting), then one
- * must also implement the CKEditorPluginConfigurableInterface interface.
+ * If a contextually enabled CKEditor plugin must also be configurable (for
+ * instance, in the case where it must be enabled based on an explicit setting),
+ * then one must also implement the CKEditorPluginConfigurableInterface
+ * interface.
  *
  * @see \Drupal\ckeditor\CKEditorPluginInterface
  * @see \Drupal\ckeditor\CKEditorPluginButtonsInterface
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
index d1b317e84..2dbb4b1b0 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
@@ -477,11 +477,11 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter
           //     Once validated, an element or its property cannot be
           //     invalidated by another rule.
           // That means that the most permissive setting wins. Which means that
-          // it will still be allowed by CKEditor to e.g. define any style, no
-          // matter what the "*" tag's restrictions may be. If there's a setting
-          // for either the "style" or "class" attribute, it cannot possibly be
-          // more permissive than what was set above. Hence: inherit from the
-          // "*" tag where possible.
+          // it will still be allowed by CKEditor, for instance, to define any
+          // style, no matter what the "*" tag's restrictions may be. If there
+          // is a setting for either the "style" or "class" attribute, it cannot
+          // possibly be more permissive than what was set above. Hence, inherit
+          // from the "*" tag where possible.
           if (isset($html_restrictions['allowed']['*'])) {
             $wildcard = $html_restrictions['allowed']['*'];
             if (isset($wildcard['style'])) {
diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
index abf409b64..5ae5e85b2 100644
--- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
+++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
@@ -187,8 +187,8 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
     // Hidden CKEditor instance. We need a hidden CKEditor instance with all
     // plugins enabled, so we can retrieve CKEditor's per-feature metadata (on
     // which tags, attributes, styles and classes are enabled). This metadata is
-    // necessary for certain filters' (e.g. the html_filter filter) settings to
-    // be updated accordingly.
+    // necessary for certain filters' (for instance, the html_filter filter)
+    // settings to be updated accordingly.
     // Get a list of all external plugins and their corresponding files.
     $plugins = array_keys($this->ckeditorPluginManager->getDefinitions());
     $all_external_plugins = array();
@@ -348,9 +348,10 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
       // If this language code is available in a Drupal mapping, use that to
       // compute a possibility for matching from the Drupal langcode to the
       // CKEditor langcode.
-      // e.g. CKEditor uses the langcode 'no' for Norwegian, Drupal uses 'nb'.
-      // This would then remove the 'no' => 'no' mapping and replace it with
-      // 'nb' => 'no'. Now Drupal knows which CKEditor translation to load.
+      // For instance, CKEditor uses the langcode 'no' for Norwegian, Drupal
+      // uses 'nb'. This would then remove the 'no' => 'no' mapping and replace
+      // it with 'nb' => 'no'. Now Drupal knows which CKEditor translation to
+      // load.
       if (isset($language_mappings[$langcode]) && !isset($langcodes[$language_mappings[$langcode]])) {
         $langcodes[$language_mappings[$langcode]] = $langcode;
         unset($langcodes[$langcode]);
diff --git a/core/modules/color/color.js b/core/modules/color/color.js
index a870e9ea1..ed68732fa 100644
--- a/core/modules/color/color.js
+++ b/core/modules/color/color.js
@@ -247,7 +247,7 @@
           var i = inputs.length;
           if (inputs.length) {
             var toggleClick = true;
-            var lock = $('<button class="color-palette__lock link">' + Drupal.t('Unlock') + '</button>').on('click', function (e) {
+            var lock = $('<button class="color-palette__lock">' + Drupal.t('Unlock') + '</button>').on('click', function (e) {
               e.preventDefault();
               if (toggleClick) {
                 $(this).addClass('is-unlocked').html(Drupal.t('Lock'));
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index dd48e4ac0..15619ff4c 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -9,7 +9,7 @@ use Drupal\Core\Asset\CssOptimizer;
 use Drupal\Component\Utility\Bytes;
 use Drupal\Component\Utility\Environment;
 use Drupal\Core\Block\BlockPluginInterface;
-use Drupal\Core\Cache\Cache;
+use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Render\Element\Textfield;
@@ -118,9 +118,13 @@ function color_block_view_system_branding_block_alter(array &$build, BlockPlugin
  */
 function color_block_view_pre_render(array $build) {
   $theme_key = \Drupal::theme()->getActiveTheme()->getName();
+  $config = \Drupal::config('color.theme.' . $theme_key);
+  CacheableMetadata::createFromRenderArray($build)
+    ->addCacheableDependency($config)
+    ->applyTo($build);
 
   // Override logo.
-  $logo = \Drupal::config('color.theme.' . $theme_key)->get('logo');
+  $logo = $config->get('logo');
   if ($logo && $build['content']['site_logo'] && preg_match('!' . $theme_key . '/logo.svg$!', $build['content']['site_logo']['#uri'])) {
     $build['content']['site_logo']['#uri'] = file_create_url($logo);
   }
@@ -193,7 +197,6 @@ function color_get_palette($theme, $default = FALSE) {
  * @see color_scheme_form_submit()
  */
 function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) {
-  $base = drupal_get_path('module', 'color');
   $info = color_get_info($theme);
 
   $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
@@ -500,9 +503,6 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
     ->set('stylesheets', $css)
     ->set('files', $paths['files'])
     ->save();
-
-  // Clear the library cache.
-  Cache::invalidateTags(['library_info']);
 }
 
 /**
diff --git a/core/modules/color/color.services.yml b/core/modules/color/color.services.yml
new file mode 100644
index 000000000..9575785b6
--- /dev/null
+++ b/core/modules/color/color.services.yml
@@ -0,0 +1,6 @@
+services:
+  color.config_cache_invalidator:
+    class: Drupal\color\EventSubscriber\ColorConfigCacheInvalidator
+    arguments: ['@cache_tags.invalidator']
+    tags:
+      - { name: event_subscriber }
diff --git a/core/modules/color/css/color.admin.css b/core/modules/color/css/color.admin.css
index 376275e97..69311c2a8 100644
--- a/core/modules/color/css/color.admin.css
+++ b/core/modules/color/css/color.admin.css
@@ -74,6 +74,8 @@ button.color-palette__lock,
   left: -10px;
   direction: ltr;
   text-indent: -9999px;
+  border: 0;
+  outline: 0;
 }
 [dir="rtl"] button.color-palette__lock,
 [dir="rtl"] .color-palette__lock {
diff --git a/core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php b/core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php
new file mode 100644
index 000000000..3af8d4042
--- /dev/null
+++ b/core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\color\EventSubscriber\ColorConfigCacheInvalidator.
+ */
+
+namespace Drupal\color\EventSubscriber;
+
+use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
+use Drupal\Core\Config\ConfigCrudEvent;
+use Drupal\Core\Config\ConfigEvents;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * A subscriber invalidating cache tags when color config objects are saved.
+ */
+class ColorConfigCacheInvalidator implements EventSubscriberInterface {
+
+  /**
+   * The cache tags invalidator.
+   *
+   * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
+   */
+  protected $cacheTagsInvalidator;
+
+  /**
+   * Constructs a ColorConfigCacheInvalidator object.
+   *
+   * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
+   *   The cache tags invalidator.
+   */
+  public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
+    $this->cacheTagsInvalidator = $cache_tags_invalidator;
+  }
+
+  /**
+   * Invalidate cache tags when a color theme config object changes.
+   *
+   * @param \Drupal\Core\Config\ConfigCrudEvent $event
+   *   The Event to process.
+   */
+  public function onChange(ConfigCrudEvent $event) {
+    // Changing a theme's color settings causes the theme's asset library
+    // containing the color CSS file to be altered to use a different file.
+    if (strpos($event->getConfig()->getName(), 'color.theme.') === 0) {
+      $this->cacheTagsInvalidator->invalidateTags(['library_info']);
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getSubscribedEvents() {
+    $events[ConfigEvents::SAVE][] = ['onChange'];
+    $events[ConfigEvents::DELETE][] = ['onChange'];
+
+    return $events;
+  }
+
+}
diff --git a/core/modules/color/src/Tests/ColorTest.php b/core/modules/color/src/Tests/ColorTest.php
index 1d1b72e33..4a4106444 100644
--- a/core/modules/color/src/Tests/ColorTest.php
+++ b/core/modules/color/src/Tests/ColorTest.php
@@ -22,7 +22,7 @@ class ColorTest extends WebTestBase {
    *
    * @var array
    */
-  public static $modules = array('color', 'color_test');
+  public static $modules = array('color', 'color_test', 'block', 'file');
 
   /**
    * A user with administrative permissions.
@@ -194,4 +194,43 @@ class ColorTest extends WebTestBase {
     $this->assertIdentical($GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png', $this->getDrupalSettings()['color']['logo']);
   }
 
+  /**
+   * Test whether the scheme can be set, viewed anonymously and reset.
+   */
+  function testOverrideAndResetScheme() {
+    $settings_path = 'admin/appearance/settings/bartik';
+    $this->config('system.theme')
+      ->set('default', 'bartik')
+      ->save();
+
+    // Place branding block with site name and slogan into header region.
+    $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
+
+    $this->drupalGet('');
+    $this->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
+    $this->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
+
+    // Log in and set the color scheme to 'slate'.
+    $this->drupalLogin($this->bigUser);
+    $edit['scheme'] = 'slate';
+    $this->drupalPostForm($settings_path, $edit, t('Save configuration'));
+
+    // Visit the homepage and ensure color changes.
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertRaw('files/color/bartik-', 'Make sure the color logo is being used.');
+    $this->assertNoRaw('bartik/logo.svg', 'Make sure the original bartik logo does not exist.');
+
+    // Log in and set the color scheme back to default (delete config).
+    $this->drupalLogin($this->bigUser);
+    $edit['scheme'] = 'default';
+    $this->drupalPostForm($settings_path, $edit, t('Save configuration'));
+
+    // Log out and ensure there is no color and we have the original logo.
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
+    $this->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
+  }
+
 }
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index dbeccb655..e333b565a 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -245,7 +245,8 @@ function comment_node_view_alter(array &$build, EntityInterface $node, EntityVie
  * @param \Drupal\comment\CommentInterface $comment
  *   The comment object.
  * @param $view_mode
- *   (optional) View mode; e.g., 'full', 'teaser', etc. Defaults to 'full'.
+ *   (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to
+ *   'full'.
  * @param $langcode
  *   (optional) A language code to use for rendering. Defaults to the global
  *   content language of the current request.
@@ -266,7 +267,8 @@ function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode
  * @param $comments
  *   An array of comments as returned by entity_load_multiple().
  * @param $view_mode
- *   View mode; e.g., 'full', 'teaser', etc.
+ *   (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to
+ *   'full'.
  * @param $langcode
  *   (optional) A string indicating the language field values are to be shown
  *   in. If no language is provided the current content language is used.
@@ -641,8 +643,8 @@ function template_preprocess_comment(&$variables) {
   }
 
   if (theme_get_setting('features.comment_user_picture')) {
-    // To change user picture settings (e.g., image style), edit the 'compact'
-    // view mode on the User entity.
+    // To change user picture settings (for instance, image style), edit the
+    // 'compact' view mode on the User entity.
     $variables['user_picture'] = user_view($account, 'compact');
   }
   else {
diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
index a83ec3930..234075289 100644
--- a/core/modules/comment/src/Plugin/views/filter/NodeComment.php
+++ b/core/modules/comment/src/Plugin/views/filter/NodeComment.php
@@ -25,6 +25,7 @@ class NodeComment extends InOperator {
       CommentItemInterface::CLOSED => $this->t('Closed'),
       CommentItemInterface::OPEN => $this->t('Open'),
     );
+    return $this->valueOptions;
   }
 
 }
diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php
index 4b326a6d8..4b0e9688d 100644
--- a/core/modules/comment/src/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php
@@ -23,7 +23,7 @@ class CommentInterfaceTest extends CommentTestBase {
   /**
    * Set up comments to have subject and preview disabled.
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->drupalLogin($this->adminUser);
     // Make sure that comment field title is not displayed when there's no
diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php
index c7f3e71a5..aa0694228 100644
--- a/core/modules/comment/src/Tests/CommentNonNodeTest.php
+++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php
@@ -240,7 +240,7 @@ class CommentNonNodeTest extends WebTestBase {
    * @param string $subject
    *   Comment subject to find.
    *
-   * @return integer
+   * @return int
    *   Comment ID.
    */
   function getUnapprovedComment($subject) {
diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php
index 2a9b1973f..8d4985a41 100644
--- a/core/modules/comment/src/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/src/Tests/CommentPreviewTest.php
@@ -129,7 +129,7 @@ class CommentPreviewTest extends CommentTestBase {
    * Tests comment edit, preview, and save.
    */
   function testCommentEditPreviewSave() {
-    $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval',  'edit own comments'));
+    $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments'));
     $this->drupalLogin($this->adminUser);
     $this->setCommentPreview(DRUPAL_OPTIONAL);
     $this->setCommentForm(TRUE);
diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php
index 62e43f6a0..17eccb9aa 100644
--- a/core/modules/comment/src/Tests/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/CommentTestBase.php
@@ -288,7 +288,7 @@ abstract class CommentTestBase extends WebTestBase {
   /**
    * Sets the value governing restrictions on anonymous comments.
    *
-   * @param integer $level
+   * @param int $level
    *   The level of the contact information allowed for anonymous comments:
    *   - 0: No contact information allowed.
    *   - 1: Contact information allowed but not required.
@@ -373,7 +373,7 @@ abstract class CommentTestBase extends WebTestBase {
    * @param string $subject
    *   Comment subject to find.
    *
-   * @return integer
+   * @return int
    *   Comment id.
    */
   function getUnapprovedComment($subject) {
diff --git a/core/modules/comment/src/Tests/Views/CommentLinksTest.php b/core/modules/comment/src/Tests/Views/CommentLinksTest.php
index d58c7fe17..90269a19b 100644
--- a/core/modules/comment/src/Tests/Views/CommentLinksTest.php
+++ b/core/modules/comment/src/Tests/Views/CommentLinksTest.php
@@ -47,7 +47,7 @@ class CommentLinksTest extends CommentViewKernelTestBase {
     $view = Views::getView('test_comment');
     $view->setDisplay();
 
-    $view->displayHandlers->get('default')->overrideOption('fields',  [
+    $view->displayHandlers->get('default')->overrideOption('fields', [
       'approve_comment' => [
         'table' => 'comment',
         'field' => 'approve_comment',
@@ -134,7 +134,7 @@ class CommentLinksTest extends CommentViewKernelTestBase {
     $view = Views::getView('test_comment');
     $view->setDisplay();
 
-    $view->displayHandlers->get('default')->overrideOption('fields',  [
+    $view->displayHandlers->get('default')->overrideOption('fields', [
       'replyto_comment' => [
         'table' => 'comment',
         'field' => 'replyto_comment',
diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig
index 14c52eba0..7f0c33297 100644
--- a/core/modules/comment/templates/comment.html.twig
+++ b/core/modules/comment/templates/comment.html.twig
@@ -27,7 +27,7 @@
  * - title: Comment title, linked to the comment.
  * - attributes: HTML attributes for the containing element.
  *   The attributes.class may contain one or more of the following classes:
- *   - comment: The current template type; e.g., 'theming hook'.
+ *   - comment: The current template type; for instance, 'theming hook'.
  *   - by-anonymous: Comment by an unregistered user.
  *   - by-{entity-type}-author: Comment by the author of the parent entity,
  *     eg. by-node-author.
diff --git a/core/modules/config/src/Controller/ConfigController.php b/core/modules/config/src/Controller/ConfigController.php
index 6fb342389..7900ed75b 100644
--- a/core/modules/config/src/Controller/ConfigController.php
+++ b/core/modules/config/src/Controller/ConfigController.php
@@ -142,6 +142,9 @@ class ConfigController implements ContainerInjectionInterface {
 
     $build['diff'] = array(
       '#type' => 'table',
+      '#attributes' => array(
+        'class' => array('diff'),
+      ),
       '#header' => array(
         array('data' => t('Active'), 'colspan' => '2'),
         array('data' => t('Staged'), 'colspan' => '2'),
diff --git a/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php b/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php
index 22d0b114a..82216348e 100644
--- a/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php
+++ b/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php
@@ -27,7 +27,7 @@ class CacheabilityMetadataConfigOverrideIntegrationTest extends WebTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // @todo If our block does not contain any content then the cache context
diff --git a/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideTest.php b/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideTest.php
index b4752b5f9..e559d8038 100644
--- a/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideTest.php
+++ b/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideTest.php
@@ -32,7 +32,7 @@ class CacheabilityMetadataConfigOverrideTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->installEntitySchema('block_content');
     $this->installConfig(['config_override_test']);
diff --git a/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php
index e12789222..3d61c9e3f 100644
--- a/core/modules/config/src/Tests/ConfigCRUDTest.php
+++ b/core/modules/config/src/Tests/ConfigCRUDTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Config\ConfigNameException;
 use Drupal\Core\Config\ConfigValueException;
@@ -263,6 +264,7 @@ class ConfigCRUDTest extends KernelTestBase {
       'string' => 'string',
       'string_int' => '1',
     );
+    $data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($data));
     $this->assertIdentical($config->get(), $data);
 
     // Re-set each key using Config::set().
diff --git a/core/modules/config/src/Tests/ConfigDiffTest.php b/core/modules/config/src/Tests/ConfigDiffTest.php
index efb5db33a..1f32b2780 100644
--- a/core/modules/config/src/Tests/ConfigDiffTest.php
+++ b/core/modules/config/src/Tests/ConfigDiffTest.php
@@ -35,13 +35,10 @@ class ConfigDiffTest extends KernelTestBase {
     $add_key = 'biff';
     $add_data = 'bangpow';
     $change_data = 'foobar';
-    $original_data = array(
-      'foo' => 'bar',
-      '404' => 'herp',
-    );
 
     // Install the default config.
     $this->installConfig(array('config_test'));
+    $original_data = \Drupal::config($config_name)->get();
 
     // Change a configuration value in sync.
     $sync_data = $original_data;
@@ -95,7 +92,7 @@ class ConfigDiffTest extends KernelTestBase {
     $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, $config_name);
     // Prove the fields match.
     $edits = $diff->getEdits();
-    $this->assertEqual($edits[0]->type, 'copy',  'The first item in the diff is a copy.');
+    $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
     $this->assertEqual(count($edits), 1, 'There is one item in the diff');
 
     // Rename the entity.
@@ -105,11 +102,11 @@ class ConfigDiffTest extends KernelTestBase {
 
     $diff = \Drupal::service('config.manager')->diff($active, $sync, 'config_test.dynamic.' . $new_test_entity_id, $config_name);
     $edits = $diff->getEdits();
-    $this->assertEqual($edits[0]->type, 'copy',  'The first item in the diff is a copy.');
-    $this->assertEqual($edits[1]->type, 'change',  'The second item in the diff is a change.');
+    $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
+    $this->assertEqual($edits[1]->type, 'change', 'The second item in the diff is a change.');
     $this->assertEqual($edits[1]->orig, array('id: ' . $new_test_entity_id));
     $this->assertEqual($edits[1]->closing, array('id: ' . $test_entity_id));
-    $this->assertEqual($edits[2]->type, 'copy',  'The third item in the diff is a copy.');
+    $this->assertEqual($edits[2]->type, 'copy', 'The third item in the diff is a copy.');
     $this->assertEqual(count($edits), 3, 'There are three items in the diff.');
   }
 
@@ -135,16 +132,16 @@ class ConfigDiffTest extends KernelTestBase {
     // Test the fields match in the default collection diff.
     $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
     $edits = $diff->getEdits();
-    $this->assertEqual($edits[0]->type, 'copy',  'The first item in the diff is a copy.');
+    $this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
     $this->assertEqual(count($edits), 1, 'There is one item in the diff');
 
     // Test that the differences are detected when diffing the collection.
     $diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, NULL, 'test');
     $edits = $diff->getEdits();
-    $this->assertEqual($edits[0]->type, 'change',  'The second item in the diff is a copy.');
+    $this->assertEqual($edits[0]->type, 'change', 'The second item in the diff is a copy.');
     $this->assertEqual($edits[0]->orig, array('foo: bar'));
     $this->assertEqual($edits[0]->closing, array('foo: baz'));
-    $this->assertEqual($edits[1]->type, 'copy',  'The second item in the diff is a copy.');
+    $this->assertEqual($edits[1]->type, 'copy', 'The second item in the diff is a copy.');
   }
 
 }
diff --git a/core/modules/config/src/Tests/ConfigEntityStaticCacheTest.php b/core/modules/config/src/Tests/ConfigEntityStaticCacheTest.php
index 20decd3c2..6b302697f 100644
--- a/core/modules/config/src/Tests/ConfigEntityStaticCacheTest.php
+++ b/core/modules/config/src/Tests/ConfigEntityStaticCacheTest.php
@@ -41,7 +41,7 @@ class ConfigEntityStaticCacheTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->entityTypeId = 'config_test';
     $this->entityId = 'test_1';
diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php
index 86d59eed9..98f11c290 100644
--- a/core/modules/config/src/Tests/ConfigImportUITest.php
+++ b/core/modules/config/src/Tests/ConfigImportUITest.php
@@ -311,6 +311,10 @@ class ConfigImportUITest extends WebTestBase {
     // Deleted value is escaped.
     $this->assertText(Html::escape("404: '<em>herp</em>'"));
 
+    // Verify diff colors are displayed.
+    $result = $this->xpath('//table[contains(@class, :class)]', array(':class' => 'diff'));
+    $this->assertEqual(count($result), 1, "Diff UI is displaying colors.");
+
     // Reset data back to original, and remove a key
     $sync_data = $original_data;
     unset($sync_data[$remove_key]);
diff --git a/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php b/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php
index e10dfe0b1..f3aba3b74 100644
--- a/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php
+++ b/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\config\Tests;
 
+use Drupal\Component\Utility\Crypt;
 use Drupal\Core\Config\InstallStorage;
 use Drupal\simpletest\WebTestBase;
 use Drupal\Core\Config\FileStorage;
@@ -48,6 +49,7 @@ class ConfigInstallProfileOverrideTest extends WebTestBase {
         'requirements_error' => 1209600,
       ),
     );
+    $expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data));
 
     // Verify that the original data matches. We have to read the module config
     // file directly, because the install profile default system.cron.yml
@@ -85,7 +87,7 @@ class ConfigInstallProfileOverrideTest extends WebTestBase {
     // type does not exist.
     $optional_dir = drupal_get_path('module', 'testing_config_overrides') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
     $optional_storage = new FileStorage($optional_dir);
-    foreach (['config_test.dynamic.dotted.default', 'config_test.dynamic.override','config_test.dynamic.override_unmet'] as $id) {
+    foreach (['config_test.dynamic.dotted.default', 'config_test.dynamic.override', 'config_test.dynamic.override_unmet'] as $id) {
       $this->assertTrue(\Drupal::config($id)->isNew(), "The config_test entity $id contained in the profile's optional directory does not exist.");
       // Make that we don't get false positives from the assertion above.
       $this->assertTrue($optional_storage->exists($id), "The config_test entity $id does exist in the profile's optional directory.");
diff --git a/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php b/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php
index b96819eb1..8cbb695c5 100644
--- a/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php
+++ b/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php
@@ -22,7 +22,7 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
    *
    * @var array
    */
-  public static $modules = array('user', 'language', 'config_test',  'system', 'field');
+  public static $modules = array('user', 'language', 'config_test', 'system', 'field');
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php
index a94e26ad6..8735db16d 100644
--- a/core/modules/config/src/Tests/ConfigSchemaTest.php
+++ b/core/modules/config/src/Tests/ConfigSchemaTest.php
@@ -63,6 +63,7 @@ class ConfigSchemaTest extends KernelTestBase {
     $expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
     $expected['mapping']['langcode']['type'] = 'string';
     $expected['mapping']['langcode']['label'] = 'Language code';
+    $expected['mapping']['_core']['type'] = '_core_config_info';
     $expected['mapping']['testitem'] = array('label' => 'Test item');
     $expected['mapping']['testlist'] = array('label' => 'Test list');
     $expected['type'] = 'config_schema_test.someschema';
@@ -106,6 +107,7 @@ class ConfigSchemaTest extends KernelTestBase {
       'label' => 'Language code',
       'type' => 'string',
     );
+    $expected['mapping']['_core']['type'] = '_core_config_info';
     $expected['type'] = 'system.maintenance';
     $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
     $this->assertEqual($definition, $expected, 'Retrieved the right metadata for system.maintenance');
@@ -120,6 +122,7 @@ class ConfigSchemaTest extends KernelTestBase {
       'type' => 'string',
       'label' => 'Language code',
     );
+    $expected['mapping']['_core']['type'] = '_core_config_info';
     $expected['mapping']['label'] = array(
       'label' =>  'Label',
       'type' => 'label',
@@ -179,6 +182,7 @@ class ConfigSchemaTest extends KernelTestBase {
     $expected['mapping']['third_party_settings']['type'] = 'sequence';
     $expected['mapping']['third_party_settings']['label'] = 'Third party settings';
     $expected['mapping']['third_party_settings']['sequence']['type'] = '[%parent.%parent.%type].third_party.[%key]';
+    $expected['mapping']['_core']['type'] = '_core_config_info';
     $expected['type'] = 'image.style.*';
 
     $this->assertEqual($definition, $expected);
@@ -231,6 +235,7 @@ class ConfigSchemaTest extends KernelTestBase {
     $expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
     $expected['mapping']['langcode']['type'] = 'string';
     $expected['mapping']['langcode']['label'] = 'Language code';
+    $expected['mapping']['_core']['type'] = '_core_config_info';
     $expected['mapping']['testid']['type'] = 'string';
     $expected['mapping']['testid']['label'] = 'ID';
     $expected['mapping']['testdescription']['type'] = 'text';
@@ -386,7 +391,9 @@ class ConfigSchemaTest extends KernelTestBase {
     $extension_path = drupal_get_path('module', 'config_schema_test');
     $install_storage = new FileStorage($extension_path . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY);
     $original_data = $install_storage->read('config_schema_test.ignore');
-    $this->assertIdentical($this->config('config_schema_test.ignore')->get(), $original_data);
+    $installed_data = $this->config('config_schema_test.ignore')->get();
+    unset($installed_data['_core']);
+    $this->assertIdentical($installed_data, $original_data);
   }
 
   /**
@@ -401,6 +408,7 @@ class ConfigSchemaTest extends KernelTestBase {
     $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
     $expected['mapping']['langcode']['type'] = 'string';
     $expected['mapping']['langcode']['label'] = 'Language code';
+    $expected['mapping']['_core']['type'] = '_core_config_info';
     $expected['mapping']['testid']['type'] = 'string';
     $expected['mapping']['testid']['label'] = 'ID';
     $expected['mapping']['testdescription']['type'] = 'text';
diff --git a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php
index f08c7bd71..088129afc 100644
--- a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php
+++ b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php
@@ -202,7 +202,7 @@ EOD;
     $this->assertIdentical($expected_options, array_intersect($expected_options, $options), 'The expected configuration files are listed.');
 
     $this->drupalGet('admin/config/development/configuration/single/export/system.simple/system.image');
-    $this->assertFieldByXPath('//textarea[@name="export"]', "toolkit: gd\n", 'The expected system configuration is displayed.');
+    $this->assertFieldByXPath('//textarea[@name="export"]', "toolkit: gd\n_core:\n  default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\n", 'The expected system configuration is displayed.');
 
     $this->drupalGet('admin/config/development/configuration/single/export/date_format');
     $this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Date format'), 'The date format entity type is selected when specified in the URL.');
diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php
index 2731aa0e5..8e6058785 100644
--- a/core/modules/config_translation/src/ConfigMapperManager.php
+++ b/core/modules/config_translation/src/ConfigMapperManager.php
@@ -87,13 +87,14 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
     if (!isset($this->discovery)) {
       // Look at all themes and modules.
       // @todo If the list of installed modules and themes is changed, new
-      //   definitions are not picked up immediately and obsolete definitions are
-      //   not removed, because the list of search directories is only compiled
-      //   once in this constructor. The current code only works due to
-      //   coincidence: The request that installs e.g. a new theme does not
-      //   instantiate this plugin manager at the beginning of the request; when
-      //   routes are being rebuilt at the end of the request, this service only
-      //   happens to get instantiated with the updated list of installed themes.
+      //   definitions are not picked up immediately and obsolete definitions
+      //   are not removed, because the list of search directories is only
+      //   compiled once in this constructor. The current code only works due to
+      //   coincidence: The request that installs (for instance, a new theme)
+      //   does not instantiate this plugin manager at the beginning of the
+      //   request; when routes are being rebuilt at the end of the request,
+      //   this service only happens to get instantiated with the updated list
+      //   of installed themes.
       $directories = array();
       foreach ($this->moduleHandler->getModuleList() as $name => $module) {
         $directories[$name] = $module->getPath();
diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
index afcb35a7d..cb490842e 100644
--- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
+++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
@@ -116,8 +116,8 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
    *   An associative array containing the structure of the form.
    * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The current state of the form.
-   * @param \Symfony\Component\HttpFoundation\Request $request
-   *   (optional) Page request object.
+   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
+   *   (optional) The route match.
    * @param string $plugin_id
    *   (optional) The plugin ID of the mapper.
    * @param string $langcode
diff --git a/core/modules/contact/src/Tests/Migrate/MigrateContactCategoryTest.php b/core/modules/contact/src/Tests/Migrate/MigrateContactCategoryTest.php
index 4f127a4c9..aa9df2dcc 100644
--- a/core/modules/contact/src/Tests/Migrate/MigrateContactCategoryTest.php
+++ b/core/modules/contact/src/Tests/Migrate/MigrateContactCategoryTest.php
@@ -37,15 +37,15 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
    * Performs various assertions on a single contact form entity.
    *
    * @param string $id
-   *  The contact form ID.
+   *   The contact form ID.
    * @param string $expected_label
-   *  The expected label.
+   *   The expected label.
    * @param string[] $expected_recipients
-   *  The recipient e-mail addresses the form should have.
+   *   The recipient e-mail addresses the form should have.
    * @param string $expected_reply
-   *  The expected reply message.
-   * @param integer $expected_weight
-   *  The contact form's expected weight.
+   *   The expected reply message.
+   * @param int $expected_weight
+   *   The contact form's expected weight.
    */
   protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
     /** @var \Drupal\contact\ContactFormInterface $entity */
diff --git a/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php b/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php
index 874b052f5..1d16d49b0 100644
--- a/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php
+++ b/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php
@@ -30,7 +30,7 @@ class ContactCategoryTest extends MigrateSqlSourceTestCase {
     array(
       'cid' => 1,
       'category' => 'contact category value 1',
-      'recipients' => array('admin@example.com','user@example.com'),
+      'recipients' => array('admin@example.com', 'user@example.com'),
       'reply' => 'auto reply value 1',
       'weight' => 0,
       'selected' => 0,
@@ -38,7 +38,7 @@ class ContactCategoryTest extends MigrateSqlSourceTestCase {
     array(
       'cid' => 2,
       'category' => 'contact category value 2',
-      'recipients' => array('admin@example.com','user@example.com'),
+      'recipients' => array('admin@example.com', 'user@example.com'),
       'reply' => 'auto reply value 2',
       'weight' => 0,
       'selected' => 0,
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index b354e9549..6e7bb706a 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -96,9 +96,9 @@ function content_translation_language_types_info_alter(array &$language_types) {
  *   canonical link template cannot be enabled for translation. Setting this key
  *   to TRUE overrides that. When that key is set, the Content Translation
  *   module will not provide any UI for translating the entity type, and the
- *   entity type should implement its own UI. This is useful for (e.g.) entity
- *   types that are embedded into others for editing (which would not need a
- *   canonical link, but could still support translation).
+ *   entity type should implement its own UI. For instance, this is useful for
+ *   entity types that are embedded into others for editing (which would not
+ *   need a canonical link, but could still support translation).
  * - content_translation_metadata: To implement its business logic the content
  *   translation UI relies on various metadata items describing the translation
  *   state. The default implementation is provided by
diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php
index 1b8d77df9..94505bea1 100644
--- a/core/modules/content_translation/src/ContentTranslationHandler.php
+++ b/core/modules/content_translation/src/ContentTranslationHandler.php
@@ -177,8 +177,8 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
   protected function hasAuthor() {
     // Check for field named uid, but only in case the entity implements the
     // EntityOwnerInterface. This helps to exclude cases, where the uid is
-    // defined as field name, but is not meant to be an owner field e.g. the
-    // User entity.
+    // defined as field name, but is not meant to be an owner field; for
+    // instance, the User entity.
     return $this->entityType->isSubclassOf('\Drupal\user\EntityOwnerInterface') && $this->checkFieldStorageDefinitionTranslatability('uid');
   }
 
@@ -550,7 +550,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
     // Update #title attribute for all elements that are allowed to have a
     // #title attribute according to the Form API Reference. The reason for this
     // check is because some elements have a #title attribute even though it is
-    // not rendered, e.g. field containers.
+    // not rendered; for instance, field containers.
     if (isset($element['#type']) && isset($fapi_title_elements[$element['#type']]) && isset($element['#title'])) {
       $element['#title'] .= $suffix;
     }
diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php
index b2dbf6546..386f61687 100644
--- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php
+++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php
@@ -187,7 +187,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
    *
    * @param array $items
    *   An array of field items.
-   * @param integer $delta
+   * @param int $delta
    *   The delta identifying the item to be processed.
    * @param array $columns
    *   An array of column names to be synchronized.
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php
index 53c5b0ac2..31a51820f 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php
@@ -48,7 +48,7 @@ class ContentTranslationSyncUnitTest extends KernelTestBase {
   /**
    * The field cardinality.
    *
-   * @var integer
+   * @var int
    */
   protected $cardinality;
 
diff --git a/core/modules/datetime/src/Plugin/views/sort/Date.php b/core/modules/datetime/src/Plugin/views/sort/Date.php
index 12eddc6ed..a9bdbf9ed 100644
--- a/core/modules/datetime/src/Plugin/views/sort/Date.php
+++ b/core/modules/datetime/src/Plugin/views/sort/Date.php
@@ -27,22 +27,6 @@ class Date extends NumericDate {
     return "$this->tableAlias.$this->realField";
   }
 
-  /**
-   * Override query to provide 'second' granularity.
-   */
-  public function query() {
-    $this->ensureMyTable();
-    switch ($this->options['granularity']) {
-      case 'second':
-        $formula = $this->getDateFormat('YmdHis');
-        $this->query->addOrderBy(NULL, $formula, $this->options['order'], $this->tableAlias . '_' . $this->field . '_' . $this->options['granularity']);
-        return;
-    }
-
-    // All other granularities are handled by the numeric sort handler.
-    parent::query();
-  }
-
   /**
    * {@inheritdoc}
    *
diff --git a/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php b/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php
index 18906846f..e40868eff 100644
--- a/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php
+++ b/core/modules/datetime/src/Tests/Views/ArgumentDateTimeTest.php
@@ -24,7 +24,7 @@ class ArgumentDateTimeTest extends DateTimeHandlerTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Add some basic test nodes.
diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
index b9a46992f..068f7184d 100644
--- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
+++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
@@ -40,7 +40,7 @@ abstract class DateTimeHandlerTestBase extends HandlerTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Add a date field to page nodes.
diff --git a/core/modules/datetime/src/Tests/Views/FilterDateTest.php b/core/modules/datetime/src/Tests/Views/FilterDateTest.php
index 5e54f78e2..9fbefce83 100644
--- a/core/modules/datetime/src/Tests/Views/FilterDateTest.php
+++ b/core/modules/datetime/src/Tests/Views/FilterDateTest.php
@@ -32,7 +32,7 @@ class FilterDateTest extends DateTimeHandlerTestBase {
    *
    * Create nodes with relative dates of yesterday, today, and tomorrow.
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Set to 'today'.
diff --git a/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php b/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php
index 4392cbf1b..b584c987a 100644
--- a/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php
+++ b/core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php
@@ -34,7 +34,7 @@ class FilterDateTimeTest extends DateTimeHandlerTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     static::$date = REQUEST_TIME + 86400;
diff --git a/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php b/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php
index f3f89366c..4fc5a0212 100644
--- a/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php
+++ b/core/modules/datetime/src/Tests/Views/SortDateTimeTest.php
@@ -24,7 +24,7 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Add some basic test nodes.
@@ -33,6 +33,9 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
       '2000-10-10T00:01:00',
       '2000-10-10T00:02:00',
       '2000-10-10T00:03:00',
+      '2000-10-10T00:03:02',
+      '2000-10-10T00:03:01',
+      '2000-10-10T00:03:03',
     ];
     foreach ($dates as $date) {
       $this->nodes[] = $this->drupalCreateNode([
@@ -50,7 +53,8 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
     $field = static::$field_name . '_value';
     $view = Views::getView('test_sort_datetime');
 
-    // Sort order is DESC.
+    // Set granularity to 'minute', and the secondary node ID order should
+    // define the order of nodes with the same minute.
     $view->initHandlers();
     $view->sort[$field]->options['granularity'] = 'minute';
     $view->setDisplay('default');
@@ -58,6 +62,9 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
     $expected_result = [
       ['nid' => $this->nodes[0]->id()],
       ['nid' => $this->nodes[3]->id()],
+      ['nid' => $this->nodes[4]->id()],
+      ['nid' => $this->nodes[5]->id()],
+      ['nid' => $this->nodes[6]->id()],
       ['nid' => $this->nodes[2]->id()],
       ['nid' => $this->nodes[1]->id()],
     ];
@@ -74,6 +81,9 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
       ['nid' => $this->nodes[1]->id()],
       ['nid' => $this->nodes[2]->id()],
       ['nid' => $this->nodes[3]->id()],
+      ['nid' => $this->nodes[5]->id()],
+      ['nid' => $this->nodes[4]->id()],
+      ['nid' => $this->nodes[6]->id()],
       ['nid' => $this->nodes[0]->id()],
     ];
     $this->assertIdenticalResultset($view, $expected_result, $this->map);
@@ -91,6 +101,27 @@ class SortDateTimeTest extends DateTimeHandlerTestBase {
       ['nid' => $this->nodes[1]->id()],
       ['nid' => $this->nodes[2]->id()],
       ['nid' => $this->nodes[3]->id()],
+      ['nid' => $this->nodes[4]->id()],
+      ['nid' => $this->nodes[5]->id()],
+      ['nid' => $this->nodes[6]->id()],
+    ];
+    $this->assertIdenticalResultset($view, $expected_result, $this->map);
+    $view->destroy();
+
+    // Change granularity to 'second'.
+    $view->initHandlers();
+    $view->sort[$field]->options['granularity'] = 'second';
+    $view->sort[$field]->options['order'] = 'DESC';
+    $view->setDisplay('default');
+    $this->executeView($view);
+    $expected_result = [
+      ['nid' => $this->nodes[0]->id()],
+      ['nid' => $this->nodes[6]->id()],
+      ['nid' => $this->nodes[4]->id()],
+      ['nid' => $this->nodes[5]->id()],
+      ['nid' => $this->nodes[3]->id()],
+      ['nid' => $this->nodes[2]->id()],
+      ['nid' => $this->nodes[1]->id()],
     ];
     $this->assertIdenticalResultset($view, $expected_result, $this->map);
     $view->destroy();
diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index a2c3219e8..8468caa48 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -238,6 +238,9 @@ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_
 /**
  * Loads an individual configured text editor based on text format ID.
  *
+ * @param int $format_id
+ *   A text format ID.
+ *
  * @return \Drupal\editor\Entity\Editor|null
  *   A text editor object, or NULL.
  */
diff --git a/core/modules/editor/editor.routing.yml b/core/modules/editor/editor.routing.yml
index dc41d1815..cacdfc7e7 100644
--- a/core/modules/editor/editor.routing.yml
+++ b/core/modules/editor/editor.routing.yml
@@ -2,6 +2,8 @@ editor.filter_xss:
   path: '/editor/filter_xss/{filter_format}'
   defaults:
     _controller: '\Drupal\editor\EditorController::filterXss'
+  options:
+    _theme: ajax_base_page
   requirements:
     _entity_access: 'filter_format.use'
 
@@ -23,6 +25,8 @@ editor.image_dialog:
   defaults:
     _form: '\Drupal\editor\Form\EditorImageDialog'
     _title: 'Upload image'
+  options:
+    _theme: ajax_base_page
   requirements:
     _entity_access: 'filter_format.use'
 
@@ -31,5 +35,7 @@ editor.link_dialog:
   defaults:
     _form: '\Drupal\editor\Form\EditorLinkDialog'
     _title: 'Add link'
+  options:
+    _theme: ajax_base_page
   requirements:
     _entity_access: 'filter_format.use'
diff --git a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
index d56cfffdc..32df2f5a8 100644
--- a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
+++ b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php
@@ -59,6 +59,11 @@ class Editor extends PluginBase implements InPlaceEditorInterface {
 
   /**
    * Returns whether the text format has transformation filters.
+   *
+   * @param int $format_id
+   *   A text format ID.
+   *
+   * @return bool
    */
   protected function textFormatHasTransformationFilters($format_id) {
     $format = entity_load('filter_format', $format_id);
diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php
index f9e1625d2..188a38ba6 100644
--- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php
+++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php
@@ -111,7 +111,17 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
   }
 
   /**
-   * Returns the in-place editor that Edit selects.
+   * Returns the in-place editor that quickedit selects.
+   *
+   * @param int $entity_id
+   *   An entity ID.
+   * @param string $field_name
+   *   A field name.
+   * @param string $view_mode
+   *   A view mode.
+   *
+   * @return string
+   *   Returns the selected in-place editor.
    */
   protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
     $entity = entity_load('entity_test', $entity_id, TRUE);
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index fb85d62bc..a71d69df7 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -78,7 +78,7 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
     // Forbid any update that removes allowed values with actual data.
     $allowed_values = $field_storage->getSetting('allowed_values');
     $prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
-    $lost_keys = array_keys(array_diff_key($prior_allowed_values,$allowed_values));
+    $lost_keys = array_keys(array_diff_key($prior_allowed_values, $allowed_values));
     if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
       throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
     }
@@ -106,9 +106,9 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
  * subclassing \Drupal\Core\Field\WidgetBase). Widget plugins need to be in the
  * namespace \Drupal\{your_module}\Plugin\Field\FieldWidget.
  *
- * Widgets are @link forms_api_reference.html Form API @endlink
- * elements with additional processing capabilities. The methods of the
- * WidgetInterface object are typically called by respective methods in the
+ * Widgets are @link form_api Form API @endlink elements with additional
+ * processing capabilities. The methods of the WidgetInterface object are
+ * typically called by respective methods in the
  * \Drupal\Core\Entity\Entity\EntityFormDisplay class.
  *
  * @see field
diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php
index 1f6e2f3d5..eb2a97f48 100644
--- a/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php
+++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php
@@ -30,7 +30,7 @@ class FieldTypeDefaults extends ProcessPluginBase {
         $value = 'datetime_default';
       }
       else {
-        throw new MigrateException(sprintf('Failed to lookup %s in the static map.', var_export($value, TRUE)));
+        throw new MigrateException(sprintf('Failed to lookup field type %s in the static map.', var_export($value, TRUE)));
       }
     }
     return $value;
diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
old mode 100755
new mode 100644
index 2be922359..3c2496e8d
--- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
+++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php
@@ -34,7 +34,7 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
         'type',
         'module',
       ))
-      ->condition('fci.entity_type','node');
+      ->condition('fci.entity_type', 'node');
     $query->join('field_config', 'fc', 'fci.field_id = fc.id');
     return $query;
   }
diff --git a/core/modules/field/src/Tests/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php b/core/modules/field/src/Tests/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php
index 379382c04..22f81c0d4 100644
--- a/core/modules/field/src/Tests/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php
+++ b/core/modules/field/src/Tests/Entity/Update/SqlContentEntityStorageSchemaColumnTest.php
@@ -49,7 +49,7 @@ class SqlContentEntityStorageSchemaColumnTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->installEntitySchema('entity_test_rev');
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
index a57104f4c..eb9f64040 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
@@ -36,7 +36,7 @@ class EntityReferenceFileUploadTest extends WebTestBase {
   /**
    * Node id.
    *
-   * @var integer
+   * @var int
    */
   protected $nodeId;
 
diff --git a/core/modules/field/src/Tests/EntityReference/Views/EntityReferenceRelationshipTest.php b/core/modules/field/src/Tests/EntityReference/Views/EntityReferenceRelationshipTest.php
index fc7627860..6ecb328e1 100644
--- a/core/modules/field/src/Tests/EntityReference/Views/EntityReferenceRelationshipTest.php
+++ b/core/modules/field/src/Tests/EntityReference/Views/EntityReferenceRelationshipTest.php
@@ -62,7 +62,7 @@ class EntityReferenceRelationshipTest extends ViewKernelTestBase {
     $this->installEntitySchema('entity_test_mul');
 
     // Create reference from entity_test to entity_test_mul.
-    $this->createEntityReferenceField('entity_test','entity_test','field_test_data','field_test_data','entity_test_mul');
+    $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_data', 'field_test_data', 'entity_test_mul');
 
     // Create reference from entity_test_mul to entity_test.
     $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test', 'field_data_test', 'entity_test');
diff --git a/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php b/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php
index f560876de..c5db78b72 100644
--- a/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php
+++ b/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php
@@ -36,7 +36,7 @@ class SelectionTest extends WebTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Create nodes.
diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php
index 9edbbdb2b..bbb0cd914 100644
--- a/core/modules/field/src/Tests/FieldDataCountTest.php
+++ b/core/modules/field/src/Tests/FieldDataCountTest.php
@@ -80,8 +80,8 @@ class FieldDataCountTest extends FieldUnitTestBase {
     // Create 12 entities to ensure that the purging works as expected.
     for ($i=0; $i < 12; $i++) {
       $entity = entity_create('entity_test');
-      $entity->field_int[] = mt_rand(1,99);
-      $entity->field_int[] = mt_rand(1,99);
+      $entity->field_int[] = mt_rand(1, 99);
+      $entity->field_int[] = mt_rand(1, 99);
       $entity->name[] = $this->randomMachineName();
       $entity->save();
     }
diff --git a/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php b/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php
index 89a49619e..c3973de1e 100644
--- a/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php
+++ b/core/modules/field/src/Tests/FieldDefaultValueCallbackTest.php
@@ -35,7 +35,7 @@ class FieldDefaultValueCallbackTest extends WebTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->fieldName = 'field_test';
diff --git a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldTest.php b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldTest.php
index 1eb5ad659..47b8bbd4e 100644
--- a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldTest.php
+++ b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldTest.php
@@ -39,22 +39,22 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
 
     // Integer field.
     $field_storage = FieldStorageConfig::load('node.field_test_two');
-    $this->assertIdentical("integer", $field_storage->getType(),  t('Field type is @fieldtype. It should be integer.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', array('@fieldtype' => $field_storage->getType())));
 
     // Float field.
     $field_storage = FieldStorageConfig::load('node.field_test_three');
-    $this->assertIdentical("decimal", $field_storage->getType(),  t('Field type is @fieldtype. It should be decimal.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', array('@fieldtype' => $field_storage->getType())));
 
     // Link field.
     $field_storage = FieldStorageConfig::load('node.field_test_link');
-    $this->assertIdentical("link", $field_storage->getType(),  t('Field type is @fieldtype. It should be link.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', array('@fieldtype' => $field_storage->getType())));
 
     // File field.
     $field_storage = FieldStorageConfig::load('node.field_test_filefield');
-    $this->assertIdentical("file", $field_storage->getType(),  t('Field type is @fieldtype. It should be file.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', array('@fieldtype' => $field_storage->getType())));
 
     $field_storage = FieldStorageConfig::load('node.field_test_imagefield');
-    $this->assertIdentical("image", $field_storage->getType(),  t('Field type is @fieldtype. It should be image.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', array('@fieldtype' => $field_storage->getType())));
     $settings = $field_storage->getSettings();
     $this->assertIdentical('file', $settings['target_type']);
     $this->assertIdentical('public', $settings['uri_scheme']);
@@ -62,15 +62,15 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
 
     // Phone field.
     $field_storage = FieldStorageConfig::load('node.field_test_phone');
-    $this->assertIdentical("telephone", $field_storage->getType(),  t('Field type is @fieldtype. It should be telephone.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', array('@fieldtype' => $field_storage->getType())));
 
     // Date field.
     $field_storage = FieldStorageConfig::load('node.field_test_datetime');
-    $this->assertIdentical("datetime", $field_storage->getType(),  t('Field type is @fieldtype. It should be datetime.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', array('@fieldtype' => $field_storage->getType())));
 
     // Decimal field with radio buttons.
     $field_storage = FieldStorageConfig::load('node.field_test_decimal_radio_buttons');
-    $this->assertIdentical("list_float", $field_storage->getType(),  t('Field type is @fieldtype. It should be list_float.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', array('@fieldtype' => $field_storage->getType())));
     $this->assertNotNull($field_storage->getSetting('allowed_values')['1.2'], t('First allowed value key is set to 1.2'));
     $this->assertNotNull($field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value key is set to 2.1'));
     $this->assertIdentical('1.2', $field_storage->getSetting('allowed_values')['1.2'], t('First allowed value is set to 1.2'));
@@ -78,11 +78,11 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
 
     // Float field with a single checkbox.
     $field_storage = FieldStorageConfig::load('node.field_test_float_single_checkbox');
-    $this->assertIdentical("boolean", $field_storage->getType(),  t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
 
     // Integer field with a select list.
     $field_storage = FieldStorageConfig::load('node.field_test_integer_selectlist');
-    $this->assertIdentical("list_integer", $field_storage->getType(),  t('Field type is @fieldtype. It should be list_integer.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', array('@fieldtype' => $field_storage->getType())));
     $this->assertNotNull($field_storage->getSetting('allowed_values')['1234'], t('First allowed value key is set to 1234'));
     $this->assertNotNull($field_storage->getSetting('allowed_values')['2341'], t('Second allowed value key is set to 2341'));
     $this->assertNotNull($field_storage->getSetting('allowed_values')['3412'], t('Third allowed value key is set to 3412'));
@@ -94,7 +94,7 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
 
     // Text field with a single checkbox.
     $field_storage = FieldStorageConfig::load('node.field_test_text_single_checkbox');
-    $this->assertIdentical("boolean", $field_storage->getType(),  t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
+    $this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
 
     // Validate that the source count and processed count match up.
     /** @var \Drupal\migrate\Entity\MigrationInterface $migration */
diff --git a/core/modules/field/src/Tests/Migrate/d7/MigrateFieldTest.php b/core/modules/field/src/Tests/Migrate/d7/MigrateFieldTest.php
index c846b89b3..7daf73480 100644
--- a/core/modules/field/src/Tests/Migrate/d7/MigrateFieldTest.php
+++ b/core/modules/field/src/Tests/Migrate/d7/MigrateFieldTest.php
@@ -53,9 +53,9 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
    *   The entity ID in the form ENTITY_TYPE.FIELD_NAME.
    * @param string $expected_type
    *   The expected field type.
-   * @param boolean $expected_translatable
+   * @param bool $expected_translatable
    *   Whether or not the field is expected to be translatable.
-   * @param integer $expected_cardinality
+   * @param int $expected_cardinality
    *   The expected cardinality of the field.
    */
   protected function assertEntity($id, $expected_type, $expected_translatable, $expected_cardinality) {
diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php
index f80dfabde..953717024 100644
--- a/core/modules/field/src/Tests/Number/NumberFieldTest.php
+++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php
@@ -371,8 +371,8 @@ class NumberFieldTest extends WebTestBase {
     $decimal_separators = array('.', ',');
     $prefix = $this->randomMachineName();
     $suffix = $this->randomMachineName();
-    $random_float = rand(0,pow(10,6));
-    $random_integer = rand(0, pow(10,6));
+    $random_float = rand(0, pow(10, 6));
+    $random_integer = rand(0, pow(10, 6));
 
     // Create a content type containing float and integer fields.
     $this->drupalCreateContentType(array('type' => $type));
diff --git a/core/modules/field/src/Tests/Timestamp/TimestampFormatterTest.php b/core/modules/field/src/Tests/Timestamp/TimestampFormatterTest.php
index 8ef98d685..2323b15f2 100644
--- a/core/modules/field/src/Tests/Timestamp/TimestampFormatterTest.php
+++ b/core/modules/field/src/Tests/Timestamp/TimestampFormatterTest.php
@@ -145,7 +145,7 @@ class TimestampFormatterTest extends KernelTestBase {
   protected function testTimestampAgoFormatter() {
     $data = [];
 
-    foreach (array(1,2,3,4,5,6) as $granularity) {
+    foreach (array(1, 2, 3, 4, 5, 6) as $granularity) {
       $data[] = [
         'future_format' => '@interval hence',
         'past_format' => '@interval ago',
diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module
index c66a0d682..c86a7b9b7 100644
--- a/core/modules/field/tests/modules/field_test/field_test.module
+++ b/core/modules/field/tests/modules/field_test/field_test.module
@@ -124,7 +124,7 @@ function field_test_field_widget_form_alter(&$element, FormStateInterface $form_
 function field_test_query_efq_table_prefixing_test_alter(&$query) {
   // Add an additional join onto the entity base table. This will cause an
   // exception if the EFQ does not properly prefix the base table.
-  $query->join('entity_test','et2','%alias.id = entity_test.id');
+  $query->join('entity_test', 'et2', '%alias.id = entity_test.id');
 }
 
 
diff --git a/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php
new file mode 100644
index 000000000..d65c924a6
--- /dev/null
+++ b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldTypeDefaultsTest.
+ */
+
+namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d6;
+
+use Drupal\field\Plugin\migrate\process\d6\FieldTypeDefaults;
+use Drupal\migrate\MigrateException;
+use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
+
+/**
+ * Tests D6 fields defaults.
+ *
+ * @coversDefaultClass \Drupal\field\Plugin\migrate\process\d6\FieldTypeDefaults
+ * @group field
+ */
+class FieldTypeDefaultsTest extends MigrateProcessTestCase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->plugin = new FieldTypeDefaults([], 'field_type_defaults', []);
+  }
+
+  /**
+   * Tests various default cases.
+   *
+   * @covers ::transform
+   */
+  public function testDefaults() {
+    $this->row->expects($this->once())
+      ->method('getSourceProperty')
+      ->willReturn('date');
+
+    // Assert common values are passed through without modification.
+    $this->assertNull($this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'property'));
+    $this->assertEquals('string', $this->plugin->transform('string', $this->migrateExecutable, $this->row, 'property'));
+    $this->assertEquals(1234, $this->plugin->transform(1234, $this->migrateExecutable, $this->row, 'property'));
+    // Assert that an array checks that this is a date field(above mock assert)
+    // and returns "datetime_default".
+    $this->assertEquals('datetime_default', $this->plugin->transform([], $this->migrateExecutable, $this->row, 'property'));
+  }
+
+  /**
+   * Tests an exception is thrown when the input is not a date field.
+   *
+   * @covers ::transform
+   */
+  public function testDefaultsException() {
+    $this->setExpectedException(MigrateException::class,
+      sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE)));
+    $this->plugin->transform([], $this->migrateExecutable, $this->row, 'property');
+  }
+}
diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module
index 56375fc9b..597be4f76 100644
--- a/core/modules/field_ui/field_ui.module
+++ b/core/modules/field_ui/field_ui.module
@@ -38,7 +38,7 @@ function field_ui_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<dt>' . t('Configuring view and form modes') . '</dt>';
       $output .= '<dd>' . t('You can add, edit, and delete view modes for entities on the <a href=":view_modes">View modes page</a>, and you can add, edit, and delete form modes for entities on the <a href=":form_modes">Form modes page</a>. Once you have defined a view mode or form mode for an entity type, it will be available on the Manage display or Manage form display page for each sub-type of that entity.', array(':view_modes' => \Drupal::url('entity.entity_view_mode.collection'), ':form_modes' => \Drupal::url('entity.entity_form_mode.collection'))) . '</dd>';
       $output .= '<dt>' . t('Listing fields') . '</dt>';
-      $output .= '<dd>' . t('There are two reports available that list the fields defined on your site. The <a href=":entity-list" title="Entities field list report">Entities</a> report lists all your fields, showing the field machine names, types, and the entity types or sub-types they are used on (each sub-type links to the Manage fields page). If the <a href=":views">Views</a> and <a href=":views-ui">Views UI</a> modules are enabled, the <a href=":views-list" title="Used in views field list report">Used in views</a> report lists each field that is used in a view, with a link to edit that view.', array(':entity-list' => \Drupal::url('entity.field_storage_config.collection'), ':views-list' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('views_ui.reports_fields') : '#', ':views' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', array('name' => 'views')) : '#',':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', array('name' => 'views_ui')) : '#')) . '</dd>';
+      $output .= '<dd>' . t('There are two reports available that list the fields defined on your site. The <a href=":entity-list" title="Entities field list report">Entities</a> report lists all your fields, showing the field machine names, types, and the entity types or sub-types they are used on (each sub-type links to the Manage fields page). If the <a href=":views">Views</a> and <a href=":views-ui">Views UI</a> modules are enabled, the <a href=":views-list" title="Used in views field list report">Used in views</a> report lists each field that is used in a view, with a link to edit that view.', array(':entity-list' => \Drupal::url('entity.field_storage_config.collection'), ':views-list' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('views_ui.reports_fields') : '#', ':views' => (\Drupal::moduleHandler()->moduleExists('views')) ? \Drupal::url('help.page', array('name' => 'views')) : '#', ':views-ui' => (\Drupal::moduleHandler()->moduleExists('views_ui')) ? \Drupal::url('help.page', array('name' => 'views_ui')) : '#')) . '</dd>';
       $output .= '</dl>';
       return $output;
 
diff --git a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
index adafcc790..4b5b3ca6e 100644
--- a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
@@ -13,6 +13,7 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field_ui\FieldUI;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
 /**
  * Provides a form for the "field storage" edit page.
@@ -33,6 +34,9 @@ class FieldStorageConfigEditForm extends EntityForm {
     // The URL of this entity form contains only the ID of the field_config
     // but we are actually editing a field_storage_config entity.
     $field_config = FieldConfig::load($route_match->getRawParameter('field_config'));
+    if (!$field_config) {
+      throw new NotFoundHttpException();
+    }
 
     return $field_config->getFieldStorageDefinition();
   }
diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php
index 7c7a48bd4..1c9332be5 100644
--- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php
+++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php
@@ -132,7 +132,7 @@ class EntityDisplayTest extends KernelTestBase {
     $display->save();
     $components = array_keys($display->getComponents());
     // The name field is not configurable so will be added automatically.
-    $expected = array ( 0 => 'component_1', 1 => 'component_2',  2 => 'component_3', 'name');
+    $expected = array ( 0 => 'component_1', 1 => 'component_2', 2 => 'component_3', 'name');
     $this->assertIdentical($components, $expected);
   }
 
diff --git a/core/modules/field_ui/src/Tests/FieldUiTestTrait.php b/core/modules/field_ui/src/Tests/FieldUiTestTrait.php
index ec0e326e4..ba70401c6 100644
--- a/core/modules/field_ui/src/Tests/FieldUiTestTrait.php
+++ b/core/modules/field_ui/src/Tests/FieldUiTestTrait.php
@@ -46,7 +46,7 @@ trait FieldUiTestTrait {
     }
 
     // First step: 'Add field' page.
-    $this->drupalPostForm($bundle_path,  $initial_edit, t('Save and continue'));
+    $this->drupalPostForm($bundle_path, $initial_edit, t('Save and continue'));
     $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Storage settings page was displayed.');
     // Test Breadcrumbs.
     $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
index c09550f9e..8cc6e43c4 100644
--- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php
@@ -492,13 +492,13 @@ class ManageFieldsTest extends WebTestBase {
     // Try with an entity key.
     $edit['field_name'] = 'title';
     $bundle_path = 'admin/structure/types/manage/' . $this->contentType;
-    $this->drupalPostForm("$bundle_path/fields/add-field",  $edit, t('Save and continue'));
+    $this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue'));
     $this->assertText(t('The machine-readable name is already in use. It must be unique.'));
 
     // Try with a base field.
     $edit['field_name'] = 'sticky';
     $bundle_path = 'admin/structure/types/manage/' . $this->contentType;
-    $this->drupalPostForm("$bundle_path/fields/add-field",  $edit, t('Save and continue'));
+    $this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue'));
     $this->assertText(t('The machine-readable name is already in use. It must be unique.'));
   }
 
@@ -718,4 +718,17 @@ class ManageFieldsTest extends WebTestBase {
     $this->assertEqual($view_display->getComponent('field_test_custom_options')['type'], 'field_test_multiple');
   }
 
+  /**
+   * Tests the access to non-existent field URLs.
+   */
+  public function testNonExistentFieldUrls() {
+    $field_id = 'node.foo.bar';
+
+    $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
+    $this->assertResponse(404);
+
+    $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id . '/storage');
+    $this->assertResponse(404);
+  }
+
 }
diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index 4c91e23a5..35a57373b 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -96,16 +96,16 @@ function file_requirements($phase) {
       $value = t('Not enabled');
       $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php or PHP-FPM and not as FastCGI.');
     }
-    elseif (!$implementation && extension_loaded('apc')) {
+    elseif (!$implementation && extension_loaded('apcu')) {
       $value = t('Not enabled');
       $description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href=":url">PECL uploadprogress</a>, which supports more than one simultaneous upload.', array(':url' => 'http://pecl.php.net/package/uploadprogress'));
     }
     elseif (!$implementation) {
       $value = t('Not enabled');
-      $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href=":uploadprogress_url">PECL uploadprogress library</a> (preferred) or to install <a href=":apc_url">APC</a>.', array(':uploadprogress_url' => 'http://pecl.php.net/package/uploadprogress', ':apc_url' => 'http://php.net/apc'));
+      $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href=":uploadprogress_url">PECL uploadprogress library</a> (preferred) or to install <a href=":apc_url">APC</a>.', array(':uploadprogress_url' => 'http://pecl.php.net/package/uploadprogress', ':apc_url' => 'http://php.net/apcu'));
     }
     elseif ($implementation == 'apc') {
-      $value = t('Enabled (<a href=":url">APC RFC1867</a>)', array(':url' => 'http://php.net/manual/apc.configuration.php#ini.apc.rfc1867'));
+      $value = t('Enabled (<a href=":url">APC RFC1867</a>)', array(':url' => 'http://php.net/manual/en/apcu.configuration.php#ini.apcu.rfc1867'));
       $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href=":url">PECL uploadprogress library</a> if possible.', array(':url' => 'http://pecl.php.net/package/uploadprogress'));
     }
     elseif ($implementation == 'uploadprogress') {
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 26c35ac53..08e94384b 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -913,7 +913,7 @@ function file_progress_implementation() {
     $implementation = FALSE;
 
     // We prefer the PECL extension uploadprogress because it supports multiple
-    // simultaneous uploads. APC only supports one at a time.
+    // simultaneous uploads. APCu only supports one at a time.
     if (extension_loaded('uploadprogress')) {
       $implementation = 'uploadprogress';
     }
diff --git a/core/modules/file/src/Controller/FileWidgetAjaxController.php b/core/modules/file/src/Controller/FileWidgetAjaxController.php
index d05a4dd7b..ef09a794f 100644
--- a/core/modules/file/src/Controller/FileWidgetAjaxController.php
+++ b/core/modules/file/src/Controller/FileWidgetAjaxController.php
@@ -38,7 +38,7 @@ class FileWidgetAjaxController {
       }
     }
     elseif ($implementation == 'apc') {
-      $status = apc_fetch('upload_' . $key);
+      $status = apcu_fetch('upload_' . $key);
       if (isset($status['current']) && !empty($status['total'])) {
         $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total'])));
         $progress['percentage'] = round(100 * $status['current'] / $status['total']);
diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
index 3570c3506..944e1028a 100644
--- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
+++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
@@ -47,7 +47,7 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
-    return new static($plugin_id, $plugin_definition,$configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('element_info'));
+    return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('element_info'));
   }
 
   /**
diff --git a/core/modules/file/src/Plugin/migrate/destination/EntityFile.php b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php
index 38c3f8716..89667f117 100644
--- a/core/modules/file/src/Plugin/migrate/destination/EntityFile.php
+++ b/core/modules/file/src/Plugin/migrate/destination/EntityFile.php
@@ -145,11 +145,11 @@ class EntityFile extends EntityContentBase {
    * Tries to move or copy a file.
    *
    * @param string $source
-   *  The source path or URI.
+   *   The source path or URI.
    * @param string $destination
-   *  The destination path or URI.
-   * @param integer $replace
-   *  FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.
+   *   The destination path or URI.
+   * @param int $replace
+   *   (optional) FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.
    *
    * @return bool
    *  TRUE on success, FALSE on failure.
@@ -170,9 +170,9 @@ class EntityFile extends EntityContentBase {
    *
    * @param \Drupal\migrate\Row $row
    *
-   * @return integer
-   *  Either FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME, depending
-   *  on the current configuration.
+   * @return int
+   *   Either FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME, depending
+   *   on the current configuration.
    */
   protected function getOverwriteMode(Row $row) {
     if (!empty($this->configuration['rename'])) {
diff --git a/core/modules/file/src/Plugin/views/filter/Status.php b/core/modules/file/src/Plugin/views/filter/Status.php
index 5d73454dd..7d6db6f26 100644
--- a/core/modules/file/src/Plugin/views/filter/Status.php
+++ b/core/modules/file/src/Plugin/views/filter/Status.php
@@ -22,6 +22,7 @@ class Status extends InOperator {
     if (!isset($this->valueOptions)) {
       $this->valueOptions = _views_file_status();
     }
+    return $this->valueOptions;
   }
 
 }
diff --git a/core/modules/file/src/Tests/FileFieldRSSContentTest.php b/core/modules/file/src/Tests/FileFieldRSSContentTest.php
index dd31f85a2..b4f004936 100644
--- a/core/modules/file/src/Tests/FileFieldRSSContentTest.php
+++ b/core/modules/file/src/Tests/FileFieldRSSContentTest.php
@@ -30,15 +30,8 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
     $node_storage = $this->container->get('entity.manager')->getStorage('node');
     $field_name = strtolower($this->randomMachineName());
     $type_name = 'article';
-    $field_settings = array(
-      'display_field' => '1',
-      'display_default' => '1',
-    );
-    $field_settings = array(
-      'description_field' => '1',
-    );
-    $widget_settings = array();
-    $this->createFileField($field_name, 'node', $type_name, $field_settings, $field_settings, $widget_settings);
+
+    $this->createFileField($field_name, 'node', $type_name);
 
     // RSS display must be added manually.
     $this->drupalGet("admin/structure/types/manage/$type_name/display");
diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php
index e2f4aa232..7b0cce545 100644
--- a/core/modules/file/src/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php
@@ -151,7 +151,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
         // - 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) {
+        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"]');
diff --git a/core/modules/file/src/Tests/FileManagedTestBase.php b/core/modules/file/src/Tests/FileManagedTestBase.php
index 07964f7ca..ebaaaea1b 100644
--- a/core/modules/file/src/Tests/FileManagedTestBase.php
+++ b/core/modules/file/src/Tests/FileManagedTestBase.php
@@ -33,9 +33,9 @@ abstract class FileManagedTestBase extends WebTestBase {
    * Assert that all of the specified hook_file_* hooks were called once, other
    * values result in failure.
    *
-   * @param array $expected
-   *   Array with string containing with the hook name, e.g. 'load', 'save',
-   *   'insert', etc.
+   * @param string[] $expected
+   *   An array of strings containing with the hook name; for example, 'load',
+   *   'save', 'insert', etc.
    */
   function assertFileHooksCalled($expected) {
     \Drupal::state()->resetCache();
@@ -66,7 +66,7 @@ abstract class FileManagedTestBase extends WebTestBase {
    * Assert that a hook_file_* hook was called a certain number of times.
    *
    * @param string $hook
-   *   String with the hook name, e.g. 'load', 'save', 'insert', etc.
+   *   String with the hook name; for instance, 'load', 'save', 'insert', etc.
    * @param int $expected_count
    *   Optional integer count.
    * @param string|NULL $message
diff --git a/core/modules/file/src/Tests/Migrate/EntityFileTest.php b/core/modules/file/src/Tests/Migrate/EntityFileTest.php
index 42826aa3f..3c5b8ad25 100644
--- a/core/modules/file/src/Tests/Migrate/EntityFileTest.php
+++ b/core/modules/file/src/Tests/Migrate/EntityFileTest.php
@@ -37,7 +37,7 @@ class EntityFileTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->destination = new TestEntityFile([]);
     $this->destination->streamWrapperManager = \Drupal::getContainer()->get('stream_wrapper_manager');
diff --git a/core/modules/file/src/Tests/Migrate/d6/MigrateFileTest.php b/core/modules/file/src/Tests/Migrate/d6/MigrateFileTest.php
index 4277133e9..2bda4c008 100644
--- a/core/modules/file/src/Tests/Migrate/d6/MigrateFileTest.php
+++ b/core/modules/file/src/Tests/Migrate/d6/MigrateFileTest.php
@@ -50,18 +50,18 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
   /**
    * Asserts a file entity.
    *
-   * @param integer $fid
-   *  The file ID.
+   * @param int $fid
+   *   The file ID.
    * @param string $name
-   *  The expected file name.
-   * @param integer $size
-   *  The expected file size.
+   *   The expected file name.
+   * @param int $size
+   *   The expected file size.
    * @param string $uri
-   *  The expected file URI.
+   *   The expected file URI.
    * @param string $type
-   *  The expected MIME type.
-   * @param integer $uid
-   *  The expected file owner ID.
+   *   The expected MIME type.
+   * @param int $uid
+   *   The expected file owner ID.
    */
   protected function assertEntity($fid, $name, $size, $uri, $type, $uid) {
     /** @var \Drupal\file\FileInterface $file */
diff --git a/core/modules/file/src/Tests/Migrate/d7/MigrateFileTest.php b/core/modules/file/src/Tests/Migrate/d7/MigrateFileTest.php
index da1a6d251..2d54d7816 100644
--- a/core/modules/file/src/Tests/Migrate/d7/MigrateFileTest.php
+++ b/core/modules/file/src/Tests/Migrate/d7/MigrateFileTest.php
@@ -53,22 +53,22 @@ class MigrateFileTest extends MigrateDrupal7TestBase {
   /**
    * Tests a single file entity.
    *
-   * @param integer $id
-   *  The file ID.
+   * @param int $id
+   *   The file ID.
    * @param string $name
-   *  The expected file name.
+   *   The expected file name.
    * @param string $uri
-   *  The expected URI.
+   *   The expected URI.
    * @param string $mime
-   *  The expected MIME type.
-   * @param integer $size
-   *  The expected file size.
-   * @param integer $created
-   *  The expected creation time.
-   * @param integer $changed
-   *  The expected modification time.
-   * @param integer $uid
-   *  The expected owner ID.
+   *   The expected MIME type.
+   * @param int $size
+   *   The expected file size.
+   * @param int $created
+   *   The expected creation time.
+   * @param int $changed
+   *   The expected modification time.
+   * @param int $uid
+   *   The expected owner ID.
    */
   protected function assertEntity($id, $name, $uri, $mime, $size, $created, $changed, $uid) {
     /** @var \Drupal\file\FileInterface $file */
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index f1f28b516..46046d1cb 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -22,11 +22,11 @@ function filter_help($route_name, RouteMatchInterface $route_match) {
     case 'help.page.filter':
       $output = '';
       $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('The Filter module allows administrators to configure text formats. Text formats change how HTML tags and other text will be <em>processed and displayed</em> in the site. They are used to transform text, and also help to defend your web site against potentially damaging input from malicious users. Visual text editors can be associated with text formats by using the <a href=":editor_help">Text Editor module</a>. For more information, see the <a href=":filter_do">online documentation for the Filter module</a>.', array(':filter_do' => 'https://www.drupal.org/documentation/modules/filter/',':editor_help' => (\Drupal::moduleHandler()->moduleExists('editor')) ? \Drupal::url('help.page', array('name' => 'editor')) : '#')) . '</p>';
+      $output .= '<p>' . t('The Filter module allows administrators to configure text formats. Text formats change how HTML tags and other text will be <em>processed and displayed</em> in the site. They are used to transform text, and also help to defend your web site against potentially damaging input from malicious users. Visual text editors can be associated with text formats by using the <a href=":editor_help">Text Editor module</a>. For more information, see the <a href=":filter_do">online documentation for the Filter module</a>.', array(':filter_do' => 'https://www.drupal.org/documentation/modules/filter/', ':editor_help' => (\Drupal::moduleHandler()->moduleExists('editor')) ? \Drupal::url('help.page', array('name' => 'editor')) : '#')) . '</p>';
       $output .= '<h3>' . t('Uses') . '</h3>';
       $output .= '<dl>';
       $output .= '<dt>' . t('Managing text formats') . '</dt>';
-      $output .= '<dd>' . t('You can create and edit text formats on the <a href=":formats">Text formats page</a> (if the Text Editor module is enabled, this page is named Text formats and editors). One text format is included by default: Plain text (which removes all HTML tags). Additional text formats may be created during installation. You can create a text format by clicking "<a href=":add_format">Add text format</a>".', array(':formats' => \Drupal::url('filter.admin_overview'),':add_format' => \Drupal::url('filter.format_add'))) . '</dd>';
+      $output .= '<dd>' . t('You can create and edit text formats on the <a href=":formats">Text formats page</a> (if the Text Editor module is enabled, this page is named Text formats and editors). One text format is included by default: Plain text (which removes all HTML tags). Additional text formats may be created during installation. You can create a text format by clicking "<a href=":add_format">Add text format</a>".', array(':formats' => \Drupal::url('filter.admin_overview'), ':add_format' => \Drupal::url('filter.format_add'))) . '</dd>';
       $output .= '<dt>' . t('Assigning roles to text formats') . '</dt>';
       $output .= '<dd>' . t('You can define which users will be able to use each text format by selecting roles. To ensure security, anonymous and untrusted users should only have access to text formats that restrict them to either plain text or a safe set of HTML tags. This is because HTML tags can allow embedding malicious links or scripts in text. More trusted registered users may be granted permission to use less restrictive text formats in order to create rich text. <strong>Improper text format configuration is a security risk.</strong>') . '</dd>';
       $output .= '<dt>' . t('Selecting filters') . '</dt>';
@@ -817,7 +817,7 @@ function filter_filter_secure_image_alter(&$image) {
   $image->setAttribute('alt', t('Image removed.'));
   $image->setAttribute('title', t('This image has been removed. For security reasons, only images from the local domain are allowed.'));
   $image->setAttribute('height', '16');
-  $image->setAttribute('width',  '16');
+  $image->setAttribute('width', '16');
 
   // Add a CSS class to aid in styling.
   $class = ($image->getAttribute('class') ? trim($image->getAttribute('class')) . ' ' : '');
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php
index 3cb442a8e..da02711e8 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php
@@ -21,7 +21,7 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
index 36fd401eb..5c6d00f9c 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
@@ -21,7 +21,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
index ba1c97472..24ffcf75a 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
@@ -21,7 +21,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
diff --git a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
index 9c71da403..e7a0388e1 100644
--- a/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
+++ b/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php
@@ -124,6 +124,9 @@ class ContentEntityNormalizer extends NormalizerBase {
    *     all default values for entity fields before applying $data to the
    *     entity.
    *
+   * @return \Drupal\Core\Entity\EntityInterface
+   *   An unserialized entity object containing the data in $data.
+   *
    * @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException
    */
   public function denormalize($data, $class, $format = NULL, array $context = array()) {
diff --git a/core/modules/help/src/Plugin/Block/HelpBlock.php b/core/modules/help/src/Plugin/Block/HelpBlock.php
index cae2b6ef8..af71928a4 100644
--- a/core/modules/help/src/Plugin/Block/HelpBlock.php
+++ b/core/modules/help/src/Plugin/Block/HelpBlock.php
@@ -89,6 +89,9 @@ class HelpBlock extends BlockBase implements ContainerFactoryPluginInterface {
    *
    * @param \Symfony\Component\HttpFoundation\Request $request
    *   The current request.
+   *
+   * @return string
+   *   Help text of the matched route item as HTML.
    */
   protected function getActiveHelp(Request $request) {
     // Do not show on a 403 or 404 page.
diff --git a/core/modules/help/src/Tests/HelpTest.php b/core/modules/help/src/Tests/HelpTest.php
index f3c90836b..64ad4a773 100644
--- a/core/modules/help/src/Tests/HelpTest.php
+++ b/core/modules/help/src/Tests/HelpTest.php
@@ -86,8 +86,8 @@ class HelpTest extends WebTestBase {
   /**
    * Verifies the logged in user has access to the various help nodes.
    *
-   * @param integer $response
-   *   An HTTP response code.
+   * @param int $response
+   *   (optional) An HTTP response code. Defaults to 200.
    */
   protected function verifyHelp($response = 200) {
     $this->drupalGet('admin/index');
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 2c222f81f..97b3dd2da 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -96,11 +96,11 @@ function image_theme() {
     'image_style' => array(
       // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
       // allows the alt attribute to be omitted in some cases. Therefore,
-      // default the alt attribute to an empty string, but allow code calling
-      // _theme('image_style') to pass explicit NULL for it to be omitted.
+      // default the alt attribute to an empty string, but allow code using
+      // '#theme' => 'image_style' to pass explicit NULL for it to be omitted.
       // Usually, neither omission nor an empty string satisfies accessibility
-      // requirements, so it is strongly encouraged for code calling
-      // _theme('image_style') to pass a meaningful value for the alt variable.
+      // requirements, so it is strongly encouraged for code using '#theme' =>
+      // 'image_style' to pass a meaningful value for the alt variable.
       // - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
       // - http://www.w3.org/TR/xhtml1/dtds.html
       // - http://dev.w3.org/html5/spec/Overview.html#alt
@@ -260,8 +260,8 @@ function image_style_options($include_empty = TRUE) {
  *     attribute to be omitted in some cases. Therefore, this variable defaults
  *     to an empty string, but can be set to NULL for the attribute to be
  *     omitted. Usually, neither omission nor an empty string satisfies
- *     accessibility requirements, so it is strongly encouraged for code calling
- *     _theme('image_style') to pass a meaningful value for this variable.
+ *     accessibility requirements, so it is strongly encouraged for code using
+ *     '#theme' => 'image_style' to pass a meaningful value for this variable.
  *     - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
  *     - http://www.w3.org/TR/xhtml1/dtds.html
  *     - http://dev.w3.org/html5/spec/Overview.html#alt
diff --git a/core/modules/image/src/Controller/ImageStyleDownloadController.php b/core/modules/image/src/Controller/ImageStyleDownloadController.php
index b879eeea2..200a425b0 100644
--- a/core/modules/image/src/Controller/ImageStyleDownloadController.php
+++ b/core/modules/image/src/Controller/ImageStyleDownloadController.php
@@ -142,7 +142,7 @@ class ImageStyleDownloadController extends FileDownloadController {
       $path_info = pathinfo($image_uri);
       $converted_image_uri = $path_info['dirname'] . DIRECTORY_SEPARATOR . $path_info['filename'];
       if (!file_exists($converted_image_uri)) {
-        $this->logger->notice('Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.',  array('%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri));
+        $this->logger->notice('Source image at %source_image_path not found while trying to generate derivative image at %derivative_path.', array('%source_image_path' => $image_uri, '%derivative_path' => $derivative_uri));
         return new Response($this->t('Error generating image, missing source file.'), 404);
       }
       else {
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index e541c2727..ee47e3069 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\image\Tests;
 use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\file\Entity\File;
 
 /**
@@ -162,6 +163,13 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
       )
     );
 
+    // Also check that the field renders without warnings when the label is
+    // hidden.
+    EntityViewDisplay::load('node.article.default')
+      ->setComponent($field_name, array('label' => 'hidden', 'type' => 'image'))
+      ->save();
+    $this->drupalGet('node/' . $article->id());
+
     // Confirm that the image default is shown for a new page node.
     $page = $this->drupalCreateNode(array('type' => 'page'));
     $page_built = $this->drupalBuildEntityView($page);
@@ -326,7 +334,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
     // The non-existent default image should not be saved.
     $this->assertNull($settings['default_image']['uuid']);
 
-    $field = entity_create('field_config',  array(
+    $field = entity_create('field_config', array(
       'field_storage' => $field_storage,
       'bundle' => 'page',
       'label' => $this->randomMachineName(),
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index 2c6a2e4cc..53ba09f07 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -136,7 +136,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
       // Only verify HTTP headers when using private scheme and the headers are
       // sent by Drupal.
       $this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.');
-      $this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'),'private') !== FALSE, 'Cache-Control header was sent.');
+      $this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.');
 
       // Log out and try to access the file.
       $this->drupalLogout();
diff --git a/core/modules/image/src/Tests/ImageFieldValidateTest.php b/core/modules/image/src/Tests/ImageFieldValidateTest.php
index 3fee09c24..c5ea8318c 100644
--- a/core/modules/image/src/Tests/ImageFieldValidateTest.php
+++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php
@@ -72,7 +72,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
     // Look for form-required for the alt text.
     $elements = $this->xpath('//label[@for="edit-' . $field_name . '-0-alt" and @class="js-form-required form-required"]/following-sibling::input[@id="edit-' . $field_name . '-0-alt"]');
 
-    $this->assertTrue(isset($elements[0]),'Required marker is shown for the required alt text.');
+    $this->assertTrue(isset($elements[0]), 'Required marker is shown for the required alt text.');
 
     $elements = $this->xpath('//label[@for="edit-' . $field_name . '-0-title" and @class="js-form-required form-required"]/following-sibling::input[@id="edit-' . $field_name . '-0-title"]');
 
diff --git a/core/modules/image/src/Tests/Migrate/d6/MigrateImageCacheTest.php b/core/modules/image/src/Tests/Migrate/d6/MigrateImageCacheTest.php
index 99ee2925b..11e5c7376 100644
--- a/core/modules/image/src/Tests/Migrate/d6/MigrateImageCacheTest.php
+++ b/core/modules/image/src/Tests/Migrate/d6/MigrateImageCacheTest.php
@@ -24,7 +24,7 @@ class MigrateImageCacheTest extends MigrateDrupal6TestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->installConfig(['image']);
   }
diff --git a/core/modules/image/src/Tests/Migrate/d7/MigrateImageSettingsTest.php b/core/modules/image/src/Tests/Migrate/d7/MigrateImageSettingsTest.php
index 15b470fc9..f1933da51 100644
--- a/core/modules/image/src/Tests/Migrate/d7/MigrateImageSettingsTest.php
+++ b/core/modules/image/src/Tests/Migrate/d7/MigrateImageSettingsTest.php
@@ -34,7 +34,7 @@ class MigrateImageSettingsTest extends MigrateDrupal7TestBase {
     // These settings are not recommended...
     $this->assertTrue($config->get('allow_insecure_derivatives'));
     $this->assertTrue($config->get('suppress_itok_output'));
-    $this->assertIdentical("core/modules/image/testsample.png",$config->get('preview_image'));
+    $this->assertIdentical("core/modules/image/testsample.png", $config->get('preview_image'));
   }
 
 }
diff --git a/core/modules/image/tests/src/Unit/ImageStyleTest.php b/core/modules/image/tests/src/Unit/ImageStyleTest.php
index 80ce71329..70191d558 100644
--- a/core/modules/image/tests/src/Unit/ImageStyleTest.php
+++ b/core/modules/image/tests/src/Unit/ImageStyleTest.php
@@ -90,7 +90,7 @@ class ImageStyleTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->entityTypeId = $this->randomMachineName();
     $this->provider = $this->randomMachineName();
     $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
diff --git a/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php b/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php
index fab54d368..6c1af2947 100644
--- a/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php
+++ b/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php
@@ -47,7 +47,7 @@ class DenyPrivateImageStyleDownloadTest extends UnitTestCase {
    */
   protected $routeMatch;
 
-  public function setUp() {
+  protected function setUp() {
     $this->routeMatch = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
     $this->policy = new DenyPrivateImageStyleDownload($this->routeMatch);
     $this->response = new Response();
diff --git a/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php
index 6679961a0..1c262b742 100644
--- a/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php
+++ b/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php
@@ -45,7 +45,7 @@ class MigrateImageStylesTest extends MigrateSqlSourceTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     foreach ($this->expectedResults as $k => $row) {
       foreach (array('isid', 'name', 'label') as $field) {
         $this->databaseContents['image_styles'][$k][$field] = $row[$field];
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 6d9f69940..5904685c3 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -49,7 +49,7 @@ function language_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<ul><li>' . t('<em>URL</em> sets the interface language based on a path prefix or domain (for example specifying <em>de</em> for German would result in URLs like <em>example.com/de/contact</em>). The default language does not require a path prefix, but can have one assigned as well. If the language detection is done by domain name, a domain needs to be specified for each language.') . '</li>';
       $output .= '<li>' . t('<em>Session</em> determines the interface language from a request or session parameter (for example <em>example.com?language=de</em> would set the interface language to German based on the use of <em>de</em> as the <em>language</em> parameter).') . '</li>';
       $output .= '<li>' . t('<em>User</em> follows the language configuration set on the user\'s profile page.') . '</li>';
-      $output .= '<li>' . t('<em>Browser</em> sets the interface language based on the browser\'s language settings. Since browsers use different language codes to refer to the same languages, you can add and edit languages codes to map the browser language codes to the <a href=":language_list">language codes</a> used on your site.',  array(':language_list' => \Drupal::url('entity.configurable_language.collection'))) . '</li>';
+      $output .= '<li>' . t('<em>Browser</em> sets the interface language based on the browser\'s language settings. Since browsers use different language codes to refer to the same languages, you can add and edit languages codes to map the browser language codes to the <a href=":language_list">language codes</a> used on your site.', array(':language_list' => \Drupal::url('entity.configurable_language.collection'))) . '</li>';
       $output .= '<li>' . t('<em>Account administration pages</em> follows the configuration set as <em>Administration pages language</em> on the profile page of an administrative user. This method is similar to the <em>User</em> method, but only sets the interface text language on administration pages, independent of the interface text language on other pages.') . '</li>';
       $output .= '<li>' . t('<em>Selected language</em> allows you to specify the site\'s default language or a specific language as the fall-back language. This method should be listed last.') . '</li></ul></dd>';
       $output .= '</dl>';
diff --git a/core/modules/language/src/Entity/ConfigurableLanguage.php b/core/modules/language/src/Entity/ConfigurableLanguage.php
index 89cc16767..fe7f9f6de 100644
--- a/core/modules/language/src/Entity/ConfigurableLanguage.php
+++ b/core/modules/language/src/Entity/ConfigurableLanguage.php
@@ -63,14 +63,14 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
   /**
    * The direction of language, either DIRECTION_LTR or DIRECTION_RTL.
    *
-   * @var integer
+   * @var int
    */
   protected $direction = self::DIRECTION_LTR;
 
   /**
    * The weight of the language, used in lists of languages.
    *
-   * @var integer
+   * @var int
    */
   protected $weight = 0;
 
diff --git a/core/modules/language/src/Tests/EntityDefaultLanguageTest.php b/core/modules/language/src/Tests/EntityDefaultLanguageTest.php
index b3b109ac6..9479d580f 100644
--- a/core/modules/language/src/Tests/EntityDefaultLanguageTest.php
+++ b/core/modules/language/src/Tests/EntityDefaultLanguageTest.php
@@ -28,7 +28,7 @@ class EntityDefaultLanguageTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->installEntitySchema('user');
diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
index 9591618fc..6e2e70a41 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
@@ -117,7 +117,7 @@ class LanguageConfigurationElementTest extends WebTestBase {
     $this->assertTrue($configurable_language->isDefault(), 'The en language entity is flagged as the default language.');
 
     $this->config('system.site')->set('default_langcode', 'cc')->save();
-    ContentLanguageSettings::loadByEntityTypeBundle('entity_test','custom_bundle')
+    ContentLanguageSettings::loadByEntityTypeBundle('entity_test', 'custom_bundle')
       ->setLanguageAlterable(TRUE)
       ->setDefaultLangcode(LanguageInterface::LANGCODE_SITE_DEFAULT)
       ->save();
diff --git a/core/modules/language/src/Tests/Views/FilterLanguageTest.php b/core/modules/language/src/Tests/Views/FilterLanguageTest.php
index 591ad179c..b3cc5d819 100644
--- a/core/modules/language/src/Tests/Views/FilterLanguageTest.php
+++ b/core/modules/language/src/Tests/Views/FilterLanguageTest.php
@@ -45,6 +45,18 @@ class FilterLanguageTest extends LanguageTestBase {
         'name' => $name,
       ));
       $this->assertIdenticalResultset($view, $expected, array('views_test_data_name' => 'name'));
+
+      $expected = [
+        '***LANGUAGE_site_default***',
+        '***LANGUAGE_language_interface***',
+        '***LANGUAGE_language_content***',
+        'en',
+        'xx-lolspeak',
+        'und',
+        'zxx'
+      ];
+      $this->assertIdentical(array_keys($view->filter['langcode']->getValueOptions()), $expected);
+
       $view->destroy();
     }
   }
diff --git a/core/modules/language/tests/src/Unit/Config/LanguageConfigOverrideTest.php b/core/modules/language/tests/src/Unit/Config/LanguageConfigOverrideTest.php
index 0c979d9d7..ff2a4e79b 100644
--- a/core/modules/language/tests/src/Unit/Config/LanguageConfigOverrideTest.php
+++ b/core/modules/language/tests/src/Unit/Config/LanguageConfigOverrideTest.php
@@ -56,7 +56,7 @@ class LanguageConfigOverrideTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->storage = $this->getMock('Drupal\Core\Config\StorageInterface');
     $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
     $this->typedConfig = $this->getMock('\Drupal\Core\Config\TypedConfigManagerInterface');
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
index bc5d72b00..fceb4c57d 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
@@ -30,7 +30,7 @@ class LinkTypeConstraint extends Constraint implements ConstraintValidatorInterf
   protected $context;
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   public function initialize(ExecutionContextInterface $context) {
     $this->context = $context;
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index ca8df4746..74b76ecf3 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -1035,6 +1035,31 @@ function locale_translation_use_remote_source() {
  * layout issues (div) or a possible attack vector (img).
  */
 function locale_string_is_safe($string) {
+  // Some strings have tokens in them. For tokens in the first part of href or
+  // src HTML attributes, \Drupal\Component\Utility\Xss::filter() removes part
+  // of the token, the part before the first colon.
+  // \Drupal\Component\Utility\Xss::filter() assumes it could be an attempt to
+  // inject javascript. When \Drupal\Component\Utility\Xss::filter() removes
+  // part of tokens, it causes the string to not be translatable when it should
+  // be translatable.
+  // @see \Drupal\locale\Tests\LocaleStringIsSafeTest::testLocaleStringIsSafe()
+  //
+  // We can recognize tokens since they are wrapped with brackets and are only
+  // composed of alphanumeric characters, colon, underscore, and dashes. We can
+  // be sure these strings are safe to strip out before the string is checked in
+  // \Drupal\Component\Utility\Xss::filter() because no dangerous javascript
+  // will match that pattern.
+  //
+  // Strings with tokens should not be assumed to be dangerous because even if
+  // we evaluate them to be safe here, later replacing the token inside the
+  // string will automatically mark it as unsafe as it is not the same string
+  // anymore.
+  //
+  // @todo Do not strip out the token. Fix
+  //   \Drupal\Component\Utility\Xss::filter() to not incorrectly alter the
+  //   string. https://www.drupal.org/node/2372127
+  $string = preg_replace('/\[[a-z0-9_-]+(:[a-z0-9_-]+)+\]/i', '', $string);
+
   return Html::decodeEntities($string) == Html::decodeEntities(Xss::filter($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var')));
 }
 
diff --git a/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml
index 29603ee22..1d55460bf 100644
--- a/core/modules/locale/locale.services.yml
+++ b/core/modules/locale/locale.services.yml
@@ -6,6 +6,8 @@ services:
   locale.config_manager:
     class: Drupal\locale\LocaleConfigManager
     arguments: ['@config.storage', '@locale.storage', '@config.factory', '@config.typed', '@language_manager', '@locale.default.config.storage']
+    calls:
+      - [_setConfigManager, ['@config.manager']]
   locale.storage:
     class: Drupal\locale\StringDatabaseStorage
     arguments: ['@database']
diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php
index cab881661..db6c181f1 100644
--- a/core/modules/locale/src/LocaleConfigManager.php
+++ b/core/modules/locale/src/LocaleConfigManager.php
@@ -9,6 +9,7 @@ namespace Drupal\locale;
 
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Config\ConfigManagerInterface;
 use Drupal\Core\Config\StorageInterface;
 use Drupal\Core\Config\TypedConfigManagerInterface;
 use Drupal\Core\StringTranslation\TranslatableMarkup;
@@ -95,6 +96,17 @@ class LocaleConfigManager {
    */
   protected $defaultConfigStorage;
 
+  /**
+   * The configuration manager.
+   *
+   * @var \Drupal\Core\Config\ConfigManagerInterface
+   *
+   * @internal
+   *   Will be made protected and renamed to $configManager in 8.1.0.
+   *   https://www.drupal.org/node/2628132
+   */
+  private $_configManager;
+
   /**
    * Creates a new typed configuration manager.
    *
@@ -120,6 +132,36 @@ class LocaleConfigManager {
     $this->defaultConfigStorage = $default_config_storage;
   }
 
+  /**
+   * Sets the configuration manager service.
+   *
+   * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager
+   *
+   * @internal
+   *   Will be replaced by constructor injection in 8.1.0.
+   *   https://www.drupal.org/node/2628132
+   */
+  public function _setConfigManager(ConfigManagerInterface $config_manager) {
+    $this->_configManager = $config_manager;
+  }
+
+  /**
+   * Gets the configuration manager service.
+   *
+   * @return \Drupal\Core\Config\ConfigManagerInterface
+   *   The config manager
+   *
+   * @internal
+   *   Will be replaced by constructor injection in 8.1.0.
+   *   https://www.drupal.org/node/2628132
+   */
+  private final function _getConfigManager() {
+    if (!isset($this->_configManager)) {
+      $this->_configManager = \Drupal::service('config.manager');
+    }
+    return $this->_configManager;
+  }
+
   /**
    * Gets array of translated strings for Locale translatable configuration.
    *
@@ -477,10 +519,21 @@ class LocaleConfigManager {
    *   configuration exists.
    */
   public function getDefaultConfigLangcode($name) {
-    $shipped = $this->defaultConfigStorage->read($name);
-    if (!empty($shipped)) {
-      return !empty($shipped['langcode']) ? $shipped['langcode'] : 'en';
+    // Config entities that do not have the 'default_config_hash' cannot be
+    // shipped configuration regardless of whether there is a name match.
+    // configurable_language entities are a special case since they can be
+    // translated regardless of whether they are shipped if they in the standard
+    // language list.
+    $config_entity_type = $this->_getConfigManager()->getEntityTypeIdByName($name);
+    if (!$config_entity_type || $config_entity_type === 'configurable_language'
+      || !empty($this->configFactory->get($name)->get('_core.default_config_hash'))
+    ) {
+      $shipped = $this->defaultConfigStorage->read($name);
+      if (!empty($shipped)) {
+        return !empty($shipped['langcode']) ? $shipped['langcode'] : 'en';
+      }
     }
+    return NULL;
   }
 
   /**
diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php
index 1aa769649..658f5657f 100644
--- a/core/modules/locale/src/StringBase.php
+++ b/core/modules/locale/src/StringBase.php
@@ -17,7 +17,7 @@ abstract class StringBase implements StringInterface {
   /**
    * The string identifier.
    *
-   * @var integer
+   * @var int
    */
   public $lid;
 
diff --git a/core/modules/locale/src/Tests/LocaleConfigManagerTest.php b/core/modules/locale/src/Tests/LocaleConfigManagerTest.php
index 39f14cba3..193f4facb 100644
--- a/core/modules/locale/src/Tests/LocaleConfigManagerTest.php
+++ b/core/modules/locale/src/Tests/LocaleConfigManagerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\locale\Tests;
 
+use Drupal\block\Entity\Block;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\KernelTestBase;
 
@@ -22,7 +23,14 @@ class LocaleConfigManagerTest extends KernelTestBase {
    *
    * @var array
    */
-  public static $modules = array('language', 'locale', 'locale_test');
+  public static $modules = array('system', 'language', 'locale', 'locale_test', 'block');
+
+  /**
+   * This test creates simple config on the fly breaking schema checking.
+   *
+   * @var bool
+   */
+  protected $strictConfigSchema = FALSE;
 
   /**
    * Tests hasTranslation().
@@ -72,6 +80,49 @@ class LocaleConfigManagerTest extends KernelTestBase {
     $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'Before installing a module the locale config manager can not access the shipped configuration.');
     \Drupal::service('module_installer')->install(['locale_test_translate']);
     $this->assertEqual('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('locale_test_translate.settings'), 'After installing a module the locale config manager can get the shipped configuration langcode.');
+
+    $simple_config = \Drupal::configFactory()->getEditable('locale_test_translate.simple_config_extra');
+    $simple_config->set('foo', 'bar')->save();
+    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode($simple_config->getName()), 'Simple config created through the API is not treated as shipped configuration.');
+
+    $block = Block::create(array(
+      'id' => 'test_default_config',
+      'theme' => 'classy',
+      'status' => TRUE,
+      'region' => 'content',
+      'plugin' => 'local_tasks_block',
+      'settings' => [
+        'id' => 'local_tasks_block',
+        'label' => $this->randomMachineName(),
+        'provider' => 'core',
+        'label_display' => FALSE,
+        'primary' => TRUE,
+        'secondary' => TRUE,
+      ],
+    ));
+    $block->save();
+
+    // Install the theme after creating the block as installing the theme will
+    // install the block provided by the locale_test module.
+    \Drupal::service('theme_installer')->install(['classy']);
+
+    // The test_default_config block provided by the locale_test module will not
+    // be installed because a block with the same ID already exists.
+    $this->installConfig(['locale_test']);
+    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('block.block.test_default_config'), 'The block.block.test_default_config is not shipped configuration.');
+    // Delete the block so we can install the one provided by the locale_test
+    // module.
+    $block->delete();
+    $this->installConfig(['locale_test']);
+    $this->assertEqual('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('block.block.test_default_config'), 'The block.block.test_default_config is shipped configuration.');
+
+    // Test the special case for configurable_language config entities.
+    $fr_language = ConfigurableLanguage::createFromLangcode('fr');
+    $fr_language->save();
+    $this->assertEqual('en', \Drupal::service('locale.config_manager')->getDefaultConfigLangcode('language.entity.fr'), 'The language.entity.fr is treated as shipped configuration because it is a configurable_language config entity and in the standard language list.');
+    $custom_language = ConfigurableLanguage::createFromLangcode('custom');
+    $custom_language->save();
+    $this->assertNull(\Drupal::service('locale.config_manager')->getDefaultConfigLangcode('language.entity.custom'), 'The language.entity.custom is not shipped configuration because it is not in the standard language list.');
   }
 
 }
diff --git a/core/modules/locale/src/Tests/LocaleConfigurableLanguageManagerTest.php b/core/modules/locale/src/Tests/LocaleConfigurableLanguageManagerTest.php
new file mode 100644
index 000000000..6bdbc4373
--- /dev/null
+++ b/core/modules/locale/src/Tests/LocaleConfigurableLanguageManagerTest.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\locale\Tests\LocaleConfigurableLanguageManagerTest.
+ */
+
+namespace Drupal\locale\Tests;
+
+use Drupal\Core\Language\LanguageInterface;
+use Drupal\language\Entity\ConfigurableLanguage;
+use Drupal\simpletest\KernelTestBase;
+
+
+/**
+ * Tests that the configurable language manager and locale operate correctly.
+ *
+ * @group locale
+ */
+class LocaleConfigurableLanguageManagerTest extends KernelTestBase {
+
+  /**
+   * A list of modules to install for this test.
+   *
+   * @var array
+   */
+  public static $modules = ['language', 'locale'];
+
+  public function testGetLanguages() {
+    $this->installSchema('locale', ['locales_source', 'locales_target', 'locales_location']);
+    $default_language = new ConfigurableLanguage(['label' => $this->randomMachineName(), 'id' => 'default', 'weight' => 0], 'configurable_language');
+    $default_language->save();
+
+    // Set new default language.
+    \Drupal::service('language.default')->set($default_language);
+    \Drupal::service('string_translation')->setDefaultLangcode($default_language->getId());
+
+    $languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
+    $this->assertEqual(['default', 'und', 'zxx'], array_keys($languages));
+
+    $configurableLanguage = new ConfigurableLanguage(['label' => $this->randomMachineName(), 'id' => 'test', 'weight' => 1], 'configurable_language');
+    // Simulate a configuration sync by setting the flag otherwise the locked
+    // language weights would be updated whilst saving.
+    // @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
+    $configurableLanguage->setSyncing(TRUE)->save();
+
+    $languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL);
+    $this->assertEqual(['default', 'test', 'und', 'zxx'], array_keys($languages));
+  }
+
+}
diff --git a/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php b/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
index 3870cb0f4..eb7e27236 100644
--- a/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
+++ b/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
@@ -27,7 +27,7 @@ class LocaleLocaleLookupTest extends WebTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Change the language default object to different values.
diff --git a/core/modules/locale/src/Tests/LocaleStringIsSafeTest.php b/core/modules/locale/src/Tests/LocaleStringIsSafeTest.php
new file mode 100644
index 000000000..603187f54
--- /dev/null
+++ b/core/modules/locale/src/Tests/LocaleStringIsSafeTest.php
@@ -0,0 +1,106 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\locale\Tests\LocaleStringIsSafeTest.
+ */
+
+namespace Drupal\locale\Tests;
+
+use Drupal\simpletest\KernelTestBase;
+
+/**
+ * Tests locale translation safe string handling.
+ *
+ * @group locale
+ */
+class LocaleStringIsSafeTest extends KernelTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['locale', 'locale_test'];
+
+  /**
+   * Tests for locale_string_is_safe().
+   */
+  public function testLocaleStringIsSafe() {
+    // Check a translatable string without HTML.
+    $string = 'Hello world!';
+    $result = locale_string_is_safe($string);
+    $this->assertTrue($result);
+
+    // Check a translatable string which includes trustable HTML.
+    $string = 'Hello <strong>world</strong>!';
+    $result = locale_string_is_safe($string);
+    $this->assertTrue($result);
+
+    // Check an untranslatable string which includes untrustable HTML (according
+    // to the locale_string_is_safe() function definition).
+    $string = 'Hello <img src="world.png" alt="world" />!';
+    $result = locale_string_is_safe($string);
+    $this->assertFalse($result);
+
+    // Check a translatable string which includes a token in an href attribute.
+    $string = 'Hi <a href="[current-user:url]">user</a>';
+    $result = locale_string_is_safe($string);
+    $this->assertTrue($result);
+  }
+
+  /**
+   * Tests if a translated and tokenized string is properly escaped by Twig.
+   *
+   * In each assert* call we add a new line at the expected result to match the
+   * newline at the end of the template file.
+   */
+  public function testLocalizedTokenizedString() {
+    $tests_to_do = [
+      1 => [
+        'original' => 'Go to the <a href="[locale_test:security_test1]">frontpage</a>',
+        'replaced' => 'Go to the &lt;a href=&quot;javascript:alert(&amp;#039;Mooooh!&amp;#039;);&quot;&gt;frontpage&lt;/a&gt;',
+      ],
+      2 => [
+        'original' => 'Hello <strong>[locale_test:security_test2]</strong>!',
+        'replaced' => 'Hello &lt;strong&gt;&amp;lt;script&amp;gt;alert(&amp;#039;Mooooh!&amp;#039;);&amp;lt;/script&amp;gt;&lt;/strong&gt;!',
+      ],
+    ];
+
+    foreach ($tests_to_do as $i => $test) {
+      $original_string = $test['original'];
+      $rendered_original_string = \Drupal::theme()->render('locale_test_tokenized', ['content' => $original_string]);
+      // Twig assumes that strings are unsafe so it escapes them, and so the
+      // original and the rendered version should be different.
+      $this->assertNotEqual(
+        $rendered_original_string,
+        $original_string . "\n",
+        'Security test ' . $i . ' before translation'
+      );
+
+      // Pass the original string to the t() function to get it marked as safe.
+      $safe_string = t($original_string);
+      $rendered_safe_string = \Drupal::theme()->render('locale_test_tokenized', ['content' => $safe_string]);
+      // t() function always marks the string as safe so it won't be escaped,
+      // and should be the same as the original.
+      $this->assertEqual(
+        $rendered_safe_string,
+        $original_string . "\n",
+        'Security test ' . $i . ' after translation before token replacement'
+      );
+
+      // Replace tokens in the safe string to inject it with dangerous content.
+      // @see locale_test_tokens().
+      $unsafe_string = \Drupal::token()->replace($safe_string);
+      $rendered_unsafe_string = \Drupal::theme()->render('locale_test_tokenized', ['content' => $unsafe_string]);
+      // Token replacement changes the string so it is not marked as safe
+      // anymore. Check it is escaped the way we expect.
+      $this->assertEqual(
+        $rendered_unsafe_string,
+        $test['replaced'] . "\n",
+        'Security test ' . $i . ' after translation  after token replacement'
+      );
+    }
+  }
+
+}
diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php
index 41922bbc4..cc2aed324 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateBase.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php
@@ -19,28 +19,28 @@ abstract class LocaleUpdateBase extends WebTestBase {
   /**
    * Timestamp for an old translation.
    *
-   * @var integer
+   * @var int
    */
   protected $timestampOld;
 
   /**
    * Timestamp for a medium aged translation.
    *
-   * @var integer
+   * @var int
    */
   protected $timestampMedium;
 
   /**
    * Timestamp for a new translation.
    *
-   * @var integer
+   * @var int
    */
   protected $timestampNew;
 
   /**
    * Timestamp for current time.
    *
-   * @var integer
+   * @var int
    */
   protected $timestampNow;
 
diff --git a/core/modules/locale/tests/modules/locale_test/config/optional/block.block.test_default_config.yml b/core/modules/locale/tests/modules/locale_test/config/optional/block.block.test_default_config.yml
new file mode 100644
index 000000000..15f08072d
--- /dev/null
+++ b/core/modules/locale/tests/modules/locale_test/config/optional/block.block.test_default_config.yml
@@ -0,0 +1,19 @@
+langcode: en
+status: true
+dependencies:
+  theme:
+    - classy
+id: test_default_config
+theme: classy
+region: content
+weight: -40
+provider: null
+plugin: local_tasks_block
+settings:
+  id: local_tasks_block
+  label: Tabs
+  provider: core
+  label_display: '0'
+  primary: true
+  secondary: true
+visibility: {  }
diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module
index 83909d30e..b59dfee8b 100644
--- a/core/modules/locale/tests/modules/locale_test/locale_test.module
+++ b/core/modules/locale/tests/modules/locale_test/locale_test.module
@@ -146,3 +146,60 @@ function locale_test_language_fallback_candidates_locale_lookup_alter(array &$ca
   \Drupal::state()->set('locale.test_language_fallback_candidates_locale_lookup_alter_candidates', $candidates);
   \Drupal::state()->set('locale.test_language_fallback_candidates_locale_lookup_alter_context', $context);
 }
+
+/**
+ * Implements hook_theme().
+ */
+function locale_test_theme() {
+  $return = [];
+
+  $return['locale_test_tokenized'] = [
+    'variable' => ['content' => ''],
+  ];
+
+  return $return;
+}
+
+/**
+ * Implements hook_token_info().
+ */
+function locale_test_token_info() {
+  $info = [];
+
+  $info['types']['locale_test'] = [
+    'name' => t('Locale test'),
+    'description' => t('Locale test'),
+  ];
+
+  $info['tokens']['locale_test']['security_test1'] = [
+    'type' => 'text',
+    'name' => t('Security test 1'),
+  ];
+  $info['tokens']['locale_test']['security_test2'] = [
+    'type' => 'text',
+    'name' => t('Security test 2'),
+  ];
+
+  return $info;
+}
+
+/**
+ * Implements hook_tokens().
+ */
+function locale_test_tokens($type, $tokens, array $data = [], array $options = []) {
+  $return = [];
+  if ($type == 'locale_test') {
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        case 'security_test1':
+          $return[$original] = "javascript:alert('Mooooh!');";
+          break;
+        case 'security_test2':
+          $return[$original] = "<script>alert('Mooooh!');</script>";
+          break;
+      }
+    }
+  }
+
+  return $return;
+}
diff --git a/core/modules/locale/tests/modules/locale_test/templates/locale-test-tokenized.html.twig b/core/modules/locale/tests/modules/locale_test/templates/locale-test-tokenized.html.twig
new file mode 100644
index 000000000..cddd07099
--- /dev/null
+++ b/core/modules/locale/tests/modules/locale_test/templates/locale-test-tokenized.html.twig
@@ -0,0 +1 @@
+{{ content }}
diff --git a/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php b/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php
index 1c3d7485a..24bd4889c 100644
--- a/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php
+++ b/core/modules/locale/tests/src/Unit/Menu/LocaleLocalTasksTest.php
@@ -33,7 +33,7 @@ class LocaleLocalTasksTest extends LocalTaskIntegrationTestBase {
    */
   public function testLocalePageLocalTasks($route) {
     $tasks = array(
-      0 => array('locale.translate_page', 'locale.translate_import', 'locale.translate_export','locale.settings'),
+      0 => array('locale.translate_page', 'locale.translate_import', 'locale.translate_export', 'locale.settings'),
     );
     $this->assertLocalTasks($route, $tasks);
   }
diff --git a/core/modules/menu_link_content/migration_templates/d6_menu_links.yml b/core/modules/menu_link_content/migration_templates/d6_menu_links.yml
deleted file mode 100644
index e58b202fd..000000000
--- a/core/modules/menu_link_content/migration_templates/d6_menu_links.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-id: d6_menu_links
-label: Menu links
-migration_tags:
-  - Drupal 6
-source:
-  plugin: menu_link
-  constants:
-    bundle: menu_link_content
-process:
-  id: mlid
-  bundle: 'constants/bundle'
-  title: link_title
-  description:
-    plugin: extract
-    source:
-      - options
-    index:
-      - 0
-      - attributes
-      - title
-    default: ''
-  menu_name:
-    plugin: migration
-    migration: menu
-    source: menu_name
-  'link/uri':
-    plugin: internal_uri
-    source:
-      - link_path
-  'link/options': options
-  external: external
-  weight: weight
-  expanded: expanded
-  enabled: enabled
-  parent:
-    -
-      plugin: skip_on_empty
-      method: process
-      source: plid
-    -
-      plugin: migration
-      migration: d6_menu_links
-  changed: updated
-destination:
-  plugin: entity:menu_link_content
-migration_dependencies:
-  required:
-    - menu
diff --git a/core/modules/menu_link_content/migration_templates/d7_menu_links.yml b/core/modules/menu_link_content/migration_templates/menu_links.yml
similarity index 71%
rename from core/modules/menu_link_content/migration_templates/d7_menu_links.yml
rename to core/modules/menu_link_content/migration_templates/menu_links.yml
index d7b1d87ae..131162ed3 100644
--- a/core/modules/menu_link_content/migration_templates/d7_menu_links.yml
+++ b/core/modules/menu_link_content/migration_templates/menu_links.yml
@@ -1,6 +1,7 @@
-id: d7_menu_links
+id: menu_links
 label: Menu links
 migration_tags:
+  - Drupal 6
   - Drupal 7
 source:
   plugin: menu_link
@@ -10,19 +11,17 @@ process:
   id: mlid
   bundle: 'constants/bundle'
   title: link_title
-  description:
-    plugin: extract
-    source:
-      - options
-    index:
-      - 0
-      - attributes
-      - title
-    default: ''
+  description: description
   menu_name:
-    plugin: migration
-    migration: menu
-    source: menu_name
+    -
+      plugin: migration
+      migration: menu
+      source: menu_name
+    -
+      plugin: static_map
+      map:
+        management: admin
+      bypass: true
   'link/uri':
     plugin: internal_uri
     source:
@@ -42,16 +41,15 @@ process:
   expanded: expanded
   enabled: enabled
   parent:
-    -
-      plugin: skip_on_empty
-      method: process
-      source: plid
-    -
-      plugin: migration
-      migration: d7_menu_links
+    plugin: menu_link_parent
+    source:
+      - plid
+      - @menu_name
+      - parent_link_path
   changed: updated
 destination:
   plugin: entity:menu_link_content
+  no_stub: true
 migration_dependencies:
   required:
     - menu
diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
index d83f87115..dc1410908 100644
--- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
+++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
@@ -200,15 +200,22 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
 
     // The menu link can just be updated if there is already an menu link entry
     // on both entity and menu link plugin level.
-    if ($update && $menu_link_manager->getDefinition($this->getPluginId())) {
+    $definition = $this->getPluginDefinition();
+    // Even when $update is FALSE, for top level links it is possible the link
+    // already is in the storage because of the getPluginDefinition() call
+    // above, see https://www.drupal.org/node/2605684#comment-10515450 for the
+    // call chain. Because of this the $update flag is ignored and only the
+    // existence of the definition (equals to being in the tree storage) is
+    // checked.
+    if ($menu_link_manager->getDefinition($this->getPluginId(), FALSE)) {
       // When the entity is saved via a plugin instance, we should not call
       // the menu tree manager to update the definition a second time.
       if (!$this->insidePlugin) {
-        $menu_link_manager->updateDefinition($this->getPluginId(), $this->getPluginDefinition(), FALSE);
+        $menu_link_manager->updateDefinition($this->getPluginId(), $definition, FALSE);
       }
     }
     else {
-      $menu_link_manager->addDefinition($this->getPluginId(), $this->getPluginDefinition());
+      $menu_link_manager->addDefinition($this->getPluginId(), $definition);
     }
   }
 
diff --git a/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
index 93cf5836f..54c9a2011 100644
--- a/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
+++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\menu_link_content\Plugin\migrate\source;
 
+use Drupal\Component\Utility\Unicode;
 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
 use Drupal\migrate\Row;
 
@@ -23,12 +24,20 @@ class MenuLink extends DrupalSqlBase {
    * {@inheritdoc}
    */
   public function query() {
-    return $this->select('menu_links', 'ml')
-      ->fields('ml')
-      ->orderby('ml.depth')
-      ->orderby('ml.mlid')
-      ->condition('module', 'menu')
-      ->condition('customized', 1);
+    $query = $this->select('menu_links', 'ml')
+      ->fields('ml');
+    $and = $query->andConditionGroup()
+      ->condition('ml.module', 'menu')
+      ->condition('ml.router_path', ['admin/build/menu-customize/%', 'admin/structure/menu/manage/%'], 'NOT IN');
+    $condition = $query->orConditionGroup()
+      ->condition('ml.customized', 1)
+      ->condition($and);
+    $query->condition($condition);
+    $query->leftJoin('menu_links', 'pl', 'ml.plid = pl.mlid');
+    $query->addField('pl', 'link_path', 'parent_link_path');
+    $query->orderBy('ml.depth');
+    $query->orderby('ml.mlid');
+    return $query;
   }
 
   /**
@@ -70,6 +79,7 @@ class MenuLink extends DrupalSqlBase {
   public function prepareRow(Row $row) {
     $row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
     $row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
+    $row->setSourceProperty('description', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255));
 
     return parent::prepareRow($row);
   }
@@ -79,6 +89,7 @@ class MenuLink extends DrupalSqlBase {
    */
   public function getIds() {
     $ids['mlid']['type'] = 'integer';
+    $ids['mlid']['alias'] = 'ml';
     return $ids;
   }
 
diff --git a/core/modules/menu_link_content/src/Tests/Migrate/d6/MigrateMenuLinkTest.php b/core/modules/menu_link_content/src/Tests/Migrate/d6/MigrateMenuLinkTest.php
index f6346fc53..8fc22ef0c 100644
--- a/core/modules/menu_link_content/src/Tests/Migrate/d6/MigrateMenuLinkTest.php
+++ b/core/modules/menu_link_content/src/Tests/Migrate/d6/MigrateMenuLinkTest.php
@@ -29,7 +29,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
     parent::setUp();
     $this->installSchema('system', ['router']);
     $this->installEntitySchema('menu_link_content');
-    $this->executeMigrations(['menu', 'd6_menu_links']);
+    $this->executeMigrations(['menu', 'menu_links']);
   }
 
   /**
diff --git a/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php b/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php
index 6b9814a26..68c6d7aa7 100644
--- a/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php
+++ b/core/modules/menu_link_content/src/Tests/Migrate/d7/MigrateMenuLinkTest.php
@@ -8,6 +8,8 @@
 namespace Drupal\menu_link_content\Tests\Migrate\d7;
 
 use Drupal\Core\Database\Database;
+use Drupal\Core\Menu\MenuTreeParameters;
+use Drupal\Core\Url;
 use Drupal\menu_link_content\Entity\MenuLinkContent;
 use Drupal\menu_link_content\MenuLinkContentInterface;
 use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
@@ -18,6 +20,7 @@ use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
  * @group menu_link_content
  */
 class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
+  const MENU_NAME = 'menu-test-menu';
 
   /**
    * {@inheritdoc}
@@ -32,6 +35,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
     $this->installSchema('system', ['router']);
     $this->installEntitySchema('menu_link_content');
     $this->executeMigration('menu');
+    \Drupal::service('router.builder')->rebuild();
   }
 
   /**
@@ -70,16 +74,44 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
     $this->assertIdentical($attributes, $menu_link->link->options);
     $this->assertIdentical($uri, $menu_link->link->uri);
     $this->assertIdentical($weight, $menu_link->getWeight());
+    return $menu_link;
   }
 
   /**
    * Tests migration of menu links.
    */
   public function testMenuLinks() {
-    $this->executeMigration('d7_menu_links');
-    $this->assertEntity(467, 'Google', 'menu-test-menu', 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0);
-    $this->assertEntity(468, 'Yahoo', 'menu-test-menu', 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0);
-    $this->assertEntity(469, 'Bing', 'menu-test-menu', 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0);
+    $this->executeMigration('menu_links');
+    $this->assertEntity(469, 'Bing', static::MENU_NAME, 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0);
+    $this->assertEntity(467, 'Google', static::MENU_NAME, 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0);
+    $this->assertEntity(468, 'Yahoo', static::MENU_NAME, 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0);
+    $menu_link_tree_service = \Drupal::service('menu.link_tree');
+    $parameters = new MenuTreeParameters();
+    $tree = $menu_link_tree_service->load(static::MENU_NAME, $parameters);
+    $this->assertEqual(2, count($tree));
+    $children = 0;
+    $google_found = FALSE;
+    foreach ($tree as $menu_link_tree_element) {
+      $children += $menu_link_tree_element->hasChildren;
+      if ($menu_link_tree_element->link->getUrlObject()->toString() == 'http://bing.com') {
+        $this->assertEqual(reset($menu_link_tree_element->subtree)->link->getUrlObject()->toString(), 'http://google.com');
+        $google_found = TRUE;
+      }
+    }
+    $this->assertEqual(1, $children);
+    $this->assertTrue($google_found);
+    // Now find the custom link under a system link.
+    $parameters->root = 'system.admin_structure';
+    $tree = $menu_link_tree_service->load(static::MENU_NAME, $parameters);
+    $found = FALSE;
+    foreach ($tree as $menu_link_tree_element) {
+      $this->pass($menu_link_tree_element->link->getUrlObject()->toString());
+      if ($menu_link_tree_element->link->getTitle() == 'custom link test') {
+        $found = TRUE;
+        break;
+      }
+    }
+    $this->assertTrue($found);
   }
 
   /**
@@ -94,8 +126,8 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
       ->condition('mlid', 467)
       ->execute();
 
-    $this->executeMigration('d7_menu_links');
-    $this->assertEntity(467, 'Google', 'menu-test-menu', NULL, TRUE, FALSE, [], 'http://google.com', 0);
+    $this->executeMigration('menu_links');
+    $this->assertEntity(467, 'Google', static::MENU_NAME, NULL, TRUE, FALSE, [], 'http://google.com', 0);
   }
 
 }
diff --git a/core/modules/menu_link_content/tests/src/Unit/Plugin/migrate/source/MenuLinkSourceTest.php b/core/modules/menu_link_content/tests/src/Unit/Plugin/migrate/source/MenuLinkSourceTest.php
index 4ec1f096e..9484ca4d8 100644
--- a/core/modules/menu_link_content/tests/src/Unit/Plugin/migrate/source/MenuLinkSourceTest.php
+++ b/core/modules/menu_link_content/tests/src/Unit/Plugin/migrate/source/MenuLinkSourceTest.php
@@ -6,6 +6,7 @@
  */
 namespace Drupal\Tests\menu_link_content\Unit\Plugin\migrate\source;
 
+use Drupal\Component\Utility\Unicode;
 use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
 
 /**
@@ -25,6 +26,92 @@ class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
   );
 
   protected $expectedResults = array(
+    array(
+      // Customized menu link, provided by system module.
+      'menu_name' => 'menu-test-menu',
+      'mlid' => 140,
+      'plid' => 0,
+      'link_path' => 'admin/config/system/cron',
+      'router_path' => 'admin/config/system/cron',
+      'link_title' => 'Cron',
+      'options' => array(),
+      'module' => 'system',
+      'hidden' => 0,
+      'external' => 0,
+      'has_children' => 0,
+      'expanded' => 0,
+      'weight' => 0,
+      'depth' => 0,
+      'customized' => 1,
+      'p1' => '0',
+      'p2' => '0',
+      'p3' => '0',
+      'p4' => '0',
+      'p5' => '0',
+      'p6' => '0',
+      'p7' => '0',
+      'p8' => '0',
+      'p9' => '0',
+      'updated' => '0',
+    ),
+    array(
+      // D6 customized menu link, provided by menu module.
+      'menu_name' => 'menu-test-menu',
+      'mlid' => 141,
+      'plid' => 0,
+      'link_path' => 'node/141',
+      'router_path' => 'node/%',
+      'link_title' => 'Node 141',
+      'options' => array(),
+      'module' => 'menu',
+      'hidden' => 0,
+      'external' => 0,
+      'has_children' => 0,
+      'expanded' => 0,
+      'weight' => 0,
+      'depth' => 0,
+      'customized' => 1,
+      'p1' => '0',
+      'p2' => '0',
+      'p3' => '0',
+      'p4' => '0',
+      'p5' => '0',
+      'p6' => '0',
+      'p7' => '0',
+      'p8' => '0',
+      'p9' => '0',
+      'updated' => '0',
+      'description' => '',
+    ),
+    array(
+      // D6 non-customized menu link, provided by menu module.
+      'menu_name' => 'menu-test-menu',
+      'mlid' => 142,
+      'plid' => 0,
+      'link_path' => 'node/142',
+      'router_path' => 'node/%',
+      'link_title' => 'Node 142',
+      'options' => array(),
+      'module' => 'menu',
+      'hidden' => 0,
+      'external' => 0,
+      'has_children' => 0,
+      'expanded' => 0,
+      'weight' => 0,
+      'depth' => 0,
+      'customized' => 0,
+      'p1' => '0',
+      'p2' => '0',
+      'p3' => '0',
+      'p4' => '0',
+      'p5' => '0',
+      'p6' => '0',
+      'p7' => '0',
+      'p8' => '0',
+      'p9' => '0',
+      'updated' => '0',
+      'description' => '',
+    ),
     array(
       'menu_name' => 'menu-test-menu',
       'mlid' => 138,
@@ -51,6 +138,7 @@ class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
       'p8' => '0',
       'p9' => '0',
       'updated' => '0',
+      'description' => 'Test menu link 1',
     ),
     array(
       'menu_name' => 'menu-test-menu',
@@ -78,17 +166,55 @@ class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
       'p8' => '0',
       'p9' => '0',
       'updated' => '0',
+      'description' => 'Test menu link 2',
     ),
   );
 
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
-    foreach ($this->expectedResults as $k => $row) {
+  protected function setUp() {
+    $this->databaseContents['menu_links'] = $this->expectedResults;
+
+    // Add long link title attributes.
+    $title = $this->getRandomGenerator()->string('500');
+    $this->databaseContents['menu_links'][0]['options']['attributes']['title'] = $title;
+    $this->expectedResults[0]['description'] = Unicode::truncate($title, 255);
+
+    // D6 menu link to a custom menu, provided by menu module.
+    $this->databaseContents['menu_links'][] = [
+      'menu_name' => 'menu-user',
+      'mlid' => 143,
+      'plid' => 0,
+      'link_path' => 'admin/build/menu-customize/navigation',
+      'router_path' => 'admin/build/menu-customize/%',
+      'link_title' => 'Navigation',
+      'options' => array(),
+      'module' => 'menu',
+      'hidden' => 0,
+      'external' => 0,
+      'has_children' => 0,
+      'expanded' => 0,
+      'weight' => 0,
+      'depth' => 0,
+      'customized' => 0,
+      'p1' => '0',
+      'p2' => '0',
+      'p3' => '0',
+      'p4' => '0',
+      'p5' => '0',
+      'p6' => '0',
+      'p7' => '0',
+      'p8' => '0',
+      'p9' => '0',
+      'updated' => '0',
+      'description' => '',
+    ];
+
+    array_walk($this->databaseContents['menu_links'], function (&$row) {
       $row['options'] = serialize($row['options']);
-      $this->databaseContents['menu_links'][$k] = $row;
-    }
+    });
+
     parent::setUp();
   }
 
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index 3baf11719..7c01f6fe0 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -270,7 +270,7 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) {
   else {
     $default = $node_type->getThirdPartySetting('menu_ui', 'parent', 'main:');
   }
-  $parent_element = $menu_parent_selector->parentSelectElement($default,  $defaults['id'], $available_menus);
+  $parent_element = $menu_parent_selector->parentSelectElement($default, $defaults['id'], $available_menus);
   // If no possible parent menu items were found, there is nothing to display.
   if (empty($parent_element)) {
     return;
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index f8c26c903..d88911ad3 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -116,7 +116,7 @@ class MenuTest extends MenuWebTestBase {
 
     // Verify delete link exists and reset link does not exist.
     $this->drupalGet('admin/structure/menu/manage/' . $this->menu->id());
-    $this->assertLinkByHref(Url::fromRoute('entity.menu_link_content.delete_form',  ['menu_link_content' => $this->items[0]->id()])->toString());
+    $this->assertLinkByHref(Url::fromRoute('entity.menu_link_content.delete_form', ['menu_link_content' => $this->items[0]->id()])->toString());
     $this->assertNoLinkByHref(Url::fromRoute('menu_ui.link_reset', ['menu_link_plugin' => $this->items[0]->getPluginId()])->toString());
     // Check delete and reset access.
     $this->drupalGet('admin/structure/menu/item/' . $this->items[0]->id() . '/delete');
@@ -265,23 +265,23 @@ class MenuTest extends MenuWebTestBase {
     $menu_name = $this->menu->id();
 
     // Test the 'Add link' local action.
-    $this->drupalGet(Url::fromRoute('entity.menu.edit_form',  ['menu' => $menu_name]));
+    $this->drupalGet(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
 
     $this->clickLink(t('Add link'));
     $link_title = $this->randomString();
     $this->drupalPostForm(NULL, array('link[0][uri]' => '/', 'title[0][value]' => $link_title), t('Save'));
-    $this->assertUrl(Url::fromRoute('entity.menu.edit_form',  ['menu' => $menu_name]));
+    $this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
     // Test the 'Edit' operation.
     $this->clickLink(t('Edit'));
     $this->assertFieldByName('title[0][value]', $link_title);
     $link_title = $this->randomString();
     $this->drupalPostForm(NULL, array('title[0][value]' => $link_title), t('Save'));
-    $this->assertUrl(Url::fromRoute('entity.menu.edit_form',  ['menu' => $menu_name]));
+    $this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
     // Test the 'Delete' operation.
     $this->clickLink(t('Delete'));
     $this->assertRaw(t('Are you sure you want to delete the custom menu link %item?', array('%item' => $link_title)));
     $this->drupalPostForm(NULL, array(), t('Delete'));
-    $this->assertUrl(Url::fromRoute('entity.menu.edit_form',  ['menu' => $menu_name]));
+    $this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
 
     // Add nodes to use as links for menu links.
     $node1 = $this->drupalCreateNode(array('type' => 'article'));
@@ -901,8 +901,8 @@ class MenuTest extends MenuWebTestBase {
   /**
    * Verifies the logged in user has the desired access to various menu pages.
    *
-   * @param integer $response
-   *   The expected HTTP response code. Defaults to 200.
+   * @param int $response
+   *   (optional) The expected HTTP response code. Defaults to 200.
    */
   private function verifyAccess($response = 200) {
     // View menu help page.
diff --git a/core/modules/migrate/config/schema/migrate.data_types.schema.yml b/core/modules/migrate/config/schema/migrate.data_types.schema.yml
index 60dd5193f..27c8006f4 100644
--- a/core/modules/migrate/config/schema/migrate.data_types.schema.yml
+++ b/core/modules/migrate/config/schema/migrate.data_types.schema.yml
@@ -26,6 +26,10 @@ migrate_source:
       type: ignore
       label: 'Constants'
 
+migrate_process:
+  type: migrate_plugin
+  label: 'Process'
+
 # Base schema for migrate source plugins that extend
 # \Drupal\migrate\Plugin\migrate\source\SqlBase.
 migrate_source_sql:
diff --git a/core/modules/migrate/config/schema/migrate.process.schema.yml b/core/modules/migrate/config/schema/migrate.process.schema.yml
new file mode 100644
index 000000000..249f69d8a
--- /dev/null
+++ b/core/modules/migrate/config/schema/migrate.process.schema.yml
@@ -0,0 +1,134 @@
+# Schema for the migrate process plugins.
+
+migrate.process.*:
+  type: migrate_process
+  label: 'Default process'
+
+migrate.process.callback:
+  type: migrate_process
+  label: 'Callback process'
+  mapping:
+    callback:
+      type: string
+      label: 'Callback'
+
+migrate.process.concat:
+  type: migrate_process
+  label: 'Concat process'
+  mapping:
+    delimiter:
+      type: string
+      label: 'Delimiter'
+
+migrate.process.dedupe_entity:
+  type: migrate_process
+  label: 'Dedupe Entity process'
+  mapping:
+    entity_type:
+      type: string
+      label: 'Entity type'
+    field:
+      type: string
+      label: 'Field name'
+    postfix:
+      type: string
+      label: 'Postfix'
+    start:
+      type: integer
+      label: 'Start'
+    length:
+      type: integer
+      label: 'Length'
+
+migrate.process.extract:
+  type: migrate_process
+  label: 'Extract process'
+  mapping:
+    default:
+      type: string
+      label: 'Default value'
+
+migrate.process.flatten:
+  type: migrate_process
+  label: 'Flatten process'
+
+migrate.process.get:
+  type: migrate_process
+  label: 'Get process'
+  mapping:
+    source:
+      type: string
+      label: 'Source key'
+
+migrate.process.iterator:
+  type: migrate_process
+  label: 'Iterator process'
+  mapping:
+    process:
+      type: ignore
+      label: 'Process'
+    key:
+      type: string
+      label: 'Key'
+
+migrate.process.machine_name:
+  type: migrate_process
+  label: 'Machine name process'
+
+migrate.process.migration:
+  type: migrate_process
+  label: 'Migration process'
+  mapping:
+    migration:
+      type: sequence
+      label: 'Migration'
+    source:
+      type: sequence
+      label: 'Source keys'
+    source_ids:
+      type: string
+      label: 'Source IDs'
+    stub_id:
+      type: string
+      label: 'Stub ID'
+
+migrate.process.route:
+  type: migrate_process
+  label: 'Route process'
+
+migrate.process.skip_on_empty:
+  type: migrate_process
+  label: 'Skip on Empty'
+
+migrate.process.skip_row_if_not_set:
+  type: migrate_process
+  label: 'Skip Row process if not set'
+  mapping:
+    index:
+      type: integer
+      label: 'Index'
+
+migrate.process.static_map:
+  type: migrate_process
+  label: 'Static Map'
+  mapping:
+    map:
+      type: sequence
+      label: 'Map'
+    default_value:
+      type: string
+      label: 'Default value'
+    bypass:
+      type: boolean
+      label: 'Bypass lookup'
+
+migrate.process.default_value:
+  type: migrate_process
+  label: 'Default value'
+  mapping:
+    strict:
+      type: boolean
+      label: 'Strict type check'
+    default_value:
+      type: string
+      label: 'Default value'
diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php
index 094713d1d..9e509f486 100644
--- a/core/modules/migrate/src/Entity/Migration.php
+++ b/core/modules/migrate/src/Entity/Migration.php
@@ -81,7 +81,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
    *
    * @var array
    */
-  protected $process;
+  protected $process = [];
 
   /**
    * The cached process plugins.
@@ -320,10 +320,10 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
    * {@inheritdoc}
    */
   public function getDestinationPlugin($stub_being_requested = FALSE) {
+    if ($stub_being_requested && !empty($this->destination['no_stub'])) {
+      throw new MigrateSkipRowException;
+    }
     if (!isset($this->destinationPlugin)) {
-      if ($stub_being_requested && !empty($this->destination['no_stub'])) {
-        throw new MigrateSkipRowException;
-      }
       $this->destinationPlugin = \Drupal::service('plugin.manager.migrate.destination')->createInstance($this->destination['plugin'], $this->destination, $this);
     }
     return $this->destinationPlugin;
diff --git a/core/modules/migrate/src/MigrateTemplateStorage.php b/core/modules/migrate/src/MigrateTemplateStorage.php
index d08f1aa8b..7124d573b 100644
--- a/core/modules/migrate/src/MigrateTemplateStorage.php
+++ b/core/modules/migrate/src/MigrateTemplateStorage.php
@@ -13,7 +13,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
 /**
  * Storage to access migration template configuration in enabled extensions.
  */
-class MigrateTemplateStorage {
+class MigrateTemplateStorage implements MigrateTemplateStorageInterface {
   /**
    * Extension sub-directory containing default configuration for migrations.
    */
@@ -41,13 +41,7 @@ class MigrateTemplateStorage {
   }
 
   /**
-   * Find all migration templates with the specified tag.
-   *
-   * @param $tag
-   *   The tag to match.
-   *
-   * @return array
-   *   Any templates (parsed YAML config) that matched, keyed by the ID.
+   * {@inheritdoc}
    */
   public function findTemplatesByTag($tag) {
     $templates = $this->getAllTemplates();
@@ -63,13 +57,7 @@ class MigrateTemplateStorage {
   }
 
   /**
-   * Retrieve a template given a specific name.
-   *
-   * @param string $name
-   *   A migration template name.
-   *
-   * @return NULL|array
-   *   A parsed migration template, or NULL if it doesn't exist.
+   * {@inheritdoc}
    */
   public function getTemplateByName($name) {
     $templates = $this->getAllTemplates();
@@ -77,10 +65,7 @@ class MigrateTemplateStorage {
   }
 
   /**
-   * Retrieves all migration templates belonging to enabled extensions.
-   *
-   * @return array
-   *   Array of parsed templates, keyed by the fully-qualified id.
+   * {@inheritdoc}
    */
   public function getAllTemplates() {
     $templates = [];
diff --git a/core/modules/migrate/src/MigrateTemplateStorageInterface.php b/core/modules/migrate/src/MigrateTemplateStorageInterface.php
new file mode 100644
index 000000000..dc9372e0d
--- /dev/null
+++ b/core/modules/migrate/src/MigrateTemplateStorageInterface.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\migrate\MigrateTemplateStorageInterface.
+ */
+
+namespace Drupal\migrate;
+
+/**
+ * The MigrateTemplateStorageInterface interface.
+ */
+interface MigrateTemplateStorageInterface {
+
+  /**
+   * Find all migration templates with the specified tag.
+   *
+   * @param $tag
+   *   The tag to match.
+   *
+   * @return array
+   *   Any templates (parsed YAML config) that matched, keyed by the ID.
+   */
+  public function findTemplatesByTag($tag);
+
+  /**
+   * Retrieve a template given a specific name.
+   *
+   * @param string $name
+   *   A migration template name.
+   *
+   * @return NULL|array
+   *   A parsed migration template, or NULL if it doesn't exist.
+   */
+  public function getTemplateByName($name);
+
+  /**
+   * Retrieves all migration templates belonging to enabled extensions.
+   *
+   * @return array
+   *   Array of parsed templates, keyed by the fully-qualified id.
+   */
+  public function getAllTemplates();
+
+}
diff --git a/core/modules/migrate/src/MigrationBuilder.php b/core/modules/migrate/src/MigrationBuilder.php
index e4c4658e1..bdf3e4e42 100644
--- a/core/modules/migrate/src/MigrationBuilder.php
+++ b/core/modules/migrate/src/MigrationBuilder.php
@@ -13,7 +13,7 @@ use Drupal\migrate\Plugin\MigratePluginManager;
 /**
  * Builds migration entities from migration templates.
  */
-class MigrationBuilder {
+class MigrationBuilder implements MigrationBuilderInterface {
 
   /**
    * The builder plugin manager.
@@ -33,14 +33,7 @@ class MigrationBuilder {
   }
 
   /**
-   * Builds migration entities from templates.
-   *
-   * @param array $templates
-   *   The parsed templates (each of which is an array parsed from YAML), keyed
-   *   by ID.
-   *
-   * @return \Drupal\migrate\Entity\MigrationInterface[]
-   *   The migration entities derived from the templates.
+   * {@inheritdoc}
    */
   public function createMigrations(array $templates) {
     /** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
diff --git a/core/modules/migrate/src/MigrationBuilderInterface.php b/core/modules/migrate/src/MigrationBuilderInterface.php
new file mode 100644
index 000000000..66f3078e5
--- /dev/null
+++ b/core/modules/migrate/src/MigrationBuilderInterface.php
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\migrate\MigrationBuilderInterface.
+ */
+
+namespace Drupal\migrate;
+
+/**
+ * The migration builder interface.
+ */
+interface MigrationBuilderInterface {
+
+  /**
+   * Builds migration entities from templates.
+   *
+   * @param array $templates
+   *   The parsed templates (each of which is an array parsed from YAML), keyed
+   *   by ID.
+   *
+   * @return \Drupal\migrate\Entity\MigrationInterface[]
+   *   The migration entities derived from the templates.
+   */
+  public function createMigrations(array $templates);
+
+}
diff --git a/core/modules/migrate/src/MigrationStorage.php b/core/modules/migrate/src/MigrationStorage.php
index e43496e36..36390e046 100644
--- a/core/modules/migrate/src/MigrationStorage.php
+++ b/core/modules/migrate/src/MigrationStorage.php
@@ -173,13 +173,13 @@ class MigrationStorage extends ConfigEntityStorage implements MigrateBuildDepend
    * Add one or more dependencies to a graph.
    *
    * @param array $graph
-   *   The graph so far.
+   *   The graph so far, passed by reference.
    * @param int $id
-   *   The migration id.
+   *   The migration ID.
    * @param string $dependency
    *   The dependency string.
    * @param array $dynamic_ids
-   *   The dynamic id mapping.
+   *   The dynamic ID mapping.
    */
   protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids) {
     $dependencies = isset($dynamic_ids[$dependency]) ? $dynamic_ids[$dependency] : array($dependency);
diff --git a/core/modules/migrate/src/Plugin/MigrateBuilderInterface.php b/core/modules/migrate/src/Plugin/MigrateBuilderInterface.php
index c615dd441..511af1ba3 100644
--- a/core/modules/migrate/src/Plugin/MigrateBuilderInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrateBuilderInterface.php
@@ -11,8 +11,8 @@ namespace Drupal\migrate\Plugin;
  * Defines the builder plugin type.
  *
  * Builder plugins implement custom logic to generate migration entities from
- * migration templates. For example, a migration may need to be customized
- * based on data that's present in the source database; such customization is
+ * migration templates. For example, a migration may need to be customized based
+ * on data that's present in the source database; such customization is
  * implemented by builders.
  */
 interface MigrateBuilderInterface {
diff --git a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php
index 81348833c..97c684dd5 100644
--- a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php
@@ -12,6 +12,8 @@ use Drupal\migrate\Entity\MigrationInterface;
 use Drupal\migrate\Row;
 
 /**
+ * Defines an interface for Migration Destination classes.
+ *
  * Destinations are responsible for persisting source data into the destination
  * Drupal.
  *
@@ -25,7 +27,7 @@ use Drupal\migrate\Row;
 interface MigrateDestinationInterface extends PluginInspectionInterface {
 
   /**
-   * Get the destination ids.
+   * Get the destination IDs.
    *
    * To support MigrateIdMap maps, derived destination classes should return
    * schema field definition(s) corresponding to the primary key of the
@@ -33,7 +35,7 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
    * key fields of the map table for a migration using this destination.
    *
    * @return array
-   *   An array of ids.
+   *   An array of IDs.
    */
   public function getIds();
 
@@ -43,11 +45,11 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
    * Derived classes must implement fields(), returning a list of available
    * destination fields.
    *
-   * @todo Review the cases where we need the Migration parameter,
-   * can we avoid that?
+   * @todo Review the cases where we need the Migration parameter, can we avoid
+   *   that? To be resolved with https://www.drupal.org/node/2543568.
    *
    * @param \Drupal\migrate\Entity\MigrationInterface $migration
-   *   (optional) the migration containing this destination.
+   *   (optional) The migration containing this destination. Defaults to NULL.
    *
    * @return array
    *   - Keys: machine names of the fields
@@ -64,10 +66,10 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
    * @param \Drupal\migrate\Row $row
    *   The row object.
    * @param array $old_destination_id_values
-   *   The old destination ids.
+   *   (optional) The old destination IDs. Defaults to an empty array.
    *
    * @return mixed
-   *   The entity id or an indication of success.
+   *   The entity ID or an indication of success.
    */
   public function import(Row $row, array $old_destination_id_values = array());
 
@@ -95,4 +97,5 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
    *   item should be handled on rollback.
    */
   public function rollbackAction();
+
 }
diff --git a/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php b/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php
index 96f7be54b..383a7de86 100644
--- a/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php
+++ b/core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php
@@ -5,7 +5,6 @@
  * Contains \Drupal\migrate\Plugin\MigrateDestinationPluginManager.
  */
 
-
 namespace Drupal\migrate\Plugin;
 
 use Drupal\Core\Cache\CacheBackendInterface;
@@ -37,7 +36,7 @@ class MigrateDestinationPluginManager extends MigratePluginManager {
    *
    * @param string $type
    *   The type of the plugin: row, source, process, destination, entity_field,
-   * id_map.
+   *   id_map.
    * @param \Traversable $namespaces
    *   An object that implements \Traversable which contains the root paths
    *   keyed by the corresponding namespace to look for plugin implementations.
@@ -48,7 +47,8 @@ class MigrateDestinationPluginManager extends MigratePluginManager {
    * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    *   The entity manager.
    * @param string $annotation
-   *   The annotation class name.
+   *   (optional) The annotation class name. Defaults to
+   *   'Drupal\migrate\Annotation\MigrateDestination'.
    */
   public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager, $annotation = 'Drupal\migrate\Annotation\MigrateDestination') {
     parent::__construct($type, $namespaces, $cache_backend, $module_handler, $annotation);
diff --git a/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php b/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php
index 36be2ddbb..6a7a9d031 100644
--- a/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php
@@ -37,8 +37,8 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
   /**
    * Saves a mapping from the source identifiers to the destination identifiers.
    *
-   * Called upon import of one row, we record a mapping from the source ID
-   * to the destination ID. Also may be called, setting the third parameter to
+   * Called upon import of one row, we record a mapping from the source ID to
+   * the destination ID. Also may be called, setting the third parameter to
    * NEEDS_UPDATE, to signal an existing record should be re-migrated.
    *
    * @param \Drupal\migrate\Row $row
@@ -47,9 +47,11 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
    * @param array $destination_id_values
    *   An array of destination identifier values.
    * @param int $status
-   *   Status of the source row in the map.
+   *   (optional) Status of the source row in the map. Defaults to
+   *   self::STATUS_IMPORTED.
    * @param int $rollback_action
-   *   How to handle the destination object on rollback.
+   *   (optional) How to handle the destination object on rollback. Defaults to
+   *   self::ROLLBACK_DELETE.
    */
   public function saveIdMapping(Row $row, array $destination_id_values, $status = self::STATUS_IMPORTED, $rollback_action = self::ROLLBACK_DELETE);
 
@@ -61,7 +63,8 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
    * @param string $message
    *   The message to record.
    * @param int $level
-   *   Optional message severity (defaults to MESSAGE_ERROR).
+   *   (optional) The message severity. Defaults to
+   *   MigrationInterface::MESSAGE_ERROR.
    */
   public function saveMessage(array $source_id_values, $message, $level = MigrationInterface::MESSAGE_ERROR);
 
@@ -69,10 +72,11 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
    * Retrieves an iterator over messages relate to source records.
    *
    * @param array $source_id_values
-   *   (optional) The source identifier keyed values of the record, e.g. ['nid' => 5].
-   *   If empty, all messages are retrieved.
+   *   (optional) The source identifier keyed values of the record, e.g.
+   *   ['nid' => 5]. If empty (the default), all messages are retrieved.
    * @param int $level
-   *   (optional) Message severity. If NULL, retrieve messages of all severities.
+   *   (optional) Message severity. If NULL (the default), retrieve messages of
+   *   all severities.
    *
    * @return \Iterator
    *   Retrieves an iterator over the message rows.
@@ -136,7 +140,7 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
    * @param array $source_id_values
    *   The source identifier keyed values of the record, e.g. ['nid' => 5].
    * @param bool $messages_only
-   *   TRUE to only delete the migrate messages.
+   *   (optional) TRUE to only delete the migrate messages. Defaults to FALSE.
    */
   public function delete(array $source_id_values, $messages_only = FALSE);
 
diff --git a/core/modules/migrate/src/Plugin/MigratePluginManager.php b/core/modules/migrate/src/Plugin/MigratePluginManager.php
index 84f227843..6ca1a2472 100644
--- a/core/modules/migrate/src/Plugin/MigratePluginManager.php
+++ b/core/modules/migrate/src/Plugin/MigratePluginManager.php
@@ -34,7 +34,7 @@ class MigratePluginManager extends DefaultPluginManager {
    *
    * @param string $type
    *   The type of the plugin: row, source, process, destination, entity_field,
-   * id_map.
+   *   id_map.
    * @param \Traversable $namespaces
    *   An object that implements \Traversable which contains the root paths
    *   keyed by the corresponding namespace to look for plugin implementations.
@@ -43,7 +43,8 @@ class MigratePluginManager extends DefaultPluginManager {
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    *   The module handler to invoke the alter hook with.
    * @param string $annotation
-   *   The annotation class name.
+   *   (optional) The annotation class name. Defaults to
+   *   'Drupal\Component\Annotation\PluginID'.
    */
   public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, $annotation = 'Drupal\Component\Annotation\PluginID') {
     $plugin_interface = isset($plugin_interface_map[$type]) ? $plugin_interface_map[$type] : NULL;
diff --git a/core/modules/migrate/src/Plugin/MigrateProcessInterface.php b/core/modules/migrate/src/Plugin/MigrateProcessInterface.php
index 6f9d7ae2a..f6f640302 100644
--- a/core/modules/migrate/src/Plugin/MigrateProcessInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrateProcessInterface.php
@@ -37,12 +37,12 @@ interface MigrateProcessInterface extends PluginInspectionInterface {
    * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
    *   The migration in which this process is being executed.
    * @param \Drupal\migrate\Row $row
-   *   The row from the source to process. Normally, just transforming the
-   *   value is adequate but very rarely you might need to change two columns
-   *   at the same time or something like that.
+   *   The row from the source to process. Normally, just transforming the value
+   *   is adequate but very rarely you might need to change two columns at the
+   *   same time or something like that.
    * @param string $destination_property
-   *   The destination property currently worked on. This is only used
-   *   together with the $row above.
+   *   The destination property currently worked on. This is only used together
+   *   with the $row above.
    *
    * @return string|array
    *   The newly transformed value.
diff --git a/core/modules/migrate/src/Plugin/MigrateSourceInterface.php b/core/modules/migrate/src/Plugin/MigrateSourceInterface.php
index 3620e6777..9216f821a 100644
--- a/core/modules/migrate/src/Plugin/MigrateSourceInterface.php
+++ b/core/modules/migrate/src/Plugin/MigrateSourceInterface.php
@@ -31,7 +31,7 @@ interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspection
   public function fields();
 
   /**
-   * Add additional data to the row.
+   * Adds additional data to the row.
    *
    * @param \Drupal\Migrate\Row $row
    *   The row object.
@@ -41,13 +41,17 @@ interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspection
    */
   public function prepareRow(Row $row);
 
+  /**
+   * Allows class to decide how it will react when it is treated like a string.
+   */
   public function __toString();
 
   /**
-   * Defines the source fields uniquely identifying a source row. None of these
-   * fields should contain a NULL value - if necessary, use prepareRow() or
-   * hook_migrate_prepare_row() to rewrite NULL values to appropriate empty
-   * values (such as '' or 0).
+   * Defines the source fields uniquely identifying a source row.
+   *
+   * None of these fields should contain a NULL value. If necessary, use
+   * prepareRow() or hook_migrate_prepare_row() to rewrite NULL values to
+   * appropriate empty values (such as '' or 0).
    *
    * @return array
    *   Array keyed by source field name, with values being a schema array
diff --git a/core/modules/migrate/src/Plugin/migrate/builder/BuilderBase.php b/core/modules/migrate/src/Plugin/migrate/builder/BuilderBase.php
index 92a65beb1..447ebf49d 100644
--- a/core/modules/migrate/src/Plugin/migrate/builder/BuilderBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/builder/BuilderBase.php
@@ -12,7 +12,7 @@ use Drupal\migrate\Entity\Migration;
 use Drupal\migrate\Plugin\MigrateBuilderInterface;
 
 /**
- * Base class for builder plugins.
+ * Provides abstract base class for builder plugins.
  */
 abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface {
 
@@ -22,7 +22,8 @@ abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface
    * @param string $plugin_id
    *   The plugin ID.
    * @param array $configuration
-   *   (optional) Additional configuration for the plugin.
+   *   (optional) Additional configuration for the plugin. Defaults to an empty
+   *   array.
    *
    * @return \Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface
    *   The fully initialized source plugin.
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php b/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php
index f5e512764..dfd17399d 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php
@@ -10,6 +10,9 @@ namespace Drupal\migrate\Plugin\migrate\destination;
 use Drupal\migrate\Entity\MigrationInterface;
 use Drupal\migrate\Row;
 
+/**
+ * Defines the base abstract class for component entity display.
+ */
 abstract class ComponentEntityDisplayBase extends DestinationBase {
 
   const MODE_NAME = '';
@@ -54,7 +57,7 @@ abstract class ComponentEntityDisplayBase extends DestinationBase {
   }
 
   /**
-   * Get the entity.
+   * Gets the entity.
    *
    * @param string $entity_type
    *   The entity type to retrieve.
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Config.php b/core/modules/migrate/src/Plugin/migrate/destination/Config.php
index 748f1a8d2..0dd9fd377 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/Config.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/Config.php
@@ -3,8 +3,6 @@
 /**
  * @file
  * Contains \Drupal\migrate\Plugin\migrate\destination\Config.
- *
- * Provides Configuration Management destination plugin.
  */
 
 namespace Drupal\migrate\Plugin\migrate\destination;
@@ -18,6 +16,8 @@ use Drupal\migrate\Row;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
+ * Provides Configuration Management destination plugin.
+ *
  * Persist data to the config system.
  *
  * When a property is NULL, the default is used unless the configuration option
@@ -28,6 +28,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
  * )
  */
 class Config extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface {
+
   use DependencyTrait;
 
   /**
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/DestinationBase.php b/core/modules/migrate/src/Plugin/migrate/destination/DestinationBase.php
index 93f3b8366..0a38ba85e 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/DestinationBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/DestinationBase.php
@@ -5,7 +5,6 @@
  * Contains \Drupal\migrate\Plugin\migrate\destination\DestinationBase.
  */
 
-
 namespace Drupal\migrate\Plugin\migrate\destination;
 
 use Drupal\Core\Plugin\PluginBase;
@@ -113,4 +112,5 @@ abstract class DestinationBase extends PluginBase implements MigrateDestinationI
       $this->rollbackAction = MigrateIdMapInterface::ROLLBACK_PRESERVE;
     }
   }
+
 }
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
index f7a6a1e93..c8cca6506 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
@@ -16,12 +16,15 @@ use Drupal\migrate\Row;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
+ * Provides entity destination plugin.
+ *
  * @MigrateDestination(
  *   id = "entity",
  *   deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntity"
  * )
  */
 abstract class Entity extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface {
+
   use DependencyTrait;
 
   /**
@@ -77,16 +80,16 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
   }
 
   /**
-   * Finds the entity type from configuration or plugin id.
+   * Finds the entity type from configuration or plugin ID.
    *
    * @param string $plugin_id
-   *   The plugin id.
+   *   The plugin ID.
    *
    * @return string
    *   The entity type.
    */
   protected static function getEntityTypeId($plugin_id) {
-    // Remove "entity:"
+    // Remove "entity:".
     return substr($plugin_id, 7);
   }
 
@@ -103,10 +106,10 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
    * @param \Drupal\migrate\Row $row
    *   The row object.
    * @param array $old_destination_id_values
-   *   The old destination ids.
+   *   The old destination IDs.
    *
    * @return \Drupal\Core\Entity\EntityInterface
-   *   The entity we're importing into.
+   *   The entity we are importing into.
    */
   protected function getEntity(Row $row, array $old_destination_id_values) {
     $entity_id = $old_destination_id_values ? reset($old_destination_id_values) : $this->getEntityId($row);
@@ -125,12 +128,13 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
   }
 
   /**
-   * Get the entity id of the row.
+   * Gets the entity ID of the row.
    *
    * @param \Drupal\migrate\Row $row
    *   The row of data.
+   *
    * @return string
-   *   The entity id for the row we're importing.
+   *   The entity ID for the row that we are importing.
    */
   protected function getEntityId(Row $row) {
     return $row->getDestinationProperty($this->getKey('id'));
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php
index 2e2de4ba4..2501b5367 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityBaseFieldOverride.php
@@ -10,6 +10,8 @@ namespace Drupal\migrate\Plugin\migrate\destination;
 use Drupal\migrate\Row;
 
 /**
+ * Provides entity base field override plugin.
+ *
  * @MigrateDestination(
  *   id = "entity:base_field_override"
  * )
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
index 5e5fbd54f..382f32a7f 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
@@ -18,7 +18,7 @@ use Drupal\migrate\Row;
  *
  * This class serves as the import class for most configuration entities.
  * It can be necessary to provide a specific entity class if the configuration
- * entity has a compound id (see EntityFieldEntity) or it has specific setter
+ * entity has a compound ID (see EntityFieldEntity) or it has specific setter
  * methods (see EntityDateFormat). When implementing an entity destination for
  * the latter case, make sure to add a test not only for importing but also
  * for re-importing (if that is supported).
@@ -39,14 +39,14 @@ class EntityConfigBase extends Entity {
       // Ids is keyed by the key name so grab the keys.
       $id_keys = array_keys($ids);
       if (!$row->getDestinationProperty($id_key)) {
-        // Set the id into the destination in for form "val1.val2.val3".
+        // Set the ID into the destination in for form "val1.val2.val3".
         $row->setDestinationProperty($id_key, $this->generateId($row, $id_keys));
       }
     }
     $entity = $this->getEntity($row, $old_destination_id_values);
     $entity->save();
     if (count($ids) > 1) {
-      // This can only be a config entity, content entities have their id key
+      // This can only be a config entity, content entities have their ID key
       // and that's it.
       $return = array();
       foreach ($id_keys as $id_key) {
@@ -105,15 +105,15 @@ class EntityConfigBase extends Entity {
   }
 
   /**
-   * Generate an entity id.
+   * Generates an entity ID.
    *
    * @param \Drupal\migrate\Row $row
    *   The current row.
    * @param array $ids
-   *   The destination ids.
+   *   The destination IDs.
    *
    * @return string
-   *   The generated entity id.
+   *   The generated entity ID.
    */
   protected function generateId(Row $row, array $ids) {
     $id_values = array();
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
index e2320cd75..f23b54fee 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
@@ -7,15 +7,12 @@
 
 namespace Drupal\migrate\Plugin\migrate\destination;
 
-use Drupal\Component\Utility\Random;
-use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Field\FieldTypePluginManagerInterface;
 use Drupal\Core\TypedData\TypedDataInterface;
-use Drupal\link\LinkItemInterface;
 use Drupal\migrate\Entity\MigrationInterface;
 use Drupal\migrate\MigrateException;
 use Drupal\migrate\Plugin\MigrateIdMapInterface;
@@ -97,15 +94,15 @@ class EntityContentBase extends Entity {
   }
 
   /**
-   * Save the entity.
+   * Saves the entity.
    *
    * @param \Drupal\Core\Entity\ContentEntityInterface $entity
    *   The content entity.
    * @param array $old_destination_id_values
-   *   An array of destination id values.
+   *   (optional) An array of destination ID values. Defaults to an empty array.
    *
    * @return array
-   *   An array containing the entity id.
+   *   An array containing the entity ID.
    */
   protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
     $entity->save();
@@ -122,7 +119,7 @@ class EntityContentBase extends Entity {
   }
 
   /**
-   * Update an entity with the new values from row.
+   * Updates an entity with the new values from row.
    *
    * @param \Drupal\Core\Entity\EntityInterface $entity
    *   The entity to update.
@@ -152,7 +149,7 @@ class EntityContentBase extends Entity {
   }
 
   /**
-   * Do as much population of the stub row as we can.
+   * Populates as much of the stub row as possible.
    *
    * @param \Drupal\migrate\Row $row
    *   The row of data.
@@ -185,7 +182,6 @@ class EntityContentBase extends Entity {
           if (is_null($values)) {
             // Handle failure to generate a sample value.
             throw new MigrateException('Stubbing failed, unable to generate value for field ' . $field_name);
-            break;
           }
         }
 
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php
index c6cd7e467..5d2f90288 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php
@@ -8,6 +8,8 @@
 namespace Drupal\migrate\Plugin\migrate\destination;
 
 /**
+ * Provides entity field instance plugin.
+ *
  * @MigrateDestination(
  *   id = "entity:field_config"
  * )
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
index 31f7a13bc..9b374c67f 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
@@ -8,6 +8,8 @@
 namespace Drupal\migrate\Plugin\migrate\destination;
 
 /**
+ * Provides entity field storage configuration plugin.
+ *
  * @MigrateDestination(
  *   id = "entity:field_storage_config"
  * )
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
index 81498c39b..24602b6d6 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
@@ -12,6 +12,8 @@ use Drupal\migrate\MigrateException;
 use Drupal\migrate\Row;
 
 /**
+ * Provides entity revision destination plugin.
+ *
  * @MigrateDestination(
  *   id = "entity_revision",
  *   deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntityRevision"
@@ -28,12 +30,12 @@ class EntityRevision extends EntityContentBase {
   }
 
   /**
-   * Get the entity.
+   * Gets the entity.
    *
    * @param \Drupal\migrate\Row $row
    *   The row object.
    * @param array $old_destination_id_values
-   *   The old destination ids.
+   *   The old destination IDs.
    *
    * @return \Drupal\Core\Entity\EntityInterface|false
    *   The entity or false if it can not be created.
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
index 87fe20483..61bb0ebe1 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
@@ -8,6 +8,8 @@
 namespace Drupal\migrate\Plugin\migrate\destination;
 
 /**
+ * Provides entity view mode destination plugin.
+ *
  * @MigrateDestination(
  *   id = "entity:entity_view_mode"
  * )
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php b/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php
index 1bffa9ea4..f35c5d418 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/NullDestination.php
@@ -11,6 +11,8 @@ use Drupal\migrate\Entity\MigrationInterface;
 use Drupal\migrate\Row;
 
 /**
+ * Provides null destination plugin.
+ *
  * @MigrateDestination(
  *   id = "null",
  *   requirements_met = false
diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
index 7f9746406..9005ef210 100644
--- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -69,6 +69,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
   protected $database;
 
   /**
+   * The select query.
+   *
    * @var \Drupal\Core\Database\Query\SelectInterface
    */
   protected $query;
@@ -300,7 +302,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
       $fields = $source_id_schema;
 
       // Add destination identifiers to map table.
-      // TODO: How do we discover the destination schema?
+      // @todo How do we discover the destination schema?
       $count = 1;
       foreach ($this->migration->getDestinationPlugin()->getIds() as $id_definition) {
         // Allow dest identifier fields to be NULL (for IGNORED/FAILED
@@ -383,35 +385,40 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
       // Add any missing columns to the map table.
       if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName,
                                                     'rollback_action')) {
-        $this->getDatabase()->schema()->addField($this->mapTableName,
-                                              'rollback_action', array(
-          'type' => 'int',
-          'size' => 'tiny',
-          'unsigned' => TRUE,
-          'not null' => TRUE,
-          'default' => 0,
-          'description' => 'Flag indicating what to do for this item on rollback',
-        ));
+        $this->getDatabase()->schema()->addField($this->mapTableName, 'rollback_action',
+          array(
+            'type' => 'int',
+            'size' => 'tiny',
+            'unsigned' => TRUE,
+            'not null' => TRUE,
+            'default' => 0,
+            'description' => 'Flag indicating what to do for this item on rollback',
+          )
+        );
       }
       if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName, 'hash')) {
-        $this->getDatabase()->schema()->addField($this->mapTableName, 'hash', array(
-          'type' => 'varchar',
-          'length' => '64',
-          'not null' => FALSE,
-          'description' => 'Hash of source row data, for detecting changes',
-        ));
+        $this->getDatabase()->schema()->addField($this->mapTableName, 'hash',
+          array(
+            'type' => 'varchar',
+            'length' => '64',
+            'not null' => FALSE,
+            'description' => 'Hash of source row data, for detecting changes',
+          )
+        );
       }
     }
   }
 
   /**
-   * Create schema from an id definition.
+   * Creates schema from an ID definition.
    *
    * @param array $id_definition
    *   A field schema definition. Can be SQL schema or a type data
    *   based schema. In the latter case, the value of type needs to be
-   *   $typed_data_type.$column
+   *   $typed_data_type.$column.
+   *
    * @return array
+   *   The schema definition.
    */
   protected function getFieldSchema(array $id_definition) {
     $type_parts = explode('.', $id_definition['type']);
@@ -593,8 +600,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
    */
   public function prepareUpdate() {
     $this->getDatabase()->update($this->mapTableName())
-    ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
-    ->execute();
+      ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
+      ->execute();
   }
 
   /**
@@ -642,10 +649,11 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
   /**
    * Counts records in a table.
    *
-   * @param $status
+   * @param int $status
    *   An integer for the source_row_status column.
-   * @param $table
-   *   The table to work
+   * @param string $table
+   *   (optional) The table to work. Defaults to NULL.
+   *
    * @return int
    *   The number of records.
    */
@@ -779,7 +787,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
   }
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   public function currentDestination() {
     if ($this->valid()) {
diff --git a/core/modules/migrate/src/Plugin/migrate/process/DedupeEntity.php b/core/modules/migrate/src/Plugin/migrate/process/DedupeEntity.php
index 58bcdf879..175e9c933 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/DedupeEntity.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/DedupeEntity.php
@@ -22,6 +22,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 class DedupeEntity extends DedupeBase implements ContainerFactoryPluginInterface {
 
   /**
+   * The entity query factory.
+   *
    * @var \Drupal\Core\Entity\Query\QueryFactoryInterface
    */
   protected $entityQueryFactory;
diff --git a/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php b/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php
index 17258189e..87f2b6f88 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php
@@ -11,7 +11,6 @@ use Drupal\migrate\ProcessPluginBase;
 use Drupal\migrate\MigrateExecutableInterface;
 use Drupal\migrate\Row;
 
-
 /**
  * This plugin sets missing values on the destination.
  *
@@ -30,4 +29,5 @@ class DefaultValue extends ProcessPluginBase {
     }
     return $value ?: $this->configuration['default_value'];
   }
+
 }
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Flatten.php b/core/modules/migrate/src/Plugin/migrate/process/Flatten.php
index 52781a06f..56b042a00 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Flatten.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Flatten.php
@@ -34,4 +34,5 @@ class Flatten extends ProcessPluginBase {
   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
     return iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($value)), FALSE);
   }
+
 }
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Get.php b/core/modules/migrate/src/Plugin/migrate/process/Get.php
index 07e4b04bb..5b720bc25 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Get.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Get.php
@@ -21,6 +21,8 @@ use Drupal\migrate\Row;
 class Get extends ProcessPluginBase {
 
   /**
+   * Flag indicating whether there are multiple values.
+   *
    * @var bool
    */
   protected $multiple;
@@ -69,4 +71,5 @@ class Get extends ProcessPluginBase {
   public function multiple() {
     return $this->multiple;
   }
+
 }
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php
index 7706a5e92..906513cd9 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php
@@ -65,4 +65,5 @@ class Iterator extends ProcessPluginBase {
   public function multiple() {
     return TRUE;
   }
+
 }
diff --git a/core/modules/migrate/src/Plugin/migrate/process/MachineName.php b/core/modules/migrate/src/Plugin/migrate/process/MachineName.php
index e3963e562..8f08dd6fe 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/MachineName.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/MachineName.php
@@ -29,6 +29,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 class MachineName extends ProcessPluginBase implements ContainerFactoryPluginInterface {
 
   /**
+   * The transliteration service.
+   *
    * @var \Drupal\Component\Transliteration\TransliterationInterface
    */
   protected $transliteration;
@@ -37,13 +39,13 @@ class MachineName extends ProcessPluginBase implements ContainerFactoryPluginInt
    * Constructs a MachineName plugin.
    *
    * @param array $configuration
-   *  The plugin configuration.
+   *   The plugin configuration.
    * @param string $plugin_id
-   *  The plugin ID.
+   *   The plugin ID.
    * @param mixed $plugin_definition
-   *  The plugin definition.
+   *   The plugin definition.
    * @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
-   *  The transliteration service.
+   *   The transliteration service.
    */
   public function __construct(array $configuration, $plugin_id, $plugin_definition, TransliterationInterface $transliteration) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
diff --git a/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php b/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php
new file mode 100644
index 000000000..78fbd14a5
--- /dev/null
+++ b/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php
@@ -0,0 +1,109 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\migrate\Plugin\migrate\process\MenuLinkContent.
+ */
+
+
+namespace Drupal\migrate\Plugin\migrate\process;
+
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Menu\MenuLinkManagerInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Url;
+use Drupal\migrate\Entity\MigrationInterface;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\MigrateSkipRowException;
+use Drupal\migrate\Plugin\MigrateProcessInterface;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * This plugin figures out menu link parent plugin IDs.
+ *
+ * @MigrateProcessPlugin(
+ *   id = "menu_link_parent"
+ * )
+ */
+class MenuLinkParent extends ProcessPluginBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * @var \Drupal\Core\Menu\MenuLinkManagerInterface
+   */
+  protected $menuLinkManager;
+
+  /**
+   * @var \Drupal\migrate\Plugin\MigrateProcessInterface
+   */
+  protected $migrationPlugin;
+
+  /**
+   * @var \Drupal\Core\Entity\EntityStorageInterface
+   */
+  protected $menuLinkStorage;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateProcessInterface $migration_plugin, MenuLinkManagerInterface $menu_link_manager, EntityStorageInterface $menu_link_storage) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->migrationPlugin = $migration_plugin;
+    $this->menuLinkManager = $menu_link_manager;
+    $this->menuLinkStorage = $menu_link_storage;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
+    $migration_configuration['migration'][] = $migration->id();
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration),
+      $container->get('plugin.manager.menu.link'),
+      $container->get('entity.manager')->getStorage('menu_link_content')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * Find the parent link GUID.
+   */
+  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+    $parent_id = array_shift($value);
+    if (!$parent_id) {
+      // Top level item.
+      return '';
+    }
+    try {
+      $already_migrated_id = $this
+        ->migrationPlugin
+        ->transform($parent_id, $migrate_executable, $row, $destination_property);
+      if ($already_migrated_id && ($link = $this->menuLinkStorage->load($already_migrated_id))) {
+        return $link->getPluginId();
+      }
+    }
+    catch (MigrateSkipRowException $e) {
+
+    }
+    if (isset($value[1])) {
+      list($menu_name, $parent_link_path) = $value;
+      $url = Url::fromUserInput("/$parent_link_path");
+      if ($url->isRouted()) {
+        $links = $this->menuLinkManager->loadLinksByRoute($url->getRouteName(), $url->getRouteParameters(), $menu_name);
+        if (count($links) == 1) {
+          /** @var \Drupal\Core\Menu\MenuLinkInterface $link */
+          $link = reset($links);
+          return $link->getPluginId();
+        }
+      }
+    }
+    throw new MigrateSkipRowException;
+  }
+
+}
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Migration.php b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
index a60e773ab..5fc8b4248 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Migration.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Migration.php
@@ -5,7 +5,6 @@
  * Contains \Drupal\migrate\Plugin\migrate\process\Migration.
  */
 
-
 namespace Drupal\migrate\Plugin\migrate\process;
 
 use Drupal\Core\Entity\EntityStorageInterface;
@@ -28,11 +27,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 class Migration extends ProcessPluginBase implements ContainerFactoryPluginInterface {
 
   /**
+   * The process plugin manager.
+   *
    * @var \Drupal\migrate\Plugin\MigratePluginManager
    */
   protected $processPluginManager;
 
   /**
+   * The entity storage manager.
+   *
    * @var \Drupal\Core\Entity\EntityStorageInterface
    */
   protected $migrationStorage;
@@ -115,7 +118,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
       // Only keep the process necessary to produce the destination ID.
       $process = $migration->get('process');
 
-      // We already have the source id values but need to key them for the Row
+      // We already have the source ID values but need to key them for the Row
       // constructor.
       $source_ids = $migration->getSourcePlugin()->getIds();
       $values = array();
@@ -148,7 +151,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
   }
 
   /**
-   * Skip the migration process entirely if the value is FALSE.
+   * Skips the migration process entirely if the value is FALSE.
    *
    * @param mixed $value
    *   The incoming value to transform.
diff --git a/core/modules/migrate/src/Plugin/migrate/process/Route.php b/core/modules/migrate/src/Plugin/migrate/process/Route.php
index 7b83f21fb..6fd6722e7 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/Route.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/Route.php
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * @file
  * Contains \Drupal\migrate\Plugin\migrate\process\Route.
@@ -22,6 +23,8 @@ use Drupal\migrate\Row;
 class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface {
 
   /**
+   * The path validator service.
+   *
    * @var \Drupal\Core\Path\PathValidatorInterface
    */
   protected $pathValidator;
@@ -29,10 +32,10 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
   /**
    * {@inheritdoc}
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, PathValidatorInterface $pathValidator) {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, PathValidatorInterface $path_validator) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->migration = $migration;
-    $this->pathValidator = $pathValidator;
+    $this->pathValidator = $path_validator;
   }
 
   /**
@@ -60,7 +63,7 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
 
     if ($extracted) {
       if ($extracted->isExternal()) {
-        $route['route_name'] = null;
+        $route['route_name'] = NULL;
         $route['route_parameters'] = array();
         $route['options'] = $options;
         $route['url'] = $extracted->getUri();
@@ -83,7 +86,7 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
           unset($route['options']['query']);
         }
         $route['options'] = $route['options'] + $options;
-        $route['url'] = null;
+        $route['url'] = NULL;
       }
     }
 
@@ -91,4 +94,3 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
   }
 
 }
-
diff --git a/core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php b/core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php
index 91daf2979..523c48e71 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php
@@ -8,10 +8,12 @@
 namespace Drupal\migrate\Plugin\migrate\source;
 
 /**
+ * Provides a dummy select query object for source plugins.
+ *
  * Trait providing a dummy select query object for source plugins based on
  * SqlBase which override initializeIterator() to obtain their data from other
  * SqlBase services instead of a direct query. This ensures that query() returns
- * a valid object, even though it isn't used for iteration.
+ * a valid object, even though it is not used for iteration.
  */
 trait DummyQueryTrait {
 
@@ -19,7 +21,8 @@ trait DummyQueryTrait {
    * {@inheritdoc}
    */
   public function query() {
-    // Pass an arbritrary table name - the query should never be executed anyway.
+    // Pass an arbritrary table name - the query should never be executed
+    // anyway.
     $query = $this->select(uniqid(), 's')
       ->range(0, 1);
     $query->addExpression('1');
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
index 0a93cb32b..93cf7265d 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
@@ -34,6 +34,9 @@ class EmptySource extends SourcePluginBase {
     return new \ArrayIterator(array(array('id' => '')));
   }
 
+  /**
+   * Allows class to decide how it will react when it is treated like a string.
+   */
   public function __toString() {
     return '';
   }
diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
index a222eee32..fc63bb850 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
@@ -28,11 +28,15 @@ use Drupal\migrate\Row;
 abstract class SourcePluginBase extends PluginBase implements MigrateSourceInterface {
 
   /**
+   * The module handler service.
+   *
    * @var \Drupal\Core\Extension\ModuleHandlerInterface
    */
   protected $moduleHandler;
 
   /**
+   * The entity migration object.
+   *
    * @var \Drupal\migrate\Entity\MigrationInterface
    */
   protected $migration;
@@ -47,14 +51,14 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   protected $highWaterProperty;
 
   /**
-   * The current row from the query
+   * The current row from the query.
    *
    * @var \Drupal\Migrate\Row
    */
   protected $currentRow;
 
   /**
-   * The primary key of the current row
+   * The primary key of the current row.
    *
    * @var array
    */
@@ -92,6 +96,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   protected $skipCount = FALSE;
 
   /**
+   * Flags whether to track changes to incloming data.
+   *
    * If TRUE, we will maintain hashed source rows to determine whether incoming
    * data has changed.
    *
@@ -100,6 +106,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   protected $trackChanges = FALSE;
 
   /**
+   * Flags whether source plugin will read the map row and add to data row.
+   *
    * By default, next() will directly read the map row and add it to the data
    * row. A source plugin implementation may do this itself (in particular, the
    * SQL source can incorporate the map table into the query) - if so, it should
@@ -110,16 +118,22 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   protected $mapRowAdded = FALSE;
 
   /**
+   * The backend cache.
+   *
    * @var \Drupal\Core\Cache\CacheBackendInterface
    */
   protected $cache;
 
   /**
+   * The migration ID map.
+   *
    * @var \Drupal\migrate\Plugin\MigrateIdMapInterface
    */
   protected $idMap;
 
   /**
+   * The iterator to iterate over the source rows.
+   *
    * @var \Iterator
    */
   protected $iterator;
@@ -150,7 +164,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   }
 
   /**
-   * Initialize the iterator with the source data.
+   * Initializes the iterator with the source data.
    *
    * @return array
    *   An array of the data for this source.
@@ -158,7 +172,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   protected abstract function initializeIterator();
 
   /**
-   * Get the module handler.
+   * Gets the module handler.
    *
    * @return \Drupal\Core\Extension\ModuleHandlerInterface
    *   The module handler.
@@ -212,6 +226,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
    * Returns the iterator that will yield the row arrays to be processed.
    *
    * @return \Iterator
+   *   The iterator that will yield the row arrays to be processed.
    */
   protected function getIterator() {
     if (!isset($this->iterator)) {
@@ -228,7 +243,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   }
 
   /**
-   * Get the iterator key.
+   * Gets the iterator key.
    *
    * Implementation of Iterator::key - called when entering a loop iteration,
    * returning the key of the current row. It must be a scalar - we will
@@ -240,17 +255,17 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   }
 
   /**
-   * Whether the iterator is currently valid.
+   * Checks whether the iterator is currently valid.
    *
    * Implementation of Iterator::valid() - called at the top of the loop,
-   * returning TRUE to process the loop and FALSE to terminate it
+   * returning TRUE to process the loop and FALSE to terminate it.
    */
   public function valid() {
     return isset($this->currentRow);
   }
 
   /**
-   * Rewind the iterator.
+   * Rewinds the iterator.
    *
    * Implementation of Iterator::rewind() - subclasses of MigrateSource should
    * implement performRewind() to do any class-specific setup for iterating
@@ -311,14 +326,14 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
       // 2. Explicitly set to update.
       // 3. The row is newer than the current highwater mark.
       // 4. If no such property exists then try by checking the hash of the row.
-      if (!$row->getIdMap() || $row->needsUpdate() || $this->aboveHighwater($row) || $this->rowChanged($row) ) {
+      if (!$row->getIdMap() || $row->needsUpdate() || $this->aboveHighwater($row) || $this->rowChanged($row)) {
         $this->currentRow = $row->freezeSource();
       }
     }
   }
 
   /**
-   * Check if the incoming data is newer than what we've previously imported.
+   * Checks if the incoming data is newer than what we've previously imported.
    *
    * @param \Drupal\migrate\Row $row
    *   The row we're importing.
@@ -331,7 +346,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   }
 
   /**
-   * Check if the incoming row has changed since our last import.
+   * Checks if the incoming row has changed since our last import.
    *
    * @param \Drupal\migrate\Row $row
    *   The row we're importing.
@@ -344,20 +359,20 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   }
 
   /**
-   * Getter for currentSourceIds data member.
+   * Gets the currentSourceIds data member.
    */
   public function getCurrentIds() {
     return $this->currentSourceIds;
   }
 
   /**
-   * Get the source count.
+   * Gets the source count.
    *
    * Return a count of available source records, from the cache if appropriate.
    * Returns -1 if the source is not countable.
    *
    * @param bool $refresh
-   *   Whether or not to refresh the count.
+   *   (optional) Whether or not to refresh the count. Defaults to FALSE.
    *
    * @return int
    *   The count.
@@ -395,7 +410,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
   }
 
   /**
-   * Get the cache object.
+   * Gets the cache object.
    *
    * @return \Drupal\Core\Cache\CacheBackendInterface
    *   The cache object.
diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
index 343e7232f..b29e73630 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -27,11 +27,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPluginInterface {
 
   /**
+   * The query string.
+   *
    * @var \Drupal\Core\Database\Query\SelectInterface
    */
   protected $query;
 
   /**
+   * The database object.
+   *
    * @var \Drupal\Core\Database\Connection
    */
   protected $database;
@@ -65,7 +69,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
   }
 
   /**
-   * Print the query string when the object is used a string.
+   * Prints the query string when the object is used as a string.
    *
    * @return string
    *   The query string.
@@ -75,7 +79,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
   }
 
   /**
-   * Get the database connection object.
+   * Gets the database connection object.
    *
    * @return \Drupal\Core\Database\Connection
    *   The database connection.
@@ -95,8 +99,9 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
   }
 
   /**
-   * Get a connection to the referenced database, adding the connection if
-   * necessary.
+   * Gets a connection to the referenced database.
+   *
+   * This method will add the database connection if necessary.
    *
    * @param array $database_info
    *   Configuration for the source database connection. The keys are:
@@ -136,7 +141,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
   }
 
   /**
-   * A helper for adding tags and metadata to the query.
+   * Adds tags and metadata to the query.
    *
    * @return \Drupal\Core\Database\Query\SelectInterface
    *   The query with additional tags and metadata.
@@ -164,8 +169,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
     $keys = array();
 
     // The rules for determining what conditions to add to the query are as
-    // follows (applying first applicable rule)
-
+    // follows (applying first applicable rule):
     // 1. If the map is joinable, join it. We will want to accept all rows
     //    which are either not in the map, or marked in the map as NEEDS_UPDATE.
     //    Note that if high water fields are in play, we want to accept all rows
@@ -241,7 +245,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
   }
 
   /**
-   * Check if we can join against the map table.
+   * Checks if we can join against the map table.
    *
    * This function specifically catches issues when we're migrating with
    * unique sets of credentials for the source and destination database.
diff --git a/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php b/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php
index 94b8a3de8..3f2265772 100644
--- a/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php
+++ b/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php
@@ -10,15 +10,14 @@ namespace Drupal\migrate\Tests;
 use Drupal\simpletest\TestBase;
 
 /**
- * Allows tests to alter dumps after they've loaded.
+ * Allows tests to alter dumps after they have loaded.
  *
- * @s
  * @see \Drupal\migrate_drupal\Tests\d6\MigrateFileTest
  */
 interface MigrateDumpAlterInterface {
 
   /**
-   * Allows tests to alter dumps after they've loaded.
+   * Allows tests to alter dumps after they have loaded.
    *
    * @param \Drupal\simpletest\TestBase $test
    *   The test that is being run.
diff --git a/core/modules/migrate/src/Tests/MigrateEventsTest.php b/core/modules/migrate/src/Tests/MigrateEventsTest.php
index ccc82acd3..6bafdafef 100644
--- a/core/modules/migrate/src/Tests/MigrateEventsTest.php
+++ b/core/modules/migrate/src/Tests/MigrateEventsTest.php
@@ -43,7 +43,7 @@ class MigrateEventsTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->state = \Drupal::state();
     \Drupal::service('event_dispatcher')->addListener(MigrateEvents::MAP_SAVE,
@@ -85,7 +85,7 @@ class MigrateEventsTest extends KernelTestBase {
     $migration = Migration::create($config);
 
     /** @var MigrationInterface $migration */
-    $executable = new MigrateExecutable($migration, new MigrateMessage);
+    $executable = new MigrateExecutable($migration, new MigrateMessage());
     // As the import runs, events will be dispatched, recording the received
     // information in state.
     $executable->import();
diff --git a/core/modules/migrate/src/Tests/MigrateInterruptionTest.php b/core/modules/migrate/src/Tests/MigrateInterruptionTest.php
index 3ffd22b81..70eae499d 100644
--- a/core/modules/migrate/src/Tests/MigrateInterruptionTest.php
+++ b/core/modules/migrate/src/Tests/MigrateInterruptionTest.php
@@ -32,7 +32,7 @@ class MigrateInterruptionTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     \Drupal::service('event_dispatcher')->addListener(MigrateEvents::POST_ROW_SAVE,
       array($this, 'postRowSaveEventRecorder'));
@@ -64,8 +64,9 @@ class MigrateInterruptionTest extends KernelTestBase {
     $migration = Migration::create($config);
 
     /** @var MigrationInterface $migration */
-    $executable = new MigrateExecutable($migration, new MigrateMessage);
-    // When the import runs, the first row imported will trigger an interruption.
+    $executable = new MigrateExecutable($migration, new MigrateMessage());
+    // When the import runs, the first row imported will trigger an
+    // interruption.
     $result = $executable->import();
 
     $this->assertEqual($result, MigrationInterface::RESULT_INCOMPLETE);
diff --git a/core/modules/migrate/src/Tests/MigrateMessageTest.php b/core/modules/migrate/src/Tests/MigrateMessageTest.php
index 729ca701f..e3a0aeb4c 100644
--- a/core/modules/migrate/src/Tests/MigrateMessageTest.php
+++ b/core/modules/migrate/src/Tests/MigrateMessageTest.php
@@ -16,7 +16,7 @@ use Drupal\migrate\MigrateMessageInterface;
 use Drupal\simpletest\KernelTestBase;
 
 /**
- * Test whether idmap messages are sent to the message interface when requested.
+ * Tests whether idmap messages are sent to message interface when requested.
  *
  * @group migrate
  */
@@ -46,12 +46,12 @@ class MigrateMessageTest extends KernelTestBase implements MigrateMessageInterfa
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->installConfig(['system']);
 
-    // A simple migration, which will generate a message to the id map because
+    // A simple migration, which will generate a message to the ID map because
     // the concat plugin throws an exception if its source is not an array.
     $config = [
       'id' => 'sample_data',
diff --git a/core/modules/migrate/src/Tests/MigrateRollbackTest.php b/core/modules/migrate/src/Tests/MigrateRollbackTest.php
index ec03bb1ae..9d6055c84 100644
--- a/core/modules/migrate/src/Tests/MigrateRollbackTest.php
+++ b/core/modules/migrate/src/Tests/MigrateRollbackTest.php
@@ -81,8 +81,8 @@ class MigrateRollbackTest extends MigrateTestBase {
       $this->assertNotNull($map_row['destid1']);
     }
 
-    // We use taxonomy terms to demonstrate importing and rolling back
-    // content entities.
+    // We use taxonomy terms to demonstrate importing and rolling back content
+    // entities.
     $term_data_rows = [
       ['id' => '1', 'vocab' => '1', 'name' => 'music'],
       ['id' => '2', 'vocab' => '2', 'name' => 'Bach'],
diff --git a/core/modules/migrate/src/Tests/MigrateSkipRowTest.php b/core/modules/migrate/src/Tests/MigrateSkipRowTest.php
index d27a9aedb..93c1a7c14 100644
--- a/core/modules/migrate/src/Tests/MigrateSkipRowTest.php
+++ b/core/modules/migrate/src/Tests/MigrateSkipRowTest.php
@@ -41,7 +41,7 @@ class MigrateSkipRowTest extends KernelTestBase {
         'plugin' => 'embedded_data',
         'data_rows' => [
           ['id' => '1', 'data' => 'skip_and_record'],
-          ['id' => '2', 'data' => 'skip_and_dont_record']
+          ['id' => '2', 'data' => 'skip_and_dont_record'],
         ],
         'ids' => [
           'id' => ['type' => 'string'],
@@ -57,7 +57,7 @@ class MigrateSkipRowTest extends KernelTestBase {
 
     $migration = Migration::create($config);
 
-    $executable = new MigrateExecutable($migration, new MigrateMessage);
+    $executable = new MigrateExecutable($migration, new MigrateMessage());
     $result = $executable->import();
     $this->assertEqual($result, MigrationInterface::RESULT_COMPLETED);
 
diff --git a/core/modules/migrate/src/Tests/MigrateStatusTest.php b/core/modules/migrate/src/Tests/MigrateStatusTest.php
index 17b12e794..bdfcf7446 100644
--- a/core/modules/migrate/src/Tests/MigrateStatusTest.php
+++ b/core/modules/migrate/src/Tests/MigrateStatusTest.php
@@ -11,14 +11,14 @@ use Drupal\migrate\Entity\Migration;
 use Drupal\migrate\Entity\MigrationInterface;
 
 /**
- * Test migration status tracking.
+ * Tests migration status tracking.
  *
  * @group migrate
  */
 class MigrateStatusTest extends MigrateTestBase {
 
   /**
-   * Test different connection types.
+   * Tests different connection types.
    */
   public function testStatus() {
     // Create a minimally valid migration.
diff --git a/core/modules/migrate/src/Tests/MigrateTestBase.php b/core/modules/migrate/src/Tests/MigrateTestBase.php
index 139bc2ff2..e9012e34e 100644
--- a/core/modules/migrate/src/Tests/MigrateTestBase.php
+++ b/core/modules/migrate/src/Tests/MigrateTestBase.php
@@ -16,7 +16,7 @@ use Drupal\migrate\Row;
 use Drupal\simpletest\KernelTestBase;
 
 /**
- * Base class for migration tests.
+ * Creates abstract base class for migration tests.
  */
 abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageInterface {
 
@@ -123,9 +123,9 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
    * Prepare any dependent migrations.
    *
    * @param array $id_mappings
-   *   A list of id mappings keyed by migration ids. Each id mapping is a list
-   *   of two arrays, the first are source ids and the second are destination
-   *   ids.
+   *   A list of ID mappings keyed by migration IDs. Each ID mapping is a list
+   *   of two arrays, the first are source IDs and the second are destination
+   *   IDs.
    */
   protected function prepareMigrations(array $id_mappings) {
     foreach ($id_mappings as $migration_id => $data) {
@@ -146,7 +146,7 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
    * Executes a single migration.
    *
    * @param string|\Drupal\migrate\Entity\MigrationInterface $migration
-   *  The migration to execute, or its ID.
+   *   The migration to execute, or its ID.
    */
   protected function executeMigration($migration) {
     if (is_string($migration)) {
@@ -200,8 +200,9 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
   }
 
   /**
-   * Records a failure in the map table of a specific migration in order to
-   * test scenarios which require a failed row.
+   * Records a failure in the map table of a specific migration.
+   *
+   * This is done in order to test scenarios which require a failed row.
    *
    * @param string|\Drupal\migrate\Entity\MigrationInterface $migration
    *   The migration entity, or its ID.
@@ -209,7 +210,8 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
    *   The raw source row which "failed".
    * @param int $status
    *   (optional) The failure status. Should be one of the
-   *   MigrateIdMapInterface::STATUS_* constants.
+   *   MigrateIdMapInterface::STATUS_* constants. Defaults to
+   *   MigrateIdMapInterface::STATUS_FAILED.
    */
   protected function mockFailure($migration, array $row, $status = MigrateIdMapInterface::STATUS_FAILED) {
     if (is_string($migration)) {
diff --git a/core/modules/migrate/src/Tests/MigrationTest.php b/core/modules/migrate/src/Tests/MigrationTest.php
index 96dfadab1..6511903b7 100644
--- a/core/modules/migrate/src/Tests/MigrationTest.php
+++ b/core/modules/migrate/src/Tests/MigrationTest.php
@@ -19,14 +19,14 @@ use Drupal\simpletest\KernelTestBase;
 class MigrationTest extends KernelTestBase {
 
   /**
-   * Enable field because we're using one of its source plugins.
+   * Enable field because we are using one of its source plugins.
    *
    * @var array
    */
   public static $modules = ['migrate', 'field'];
 
   /**
-   * Tests Migration::set()
+   * Tests Migration::set().
    *
    * @covers ::set()
    */
diff --git a/core/modules/migrate/src/Tests/SqlBaseTest.php b/core/modules/migrate/src/Tests/SqlBaseTest.php
index 0ac7bcae0..0fd15a66c 100644
--- a/core/modules/migrate/src/Tests/SqlBaseTest.php
+++ b/core/modules/migrate/src/Tests/SqlBaseTest.php
@@ -11,14 +11,14 @@ use Drupal\migrate\Plugin\migrate\source\TestSqlBase;
 use Drupal\Core\Database\Database;
 
 /**
- * Test the functionality of SqlBase.
+ * Tests the functionality of SqlBase.
  *
  * @group migrate
  */
 class SqlBaseTest extends MigrateTestBase {
 
   /**
-   * Test different connection types.
+   * Tests different connection types.
    */
   public function testConnectionTypes() {
     $sql_base = new TestSqlBase();
@@ -34,7 +34,7 @@ class SqlBaseTest extends MigrateTestBase {
     $sql_base->setConfiguration($config);
     Database::addConnectionInfo($key, $target, Database::getConnectionInfo('default')['default']);
 
-    // Validate we've injected our custom key and target.
+    // Validate we have injected our custom key and target.
     $this->assertIdentical($sql_base->getDatabase()->getTarget(), $target);
     $this->assertIdentical($sql_base->getDatabase()->getKey(), $key);
 
@@ -62,7 +62,7 @@ class SqlBaseTest extends MigrateTestBase {
     $sql_base->setConfiguration(['database_state_key' => $database_state_key]);
     Database::addConnectionInfo($key, $target, Database::getConnectionInfo('default')['default']);
 
-    // Validate we've injected our custom key and target.
+    // Validate we have injected our custom key and target.
     $this->assertIdentical($sql_base->getDatabase()->getTarget(), $target);
     $this->assertIdentical($sql_base->getDatabase()->getKey(), $key);
 
@@ -96,14 +96,14 @@ namespace Drupal\migrate\Plugin\migrate\source;
 class TestSqlBase extends SqlBase {
 
   /**
-   * Override the constructor so we can create one easily.
+   * Overrides the constructor so we can create one easily.
    */
   public function __construct() {
     $this->state = \Drupal::state();
   }
 
   /**
-   * Get the database without caching it.
+   * Gets the database without caching it.
    */
   public function getDatabase() {
     $this->database = NULL;
@@ -111,7 +111,7 @@ class TestSqlBase extends SqlBase {
   }
 
   /**
-   * Allow us to set the configuration from a test.
+   * Allows us to set the configuration from a test.
    *
    * @param array $config
    *   The config array.
diff --git a/core/modules/migrate/src/Tests/TemplateTest.php b/core/modules/migrate/src/Tests/TemplateTest.php
index 631bab7a6..44400e981 100644
--- a/core/modules/migrate/src/Tests/TemplateTest.php
+++ b/core/modules/migrate/src/Tests/TemplateTest.php
@@ -8,7 +8,7 @@
 namespace Drupal\migrate\Tests;
 
 /**
- * Test the migration template functionality.
+ * Tests the migration template functionality.
  *
  * @group migrate
  */
@@ -22,25 +22,25 @@ class TemplateTest extends MigrateTestBase {
   public static $modules = array('template_test');
 
   /**
-   * Test different connection types.
+   * Tests different connection types.
    */
   public function testTemplates() {
     $migration_templates = \Drupal::service('migrate.template_storage')->findTemplatesByTag("Template Test");
     $expected_url = [
-        'id' => 'url_template',
-        'label' => 'Template test - url',
-        'migration_tags' => ['Template Test'],
-        'source' => ['plugin' => 'empty'],
-        'process' => ['src' => 'foobar'],
-        'destination' => ['plugin' => 'url_alias'],
+      'id' => 'url_template',
+      'label' => 'Template test - url',
+      'migration_tags' => ['Template Test'],
+      'source' => ['plugin' => 'empty'],
+      'process' => ['src' => 'foobar'],
+      'destination' => ['plugin' => 'url_alias'],
     ];
     $expected_node = [
-        'id' => 'node_template',
-        'label' => 'Template test - node',
-        'migration_tags' => ['Template Test'],
-        'source' => ['plugin' => 'empty'],
-        'process' => ['src' => 'barfoo'],
-        'destination' => ['plugin' => 'entity:node'],
+      'id' => 'node_template',
+      'label' => 'Template test - node',
+      'migration_tags' => ['Template Test'],
+      'source' => ['plugin' => 'empty'],
+      'process' => ['src' => 'barfoo'],
+      'destination' => ['plugin' => 'entity:node'],
     ];
     $this->assertIdentical($migration_templates['migrate.migration.url_template'], $expected_url);
     $this->assertIdentical($migration_templates['migrate.migration.node_template'], $expected_node);
@@ -51,24 +51,24 @@ class TemplateTest extends MigrateTestBase {
    * Tests retrieving a template by name.
    */
   public function testGetTemplateByName() {
-    /** @var \Drupal\migrate\MigrateTemplateStorage $template_storage */
+    /** @var \Drupal\migrate\MigrateTemplateStorageInterface $template_storage */
     $template_storage = \Drupal::service('migrate.template_storage');
 
     $expected_url = [
-        'id' => 'url_template',
-        'label' => 'Template test - url',
-        'migration_tags' => ['Template Test'],
-        'source' => ['plugin' => 'empty'],
-        'process' => ['src' => 'foobar'],
-        'destination' => ['plugin' => 'url_alias'],
+      'id' => 'url_template',
+      'label' => 'Template test - url',
+      'migration_tags' => ['Template Test'],
+      'source' => ['plugin' => 'empty'],
+      'process' => ['src' => 'foobar'],
+      'destination' => ['plugin' => 'url_alias'],
     ];
     $expected_node = [
-        'id' => 'node_template',
-        'label' => 'Template test - node',
-        'migration_tags' => ['Template Test'],
-        'source' => ['plugin' => 'empty'],
-        'process' => ['src' => 'barfoo'],
-        'destination' => ['plugin' => 'entity:node'],
+      'id' => 'node_template',
+      'label' => 'Template test - node',
+      'migration_tags' => ['Template Test'],
+      'source' => ['plugin' => 'empty'],
+      'process' => ['src' => 'barfoo'],
+      'destination' => ['plugin' => 'entity:node'],
     ];
     $this->assertIdentical($template_storage->getTemplateByName('migrate.migration.url_template'), $expected_url);
     $this->assertIdentical($template_storage->getTemplateByName('migrate.migration.node_template'), $expected_node);
diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php
index 477e8902a..d0c160405 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php
@@ -45,7 +45,9 @@ class MigrateExecutableMemoryExceededTest extends MigrateTestCase {
   );
 
   /**
-   * php.init memory_limit value.
+   * The php.ini memory_limit value.
+   *
+   * @var int
    */
   protected $memoryLimit = 10000000;
 
@@ -68,12 +70,13 @@ class MigrateExecutableMemoryExceededTest extends MigrateTestCase {
    *   The second message to assert.
    * @param bool $memory_exceeded
    *   Whether to test the memory exceeded case.
-   * @param int $memory_usage_first
-   *   (optional) The first memory usage value.
-   * @param int $memory_usage_second
+   * @param int|null $memory_usage_first
+   *   (optional) The first memory usage value. Defaults to NULL.
+   * @param int|null $memory_usage_second
    *   (optional) The fake amount of memory usage reported after memory reclaim.
-   * @param int $memory_limit
-   *   (optional) The memory limit.
+   *   Defaults to NULL.
+   * @param int|null $memory_limit
+   *   (optional) The memory limit. Defaults to NULL.
    */
   protected function runMemoryExceededTest($message, $memory_exceeded, $memory_usage_first = NULL, $memory_usage_second = NULL, $memory_limit = NULL) {
     $this->executable->setMemoryLimit($memory_limit ?: $this->memoryLimit);
diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
index 6e6ace53a..8335e1f7d 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
@@ -14,7 +14,7 @@ use Drupal\migrate\MigrateException;
 use Drupal\migrate\Row;
 
 /**
- * @coversDefaultClass \Drupal\Tests\migrate\Unit\MigrateExecutableTest
+ * @coversDefaultClass \Drupal\migrate\MigrateExecutable
  * @group migrate
  */
 class MigrateExecutableTest extends MigrateTestCase {
@@ -40,6 +40,11 @@ class MigrateExecutableTest extends MigrateTestCase {
    */
   protected $executable;
 
+  /**
+   * The migration's configuration values.
+   *
+   * @var array
+   */
   protected $migrationConfiguration = array(
     'id' => 'test',
   );
@@ -224,8 +229,9 @@ class MigrateExecutableTest extends MigrateTestCase {
   }
 
   /**
-   * Tests the import method with a MigrateException being thrown from the
-   * destination.
+   * Tests the import method with a thrown MigrateException.
+   *
+   * The MigrationException in this case is being thrown from the destination.
    */
   public function testImportWithValidRowWithDestinationMigrateException() {
     $exception_message = $this->getRandomGenerator()->string();
@@ -275,8 +281,9 @@ class MigrateExecutableTest extends MigrateTestCase {
   }
 
   /**
-   * Tests the import method with a MigrateException being thrown from a process
-   * plugin.
+   * Tests the import method with a thrown MigrateException.
+   *
+   * The MigrationException in this case is being thrown from a process plugin.
    */
   public function testImportWithValidRowWithProcesMigrateException() {
     $exception_message = $this->getRandomGenerator()->string();
@@ -421,6 +428,7 @@ class MigrateExecutableTest extends MigrateTestCase {
    * Returns a mock migration source instance.
    *
    * @return \Drupal\migrate\Plugin\MigrateSourceInterface|\PHPUnit_Framework_MockObject_MockObject
+   *   The mocked migration source.
    */
   protected function getMockSource() {
     $iterator = $this->getMock('\Iterator');
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
index 502c9e7aa..c071b159b 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
@@ -61,14 +61,16 @@ class MigrateSourceTest extends MigrateTestCase {
   protected $executable;
 
   /**
-   * Get the source plugin to test.
+   * Gets the source plugin to test.
    *
    * @param array $configuration
-   *   The source configuration.
+   *   (optional) The source configuration. Defaults to an empty array.
    * @param array $migrate_config
-   *   The migration configuration to be used in parent::getMigration().
+   *   (optional) The migration configuration to be used in
+   *   parent::getMigration(). Defaults to an empty array.
    * @param int $status
-   *   The default status for the new rows to be imported.
+   *   (optional) The default status for the new rows to be imported. Defaults
+   *   to MigrateIdMapInterface::STATUS_NEEDS_UPDATE.
    *
    * @return \Drupal\migrate\Plugin\MigrateSourceInterface
    *   A mocked source plugin.
@@ -367,7 +369,7 @@ class MigrateSourceTest extends MigrateTestCase {
   }
 
   /**
-   * Get a mock executable for the test.
+   * Gets a mock executable for the test.
    *
    * @param \Drupal\migrate\Entity\MigrationInterface $migration
    *   The migration entity.
@@ -394,8 +396,9 @@ class StubSourcePlugin extends SourcePluginBase {
    * Helper for setting internal module handler implementation.
    *
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler.
    */
-  function setModuleHandler(ModuleHandlerInterface $module_handler) {
+  public function setModuleHandler(ModuleHandlerInterface $module_handler) {
     $this->moduleHandler = $module_handler;
   }
 
@@ -426,4 +429,5 @@ class StubSourcePlugin extends SourcePluginBase {
   protected function initializeIterator() {
     return [];
   }
+
 }
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
index 0b61f30fa..424406f13 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
@@ -29,12 +29,22 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
     'id' => 'sql_idmap_test',
   ];
 
+  /**
+   * The source IDs.
+   *
+   * @var array
+   */
   protected $sourceIds = [
     'source_id_property' => [
       'type' => 'string',
     ],
   ];
 
+  /**
+   * The destination IDs.
+   *
+   * @var array
+   */
   protected $destinationIds = [
     'destination_id_property' => [
       'type' => 'string',
@@ -48,7 +58,10 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    */
   protected $database;
 
-  public function setUp() {
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
     $this->database = $this->getDatabase([]);
   }
 
@@ -56,7 +69,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    * Saves a single ID mapping row in the database.
    *
    * @param array $map
-   *  The row to save.
+   *   The row to save.
    */
   protected function saveMap(array $map) {
     $table = 'migrate_map_sql_idmap_test';
@@ -114,6 +127,12 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
 
   /**
    * Sets defaults for SQL ID map plugin tests.
+   *
+   * @return array
+   *   An associative array with the following keys:
+   *   - source_row_status
+   *   - rollback_action
+   *   - hash
    */
   protected function idMapDefaults() {
     $defaults = array(
@@ -351,6 +370,9 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    * - Multi-value source ID to multi-value destination ID.
    * - Single-value source ID to multi-value destination ID.
    * - Multi-value source ID to single-value destination ID.
+   *
+   * @return array
+   *   An array of data values.
    */
   public function lookupDestinationIdMappingDataProvider() {
     return [
@@ -368,6 +390,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    *   Number of source fields to test.
    * @param int $num_destination_fields
    *   Number of destination fields to test.
+   *
    * @dataProvider lookupDestinationIdMappingDataProvider
    */
   public function testLookupDestinationIdMapping($num_source_fields, $num_destination_fields) {
@@ -435,6 +458,9 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    * - Multi-value destination ID to multi-value source ID.
    * - Single-value destination ID to multi-value source ID.
    * - Multi-value destination ID to single-value source ID.
+   *
+   * @return array
+   *   An array of data values.
    */
   public function lookupSourceIDMappingDataProvider() {
     return [
@@ -452,6 +478,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    *   Number of source fields to test.
    * @param int $num_destination_fields
    *   Number of destination fields to test.
+   *
    * @dataProvider lookupSourceIDMappingDataProvider
    */
   public function testLookupSourceIDMapping($num_source_fields, $num_destination_fields) {
@@ -556,6 +583,9 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    * - No updates.
    * - One update.
    * - Multiple updates.
+   *
+   * @return array
+   *   An array of data values.
    */
   public function updateCountDataProvider() {
     return [
@@ -570,6 +600,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    *
    * @param int $num_update_rows
    *   The number of update rows to test.
+   *
    * @dataProvider updateCountDataProvider
    */
   public function testUpdateCount($num_update_rows) {
@@ -598,6 +629,9 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    * - No errors.
    * - One error.
    * - Multiple errors.
+   *
+   * @return array
+   *   An array of data values.
    */
   public function errorCountDataProvider() {
     return [
@@ -612,6 +646,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    *
    * @param int $num_error_rows
    *   Number of error rows to test.
+   *
    * @dataProvider errorCountDataProvider
    */
   public function testErrorCount($num_error_rows) {
@@ -731,7 +766,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
    */
   public function testDestroy() {
     $id_map = $this->getIdMap();
-    // Initialize the id map.
+    // Initialize the ID map.
     $id_map->getDatabase();
     $map_table_name = $id_map->mapTableName();
     $message_table_name = $id_map->messageTableName();
@@ -789,6 +824,12 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
     $this->assertSame(iterator_to_array($this->getIdMap()), $expected_results);
   }
 
+  /**
+   * Retrieves the contents of an ID map.
+   *
+   * @return array
+   *   The contents of an ID map.
+   */
   private function getIdMapContents() {
     $result = $this->database
       ->select('migrate_map_sql_idmap_test', 't')
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
index f39a5aeda..b933f791e 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
@@ -111,7 +111,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
   }
 
   /**
-   * Test the source returns the same rows as expected.
+   * Tests that the source returns the same rows as expected.
    */
   public function testRetrieval() {
     $this->assertInstanceOf(SelectInterface::class, $this->source->query());
@@ -119,7 +119,7 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
   }
 
   /**
-   * Test the source returns the row count expected.
+   * Tests that the source returns the row count expected.
    */
   public function testSourceCount() {
     $count = $this->source->count();
@@ -128,16 +128,22 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
   }
 
   /**
-   * Test the source defines a valid ID.
+   * Tests the source defines a valid ID.
    */
   public function testSourceId() {
     $this->assertNotEmpty($this->source->getIds());
   }
 
   /**
+   * Gets the value on a row for a given key.
+   *
    * @param \Drupal\migrate\Row $row
+   *   The row identifier.
    * @param string $key
+   *   The key identifier.
+   *
    * @return mixed
+   *   The value on a row for a given key.
    */
   protected function getValue($row, $key) {
     return $row->getSourceProperty($key);
diff --git a/core/modules/migrate/tests/src/Unit/MigrateTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
index e3a253a59..c9e4a9728 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
@@ -17,9 +17,16 @@ use Drupal\Tests\UnitTestCase;
  */
 abstract class MigrateTestCase extends UnitTestCase {
 
+  /**
+   * An array of migration configuration values.
+   *
+   * @var array
+   */
   protected $migrationConfiguration = [];
 
   /**
+   * The migration ID map.
+   *
    * @var \Drupal\migrate\Plugin\MigrateIdMapInterface|\PHPUnit_Framework_MockObject_MockObject
    */
   protected $idMap;
@@ -32,7 +39,7 @@ abstract class MigrateTestCase extends UnitTestCase {
   protected $migrationStatus = MigrationInterface::STATUS_IDLE;
 
   /**
-   * Retrieve a mocked migration.
+   * Retrieves a mocked migration.
    *
    * @return \Drupal\migrate\Entity\MigrationInterface|\PHPUnit_Framework_MockObject_MockObject
    *   The mocked migration.
@@ -83,8 +90,8 @@ abstract class MigrateTestCase extends UnitTestCase {
 
     $migration->method('set')
       ->willReturnCallback(function ($argument, $value) use (&$configuration) {
-      $configuration[$argument] = $value;
-    });
+        $configuration[$argument] = $value;
+      });
 
     $migration->method('id')
       ->willReturn($configuration['id']);
@@ -93,13 +100,14 @@ abstract class MigrateTestCase extends UnitTestCase {
   }
 
   /**
-   * Get an SQLite database connection object for use in tests.
+   * Gets an SQLite database connection object for use in tests.
    *
    * @param array $database_contents
    *   The database contents faked as an array. Each key is a table name, each
    *   value is a list of table rows, an associative array of field => value.
    * @param array $connection_options
-   *  (optional) Options for the database connection.
+   *   (optional) Options for the database connection. Defaults to an empty
+   *   array.
    *
    * @return \Drupal\Core\Database\Driver\sqlite\Connection
    *   The database connection.
@@ -136,23 +144,25 @@ abstract class MigrateTestCase extends UnitTestCase {
    * Generates a table schema from a row.
    *
    * @param array $row
-   *  The reference row on which to base the schema.
+   *   The reference row on which to base the schema.
    *
    * @return array
-   *  The Schema API-ready table schema.
+   *   The Schema API-ready table schema.
    */
   protected function createSchemaFromRow(array $row) {
-    // SQLite uses loose ("affinity") typing, so it's OK for every column
-    // to be a text field.
+    // SQLite uses loose ("affinity") typing, so it is OK for every column to be
+    // a text field.
     $fields = array_map(function() { return ['type' => 'text']; }, $row);
     return ['fields' => $fields];
   }
 
   /**
-   * Tests a query
+   * Tests a query.
    *
-   * @param array|\Traversable
+   * @param array|\Traversable $iter
    *   The countable. foreach-able actual results if a query is being run.
+   * @param array $expected_results
+   *   An array of expected results.
    */
   public function queryResultTest($iter, $expected_results) {
     $this->assertSame(count($expected_results), count($iter), 'Number of results match');
@@ -168,9 +178,15 @@ abstract class MigrateTestCase extends UnitTestCase {
   }
 
   /**
+   * Gets the value on a row for a given key.
+   *
    * @param array $row
+   *   The row information.
    * @param string $key
+   *   The key identifier.
+   *
    * @return mixed
+   *   The value on a row for a given key.
    */
   protected function getValue($row, $key) {
     return $row[$key];
diff --git a/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php b/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php
index 93cf30173..3ff44fae8 100644
--- a/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php
@@ -23,11 +23,15 @@ use Drupal\Tests\UnitTestCase;
 class MigrationStorageTest extends UnitTestCase {
 
   /**
+   * The migration storage.
+   *
    * @var \Drupal\Tests\migrate\Unit\TestMigrationStorage
    */
   protected $storage;
 
   /**
+   * The storage query.
+   *
    * @var \Drupal\Core\Entity\Query\QueryInterface|\PHPUnit_Framework_MockObject_MockObject
    */
   protected $query;
@@ -35,7 +39,7 @@ class MigrationStorageTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->query = $this->getMock(QueryInterface::class);
     $this->query->method('condition')
       ->willReturnSelf();
@@ -63,7 +67,7 @@ class MigrationStorageTest extends UnitTestCase {
       ->willReturn(['d6_node__page', 'd6_node__article']);
 
     $ids = $this->storage->getVariantIds(['d6_node:*', 'd6_user']);
-    $this->assertSame(['d6_node__page', 'd6_node__article', 'd6_user'],  $ids);
+    $this->assertSame(['d6_node__page', 'd6_node__article', 'd6_user'], $ids);
   }
 
   /**
@@ -76,11 +80,13 @@ class MigrationStorageTest extends UnitTestCase {
       ->willReturn([]);
 
     $ids = $this->storage->getVariantIds(['d6_node:*', 'd6_user']);
-    $this->assertSame(['d6_user'],  $ids);
+    $this->assertSame(['d6_user'], $ids);
   }
 
   /**
-   * Tests getVariantIds() when no variants exist and there are no static
+   * Tests getVariantIds().
+   *
+   * This tests getVariantIds() when no variants exist and there are no static
    * (non-variant) dependencies.
    *
    * @covers ::getVariantIds
@@ -90,7 +96,7 @@ class MigrationStorageTest extends UnitTestCase {
       ->willReturn([]);
 
     $ids = $this->storage->getVariantIds(['d6_node:*', 'd6_node_revision:*']);
-    $this->assertSame([],  $ids);
+    $this->assertSame([], $ids);
   }
 
 }
@@ -98,7 +104,7 @@ class MigrationStorageTest extends UnitTestCase {
 /**
  * Test version of \Drupal\migrate\MigrationStorage.
  *
- * Exposes protected methods for testing.
+ * This class exposes protected methods for testing.
  */
 class TestMigrationStorage extends MigrationStorage {
 
diff --git a/core/modules/migrate/tests/src/Unit/MigrationTest.php b/core/modules/migrate/tests/src/Unit/MigrationTest.php
index 87f6c4343..2693decf0 100644
--- a/core/modules/migrate/tests/src/Unit/MigrationTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrationTest.php
@@ -120,29 +120,65 @@ class MigrationTest extends UnitTestCase {
 
 }
 
+/**
+ * Defines the TestMigration class.
+ */
 class TestMigration extends Migration {
 
+  /**
+   * Constructs an instance of TestMigration object.
+   */
   public function __construct() {
   }
 
+  /**
+   * Sets the requirements values.
+   *
+   * @param array $requirements
+   *   The array of requirement values.
+   */
   public function setRequirements(array $requirements) {
     $this->requirements = $requirements;
   }
 
+  /**
+   * Sets the source Plugin.
+   *
+   * @param \Drupal\migrate\Plugin\MigrateSourceInterface $source_plugin
+   *   The source Plugin.
+   */
   public function setSourcePlugin(MigrateSourceInterface $source_plugin) {
     $this->sourcePlugin = $source_plugin;
   }
 
+  /**
+   * Sets the destination Plugin.
+   *
+   * @param \Drupal\migrate\Plugin\MigrateDestinationInterface $destination_plugin
+   *   The destination Plugin.
+   */
   public function setDestinationPlugin(MigrateDestinationInterface $destination_plugin) {
     $this->destinationPlugin = $destination_plugin;
   }
 
+  /**
+   * Sets the entity manager service.
+   *
+   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   *   The entity manager service.
+   */
   public function setEntityManager(EntityManagerInterface $entity_manager) {
     $this->entityManager = $entity_manager;
   }
 
 }
 
+/**
+ * Defines the RequirementsAwareSourceInterface.
+ */
 interface RequirementsAwareSourceInterface extends MigrateSourceInterface, RequirementsInterface {}
 
+/**
+ * Defines the RequirementsAwareDestinationInterface.
+ */
 interface RequirementsAwareDestinationInterface extends MigrateDestinationInterface, RequirementsInterface {}
diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
index 220cbe84e..6d511fafc 100644
--- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
+++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
@@ -43,7 +43,7 @@ class EntityContentBaseTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->migration = $this->prophesize(MigrationInterface::class);
diff --git a/core/modules/migrate/tests/src/Unit/SqlBaseTest.php b/core/modules/migrate/tests/src/Unit/SqlBaseTest.php
index caa6e3da2..829573cfd 100644
--- a/core/modules/migrate/tests/src/Unit/SqlBaseTest.php
+++ b/core/modules/migrate/tests/src/Unit/SqlBaseTest.php
@@ -18,16 +18,20 @@ use Drupal\Tests\UnitTestCase;
 class SqlBaseTest extends UnitTestCase {
 
   /**
+   * Tests that the ID map is joinable.
+   *
    * @param bool $expected_result
    *   The expected result.
    * @param bool $id_map_is_sql
    *   TRUE if we want getIdMap() to return an instance of Sql.
    * @param bool $with_id_map
-   *   TRUE if we want the id map to have a valid map of ids.
+   *   TRUE if we want the ID map to have a valid map of IDs.
    * @param array $source_options
-   *   An array of connection options for the source connection.
+   *   (optional) An array of connection options for the source connection.
+   *   Defaults to an empty array.
    * @param array $idmap_options
-   *   An array of connection options for the id map connection.
+   *   (optional) An array of connection options for the ID map connection.
+   *   Defaults to an empty array.
    *
    * @dataProvider sqlBaseTestProvider
    */
@@ -40,7 +44,7 @@ class SqlBaseTest extends UnitTestCase {
       ->method('getConnectionOptions')
       ->willReturn($source_options);
 
-    // Setup the id map connection.
+    // Setup the ID map connection.
     $idmap_connection = $this->getMockBuilder('Drupal\Core\Database\Connection')
       ->disableOriginalConstructor()
       ->getMock();
@@ -86,22 +90,56 @@ class SqlBaseTest extends UnitTestCase {
   public function sqlBaseTestProvider() {
     return [
       // Source ids are empty so mapJoinable() is false.
-      [FALSE, FALSE, FALSE],
+      [
+        FALSE,
+        FALSE,
+        FALSE,
+      ],
       // Still false because getIdMap() is not a subclass of Sql.
-      [FALSE, FALSE, TRUE],
+      [
+        FALSE,
+        FALSE,
+        TRUE,
+      ],
       // Test mapJoinable() returns false when source and id connection options
       // differ.
-      [FALSE, TRUE, TRUE, ['username' => 'different_from_map', 'password' => 'different_from_map'], ['username' => 'different_from_source', 'password' => 'different_from_source']],
+      [
+        FALSE,
+        TRUE,
+        TRUE,
+        ['username' => 'different_from_map', 'password' => 'different_from_map'],
+        ['username' => 'different_from_source', 'password' => 'different_from_source'],
+      ],
       // Returns true because source and id map connection options are the same.
-      [TRUE, TRUE, TRUE, ['username' => 'same_value', 'password' => 'same_value'], ['username' => 'same_value', 'password' => 'same_value']],
+      [
+        TRUE,
+        TRUE,
+        TRUE,
+        ['username' => 'same_value', 'password' => 'same_value'],
+        ['username' => 'same_value', 'password' => 'same_value'],
+      ],
     ];
   }
 
 }
 
+/**
+ * Creates a base source class for SQL migration testing.
+ */
 class TestSqlBase extends SqlBase {
 
+  /**
+   * The database object.
+   *
+   * @var object
+   */
   protected $database;
+
+  /**
+   * The migration IDs.
+   *
+   * @var array
+   */
   protected $ids;
 
   /**
@@ -151,7 +189,10 @@ class TestSqlBase extends SqlBase {
   }
 
   /**
-   * Allows us to set the ids during a test.
+   * Allows us to set the IDs during a test.
+   *
+   * @param array $ids
+   *   An array of identifiers.
    */
   public function setIds($ids) {
     $this->ids = $ids;
diff --git a/core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php b/core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php
index 5aaeed5b5..bdff83d35 100644
--- a/core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php
+++ b/core/modules/migrate/tests/src/Unit/TestMigrateExecutable.php
@@ -53,7 +53,7 @@ class TestMigrateExecutable extends MigrateExecutable {
    * Allows access to protected sourceIdValues property.
    *
    * @param array $source_id_values
-   *   The value to set.
+   *   The values to set.
    */
   public function setSourceIdValues($source_id_values) {
     $this->sourceIdValues = $source_id_values;
@@ -100,7 +100,7 @@ class TestMigrateExecutable extends MigrateExecutable {
    * @param int $memory_usage
    *   The fake memory usage value.
    * @param int $cleared_memory_usage
-   *   (optional) The fake cleared memory value.
+   *   (optional) The fake cleared memory value. Defaults to NULL.
    */
   public function setMemoryUsage($memory_usage, $cleared_memory_usage = NULL) {
     $this->memoryUsage = $memory_usage;
diff --git a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
index fa31689e9..de730f4ba 100644
--- a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
+++ b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php
@@ -31,6 +31,8 @@ class TestSqlIdMap extends Sql implements \Iterator {
    *   The configuration for the plugin.
    * @param \Drupal\migrate\Entity\MigrationInterface $migration
    *   The migration to do.
+   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
+   *   The event dispatcher service.
    */
   public function __construct(Connection $database, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) {
     $this->database = $database;
@@ -44,6 +46,18 @@ class TestSqlIdMap extends Sql implements \Iterator {
     return parent::getDatabase();
   }
 
+  /**
+   * Gets the field schema.
+   *
+   * @param array $id_definition
+   *   An array defining the field, with a key 'type'.
+   *
+   * @return array
+   *   A field schema depending on value of key 'type'.  An empty array is
+   *   returned if 'type' is not defined.
+   *
+   * @throws \Drupal\migrate\MigrateException
+   */
   protected function getFieldSchema(array $id_definition) {
     if (!isset($id_definition['type'])) {
       return array();
@@ -54,14 +68,17 @@ class TestSqlIdMap extends Sql implements \Iterator {
           'type' => 'int',
           'not null' => TRUE,
         );
+
       case 'string':
         return array(
           'type' => 'varchar',
           'length' => 255,
           'not null' => FALSE,
         );
+
       default:
         throw new MigrateException($id_definition['type'] . ' not supported');
     }
   }
+
 }
diff --git a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
index 2db5d9e8e..ec3d0f2b1 100644
--- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
+++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
@@ -41,7 +41,7 @@ class EntityRevisionTest extends UnitTestCase {
    */
   protected $fieldTypeManager;
 
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Setup mocks to be used when creating a revision destination.
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php
index 38b96df20..7667c7f57 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php
@@ -54,7 +54,7 @@ abstract class CckFieldPluginBase extends PluginBase implements MigrateCckFieldI
    * {@inheritdoc}
    */
   public function getFieldWidgetMap() {
-    // By default use the plugin id for the widget types.
+    // By default, use the plugin ID for the widget types.
     return [
       $this->pluginId => $this->pluginId . '_default',
     ];
diff --git a/core/modules/migrate_drupal/src/Tests/d6/EntityContentBaseTest.php b/core/modules/migrate_drupal/src/Tests/d6/EntityContentBaseTest.php
index 1015aa16a..5420fec0c 100644
--- a/core/modules/migrate_drupal/src/Tests/d6/EntityContentBaseTest.php
+++ b/core/modules/migrate_drupal/src/Tests/d6/EntityContentBaseTest.php
@@ -24,7 +24,7 @@ class EntityContentBaseTest extends MigrateDrupal6TestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Create a field on the user entity so that we can test nested property
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
index 0f60343a3..76b3bf6e7 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -88,6 +88,48 @@ $connection->insert('actions')
   'parameters',
   'description',
 ))
+->values(array(
+  'aid' => '1',
+  'type' => 'comment',
+  'callback' => 'comment_unpublish_by_keyword_action',
+  'parameters' => 'a:1:{s:8:"keywords";a:1:{i:0;s:6:"drupal";}}',
+  'description' => 'Unpublish comment containing keyword(s)',
+))
+->values(array(
+  'aid' => '2',
+  'type' => 'node',
+  'callback' => 'node_assign_owner_action',
+  'parameters' => 'a:1:{s:9:"owner_uid";s:1:"2";}',
+  'description' => 'Change the author of a post',
+))
+->values(array(
+  'aid' => '3',
+  'type' => 'node',
+  'callback' => 'node_unpublish_by_keyword_action',
+  'parameters' => 'a:1:{s:8:"keywords";a:1:{i:0;s:6:"drupal";}}',
+  'description' => 'Unpublish post containing keyword(s)',
+))
+->values(array(
+  'aid' => '4',
+  'type' => 'system',
+  'callback' => 'system_message_action',
+  'parameters' => 'a:1:{s:7:"message";s:21:"Drupal migration test";}',
+  'description' => 'Display a message to the user',
+))
+->values(array(
+  'aid' => '5',
+  'type' => 'system',
+  'callback' => 'system_send_email_action',
+  'parameters' => 'a:3:{s:9:"recipient";s:16:"test@example.com";s:7:"subject";s:21:"Drupal migration test";s:7:"message";s:21:"Drupal migration test";}',
+  'description' => 'Send e-mail',
+))
+->values(array(
+  'aid' => '6',
+  'type' => 'system',
+  'callback' => 'system_goto_action',
+  'parameters' => 'a:1:{s:3:"url";s:22:"https://www.drupal.org";}',
+  'description' => 'Redirect to URL',
+))
 ->values(array(
   'aid' => 'comment_publish_action',
   'type' => 'comment',
@@ -196,6 +238,30 @@ $connection->schema()->createTable('actions_aid', array(
   'mysql_character_set' => 'utf8',
 ));
 
+$connection->insert('actions_aid')
+->fields(array(
+  'aid',
+))
+->values(array(
+  'aid' => '1',
+))
+->values(array(
+  'aid' => '2',
+))
+->values(array(
+  'aid' => '3',
+))
+->values(array(
+  'aid' => '4',
+))
+->values(array(
+  'aid' => '5',
+))
+->values(array(
+  'aid' => '6',
+))
+->execute();
+
 $connection->schema()->createTable('aggregator_category', array(
   'fields' => array(
     'cid' => array(
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index 78651e4be..0e94e8f9b 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -417,6 +417,48 @@ $connection->insert('actions')
   'parameters',
   'label',
 ))
+->values(array(
+  'aid' => '2',
+  'type' => 'comment',
+  'callback' => 'comment_unpublish_by_keyword_action',
+  'parameters' => 'a:1:{s:8:"keywords";a:1:{i:0;s:6:"drupal";}}',
+  'label' => 'Unpublish comment containing keyword(s)',
+))
+->values(array(
+  'aid' => '3',
+  'type' => 'node',
+  'callback' => 'node_assign_owner_action',
+  'parameters' => 'a:1:{s:9:"owner_uid";s:1:"2";}',
+  'label' => 'Change the author of content',
+))
+->values(array(
+  'aid' => '4',
+  'type' => 'node',
+  'callback' => 'node_unpublish_by_keyword_action',
+  'parameters' => 'a:1:{s:8:"keywords";a:1:{i:0;s:6:"drupal";}}',
+  'label' => 'Unpublish content containing keyword(s)',
+))
+->values(array(
+  'aid' => '5',
+  'type' => 'system',
+  'callback' => 'system_message_action',
+  'parameters' => 'a:1:{s:7:"message";s:21:"Drupal migration test";}',
+  'label' => 'Display a message to the user',
+))
+->values(array(
+  'aid' => '6',
+  'type' => 'system',
+  'callback' => 'system_send_email_action',
+  'parameters' => 'a:3:{s:9:"recipient";s:16:"test@example.com";s:7:"subject";s:21:"Drupal migration test";s:7:"message";s:21:"Drupal migration test";}',
+  'label' => 'Send e-mail',
+))
+->values(array(
+  'aid' => '7',
+  'type' => 'system',
+  'callback' => 'system_goto_action',
+  'parameters' => 'a:1:{s:3:"url";s:22:"https://www.drupal.org";}',
+  'label' => 'Redirect to URL',
+))
 ->values(array(
   'aid' => 'comment_publish_action',
   'type' => 'comment',
@@ -18829,7 +18871,7 @@ $connection->insert('menu_links')
 ->values(array(
   'menu_name' => 'menu-test-menu',
   'mlid' => '467',
-  'plid' => '0',
+  'plid' => '469',
   'link_path' => 'http://google.com',
   'router_path' => '',
   'link_title' => 'Google',
@@ -18840,10 +18882,10 @@ $connection->insert('menu_links')
   'has_children' => '0',
   'expanded' => '0',
   'weight' => '0',
-  'depth' => '1',
+  'depth' => '2',
   'customized' => '1',
-  'p1' => '467',
-  'p2' => '0',
+  'p1' => '469',
+  'p2' => '467',
   'p3' => '0',
   'p4' => '0',
   'p5' => '0',
@@ -19015,6 +19057,33 @@ $connection->insert('menu_links')
   'p9' => '0',
   'updated' => '0',
 ))
+->values(array(
+  'menu_name' => 'management',
+  'mlid' => '478',
+  'plid' => '20',
+  'link_path' => 'admin/content/book',
+  'router_path' => 'admin/content/book',
+  'link_title' => 'custom link test',
+  'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:0:"";}}',
+  'module' => 'menu',
+  'hidden' => '0',
+  'external' => '0',
+  'has_children' => '0',
+  'expanded' => '0',
+  'weight' => '0',
+  'depth' => '3',
+  'customized' => '1',
+  'p1' => '1',
+  'p2' => '20',
+  'p3' => '478',
+  'p4' => '0',
+  'p5' => '0',
+  'p6' => '0',
+  'p7' => '0',
+  'p8' => '0',
+  'p9' => '0',
+  'updated' => '0',
+))
 ->execute();
 
 $connection->schema()->createTable('menu_router', array(
diff --git a/core/modules/node/node.js b/core/modules/node/node.js
index 1f6752818..98af6fdc1 100644
--- a/core/modules/node/node.js
+++ b/core/modules/node/node.js
@@ -38,9 +38,16 @@
         var $authorContext = $(context);
         var name = $authorContext.find('.field--name-uid input').val();
         var date = $authorContext.find('.field--name-created input').val();
-        return date ?
-          Drupal.t('By @name on @date', {'@name': name, '@date': date}) :
-          Drupal.t('By @name', {'@name': name});
+
+        if (name && date) {
+          return Drupal.t('By @name on @date', {'@name': name, '@date': date});
+        }
+        else if (name) {
+          return Drupal.t('By @name', {'@name': name});
+        }
+        else if (date) {
+          return Drupal.t('Authored on @date', {'@date': date});
+        }
       });
 
       $context.find('.node-form-options').drupalSetSummary(function (context) {
diff --git a/core/modules/node/src/Access/NodeRevisionAccessCheck.php b/core/modules/node/src/Access/NodeRevisionAccessCheck.php
index aa654a2bb..a65c9243c 100644
--- a/core/modules/node/src/Access/NodeRevisionAccessCheck.php
+++ b/core/modules/node/src/Access/NodeRevisionAccessCheck.php
@@ -77,7 +77,7 @@ class NodeRevisionAccessCheck implements AccessInterface {
       $node = $this->nodeStorage->loadRevision($node_revision);
     }
     $operation = $route->getRequirement('_access_node_revision');
-    return AccessResult::allowedIf($node && $this->checkAccess($node, $account, $operation))->cachePerPermissions();
+    return AccessResult::allowedIf($node && $this->checkAccess($node, $account, $operation))->cachePerPermissions()->addCacheableDependency($node);
   }
 
   /**
diff --git a/core/modules/node/src/Plugin/views/argument_default/Node.php b/core/modules/node/src/Plugin/views/argument_default/Node.php
index 6ed43ec37..e134ee866 100644
--- a/core/modules/node/src/Plugin/views/argument_default/Node.php
+++ b/core/modules/node/src/Plugin/views/argument_default/Node.php
@@ -17,8 +17,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 /**
  * Default argument plugin to extract a node.
  *
- * This plugin actually has no options so it odes not need to do a great deal.
- *
  * @ViewsArgumentDefault(
  *   id = "node",
  *   title = @Translation("Content ID from URL")
diff --git a/core/modules/node/src/Tests/Migrate/d6/MigrateNodeBundleSettingsTest.php b/core/modules/node/src/Tests/Migrate/d6/MigrateNodeBundleSettingsTest.php
index 1003a52de..d2296613a 100644
--- a/core/modules/node/src/Tests/Migrate/d6/MigrateNodeBundleSettingsTest.php
+++ b/core/modules/node/src/Tests/Migrate/d6/MigrateNodeBundleSettingsTest.php
@@ -21,7 +21,7 @@ class MigrateNodeBundleSettingsTest extends MigrateDrupal6TestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->installConfig(['node']);
     $this->executeMigration('d6_node_type');
diff --git a/core/modules/node/src/Tests/NodeRevisionsUiBypassAccessTest.php b/core/modules/node/src/Tests/NodeRevisionsUiBypassAccessTest.php
new file mode 100644
index 000000000..4b7c4f19b
--- /dev/null
+++ b/core/modules/node/src/Tests/NodeRevisionsUiBypassAccessTest.php
@@ -0,0 +1,92 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\node\Tests\NodeRevisionsUiBypassAccessTest.
+ */
+
+namespace Drupal\node\Tests;
+
+use Drupal\node\Entity\NodeType;
+
+/**
+ * Tests the revision tab display.
+ *
+ * This test is similar to NodeRevisionsUITest except that it uses a user with
+ * the bypass node access permission to make sure that the revision access
+ * check adds correct cacheability metadata.
+ *
+ * @group node
+ */
+class NodeRevisionsUiBypassAccessTest extends NodeTestBase {
+
+  /**
+   * User with bypass node access permission.
+   *
+   * @var \Drupal\user\Entity\User
+   */
+  protected $editor;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['block'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Create a user.
+    $this->editor = $this->drupalCreateUser([
+      'administer nodes',
+      'edit any page content',
+      'view page revisions',
+      'bypass node access',
+      'access user profiles',
+    ]);
+  }
+
+  /**
+   * Checks that the Revision tab is displayed correctly.
+   */
+  function testDisplayRevisionTab() {
+    $this->drupalPlaceBlock('local_tasks_block');
+
+    $this->drupalLogin($this->editor);
+    $node_storage = $this->container->get('entity.manager')->getStorage('node');
+
+    // Set page revision setting 'create new revision'. This will mean new
+    // revisions are created by default when the node is edited.
+    $type = NodeType::load('page');
+    $type->setNewRevision(TRUE);
+    $type->save();
+
+    // Create the node.
+    $node = $this->drupalCreateNode();
+
+    // Verify the checkbox is checked on the node edit form.
+    $this->drupalGet('node/' . $node->id() . '/edit');
+    $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked");
+
+    // Uncheck the create new revision checkbox and save the node.
+    $edit = array('revision' => FALSE);
+    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save and keep published');
+
+    $this->assertUrl($node->toUrl());
+    $this->assertNoLink(t('Revisions'));
+
+    // Verify the checkbox is checked on the node edit form.
+    $this->drupalGet('node/' . $node->id() . '/edit');
+    $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked");
+
+    // Submit the form without changing the checkbox.
+    $edit = array();
+    $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save and keep published');
+
+    $this->assertUrl($node->toUrl());
+    $this->assertLink(t('Revisions'));
+  }
+
+}
diff --git a/core/modules/node/src/Tests/NodeTypeTest.php b/core/modules/node/src/Tests/NodeTypeTest.php
index 07117f709..945c83fd7 100644
--- a/core/modules/node/src/Tests/NodeTypeTest.php
+++ b/core/modules/node/src/Tests/NodeTypeTest.php
@@ -10,6 +10,7 @@ namespace Drupal\node\Tests;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\node\Entity\NodeType;
 use Drupal\Core\Url;
+use Drupal\node\NodeTypeInterface;
 
 /**
  * Ensures that node type functions work correctly.
@@ -124,6 +125,17 @@ class NodeTypeTest extends NodeTestBase {
     $this->assertRaw('Foo', 'Title field was found.');
     $this->assertRaw('Body', 'Body field was found.');
 
+    // Change the name through the API
+    /** @var NodeTypeInterface $node_type */
+    $node_type = NodeType::load('page');
+    $node_type->set('name', 'NewBar');
+    $node_type->save();
+
+    /** @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info */
+    $bundle_info = \Drupal::service('entity_type.bundle.info');
+    $node_bundles = $bundle_info->getBundleInfo('node');
+    $this->assertEqual($node_bundles['page']['label'], 'NewBar', 'Node type bundle cache is updated');
+
     // Remove the body field.
     $this->drupalPostForm('admin/structure/types/manage/page/fields/node.page.body/delete', array(), t('Delete'));
     // Resave the settings for this type.
diff --git a/core/modules/node/src/Tests/NodeViewLanguageTest.php b/core/modules/node/src/Tests/NodeViewLanguageTest.php
index b53f3e5d4..65548cdc5 100644
--- a/core/modules/node/src/Tests/NodeViewLanguageTest.php
+++ b/core/modules/node/src/Tests/NodeViewLanguageTest.php
@@ -39,7 +39,7 @@ class NodeViewLanguageTest extends NodeTestBase {
     $node = $this->drupalCreateNode(array('langcode' => 'es'));
 
     $this->drupalGet($node->urlInfo());
-    $this->assertText('Spanish','The language field is displayed properly.');
+    $this->assertText('Spanish', 'The language field is displayed properly.');
   }
 
 }
diff --git a/core/modules/node/src/Tests/Views/BulkFormTest.php b/core/modules/node/src/Tests/Views/BulkFormTest.php
index 01e997a4e..823074911 100644
--- a/core/modules/node/src/Tests/Views/BulkFormTest.php
+++ b/core/modules/node/src/Tests/Views/BulkFormTest.php
@@ -175,18 +175,18 @@ class BulkFormTest extends NodeTestBase {
     // operations are always applied to individual translations.
     $edit = array(
       // Original and all translations.
-      'node_bulk_form[0]' => TRUE,  // Node 1, English, original.
-      'node_bulk_form[1]' => TRUE,  // Node 1, British English.
-      'node_bulk_form[2]' => TRUE,  // Node 1, Italian.
+      'node_bulk_form[0]' => TRUE, // Node 1, English, original.
+      'node_bulk_form[1]' => TRUE, // Node 1, British English.
+      'node_bulk_form[2]' => TRUE, // Node 1, Italian.
       // Original and only one translation.
-      'node_bulk_form[3]' => TRUE,  // Node 2, English.
-      'node_bulk_form[4]' => TRUE,  // Node 2, British English, original.
+      'node_bulk_form[3]' => TRUE, // Node 2, English.
+      'node_bulk_form[4]' => TRUE, // Node 2, British English, original.
       'node_bulk_form[5]' => FALSE, // Node 2, Italian.
       // Only a single translation.
-      'node_bulk_form[6]' => TRUE,  // Node 3, English.
+      'node_bulk_form[6]' => TRUE, // Node 3, English.
       'node_bulk_form[7]' => FALSE, // Node 3, Italian, original.
       // Only a single untranslated node.
-      'node_bulk_form[8]' => TRUE,  // Node 4, English, untranslated.
+      'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
       'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
       'action' => 'node_unpublish_action',
     );
@@ -216,18 +216,18 @@ class BulkFormTest extends NodeTestBase {
     // nodes and individual translations are properly deleted.
     $edit = array(
       // Original and all translations.
-      'node_bulk_form[0]' => TRUE,  // Node 1, English, original.
-      'node_bulk_form[1]' => TRUE,  // Node 1, British English.
-      'node_bulk_form[2]' => TRUE,  // Node 1, Italian.
+      'node_bulk_form[0]' => TRUE, // Node 1, English, original.
+      'node_bulk_form[1]' => TRUE, // Node 1, British English.
+      'node_bulk_form[2]' => TRUE, // Node 1, Italian.
       // Original and only one translation.
-      'node_bulk_form[3]' => TRUE,  // Node 2, English.
-      'node_bulk_form[4]' => TRUE,  // Node 2, British English, original.
+      'node_bulk_form[3]' => TRUE, // Node 2, English.
+      'node_bulk_form[4]' => TRUE, // Node 2, British English, original.
       'node_bulk_form[5]' => FALSE, // Node 2, Italian.
       // Only a single translation.
-      'node_bulk_form[6]' => TRUE,  // Node 3, English.
+      'node_bulk_form[6]' => TRUE, // Node 3, English.
       'node_bulk_form[7]' => FALSE, // Node 3, Italian, original.
       // Only a single untranslated node.
-      'node_bulk_form[8]' => TRUE,  // Node 4, English, untranslated.
+      'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
       'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
       'action' => 'node_delete_action',
     );
diff --git a/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php
index 5d33ba230..c36b377c0 100644
--- a/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php
+++ b/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php
@@ -22,7 +22,7 @@ class RevisionRelationshipsTest extends ViewTestBase {
    *
    * @var array
    */
-  public static $modules = array('node' ,'node_test_views');
+  public static $modules = array('node' , 'node_test_views');
 
   protected function setUp() {
     parent::setUp();
diff --git a/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php b/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
index ea90c5395..0728eda94 100644
--- a/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
+++ b/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
@@ -47,7 +47,7 @@ class DenyNodePreviewTest extends UnitTestCase {
    */
   protected $routeMatch;
 
-  public function setUp() {
+  protected function setUp() {
     $this->routeMatch = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
     $this->policy = new DenyNodePreview($this->routeMatch);
     $this->response = new Response();
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
index 639502802..c38b20eee 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
@@ -252,7 +252,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
   }
 
   /**
-   * @inheritdoc.
+   * {@inheritdoc}
    */
   public static function storageSettingsToConfigData(array $settings) {
     if (isset($settings['allowed_values'])) {
@@ -262,7 +262,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
   }
 
   /**
-   * @inheritdoc.
+   * {@inheritdoc}
    */
   public static function storageSettingsFromConfigData(array $settings) {
     if (isset($settings['allowed_values'])) {
diff --git a/core/modules/options/src/Tests/Views/ViewsDataTest.php b/core/modules/options/src/Tests/Views/ViewsDataTest.php
index b8773a0c1..f743f4ca1 100644
--- a/core/modules/options/src/Tests/Views/ViewsDataTest.php
+++ b/core/modules/options/src/Tests/Views/ViewsDataTest.php
@@ -28,7 +28,7 @@ class ViewsDataTest extends OptionsTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $field_name = 'test_options';
diff --git a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
index 22ae7b2b4..ab1c8f2ca 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
@@ -105,6 +105,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
       'user:0',
       'user:' . $author_1->id(),
       'config:filter.format.basic_html',
+      'config:color.theme.bartik',
       'config:search.settings',
       'config:system.menu.account',
       'config:system.menu.tools',
@@ -142,6 +143,7 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
       'node_view',
       'node:' . $node_2->id(),
       'user:' . $author_2->id(),
+      'config:color.theme.bartik',
       'config:filter.format.full_html',
       'config:search.settings',
       'config:system.menu.account',
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 307a08bb3..24309b724 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -83,7 +83,9 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {
  * Implements hook_entity_translation_delete().
  */
 function path_entity_translation_delete(EntityInterface $translation) {
-  $path = $translation->urlInfo()->getInternalPath();
-  $conditions = array('source' => '/' . $path, 'langcode' => $translation->language()->getId());
-  \Drupal::service('path.alias_storage')->delete($conditions);
+  if ($translation->hasLinkTemplate('canonical')) {
+    $path = $translation->urlInfo()->getInternalPath();
+    $conditions = array('source' => '/' . $path, 'langcode' => $translation->language()->getId());
+    \Drupal::service('path.alias_storage')->delete($conditions);
+  }
 }
diff --git a/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php b/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
new file mode 100644
index 000000000..6fa9c1bdd
--- /dev/null
+++ b/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\path\tests\Kernel\PathNoCanonicalLinkTest.
+ */
+
+namespace Drupal\Tests\path\Kernel;
+
+use Drupal\content_translation_test\Entity\EntityTestTranslatableUISkip;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\language\Entity\ConfigurableLanguage;
+
+/**
+ * Tests path alias deletion when there is no canonical link template.
+ *
+ * @group path
+ */
+class PathNoCanonicalLinkTest extends KernelTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = array('path', 'content_translation_test', 'language', 'entity_test', 'user', 'system');
+
+  protected function setUp() {
+    parent::setUp();
+
+    $this->installEntitySchema('entity_test');
+    $this->installEntitySchema('entity_test_mul');
+    $this->installSchema('system', 'router');
+    \Drupal::service('router.builder')->rebuild();
+
+    // Adding german language.
+    ConfigurableLanguage::create(['id' => 'de'])->save();
+
+    $this->config('language.types')->setData([
+      'configurable' => ['language_interface'],
+      'negotiation' => ['language_interface' => ['enabled' => ['language-url' => 0]]],
+    ])->save();
+  }
+
+  /**
+   * Tests for no canonical link templates.
+   */
+  public function testNoCanonicalLinkTemplate() {
+    $entity_type = EntityTestTranslatableUISkip::create([
+      'name' => 'name english',
+      'language' => 'en'
+    ]);
+    $entity_type->save();
+
+    $entity_type->addTranslation('de', ['name' => 'name german']);
+    $entity_type->save();
+    $this->assertEqual(count($entity_type->getTranslationLanguages()), 2);
+
+    $entity_type->removeTranslation('de');
+    $entity_type->save();
+    $this->assertEqual(count($entity_type->getTranslationLanguages()), 1);
+  }
+
+}
diff --git a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
index 4816c04a5..6e6fffb9a 100644
--- a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
+++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
@@ -98,7 +98,7 @@ class QuickEditLoadingTest extends WebTestBase {
     $this->drupalGet('node/1');
 
     // Library and in-place editors.
-    $this->assertNoRaw('core/modules/quickedit/js/quickedit.js',  'Quick Edit library not loaded.');
+    $this->assertNoRaw('core/modules/quickedit/js/quickedit.js', 'Quick Edit library not loaded.');
     $this->assertNoRaw('core/modules/quickedit/js/editors/formEditor.js', "'form' in-place editor not loaded.");
 
     // HTML annotation must always exist (to not break the render cache).
diff --git a/core/modules/rdf/rdf.api.php b/core/modules/rdf/rdf.api.php
index 7a9e38ec3..3dbe7d1e2 100644
--- a/core/modules/rdf/rdf.api.php
+++ b/core/modules/rdf/rdf.api.php
@@ -18,7 +18,7 @@
  * defined in rdf_rdf_namespaces(), this hook should be used to define the new
  * namespace prefixes.
  *
- * @return
+ * @return string[]
  *   An associative array of namespaces where the key is the namespace prefix
  *   and the value is the namespace URI.
  *
diff --git a/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php
index 428a43506..9805682ad 100644
--- a/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php
+++ b/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php
@@ -32,7 +32,7 @@ class StringFieldRdfaTest extends FieldRdfaTestBase {
    */
   protected $testSummary = 'test_summary_value';
 
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->createTestField();
diff --git a/core/modules/responsive_image/src/ResponsiveImageStyleForm.php b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
index c220dbc2d..359c5c720 100644
--- a/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
+++ b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
@@ -162,7 +162,7 @@ class ResponsiveImageStyleForm extends EntityForm {
           '#type' => 'textfield',
           '#title' => $this->t('Sizes'),
           '#default_value' => isset($image_style_mapping['image_mapping']['sizes']) ? $image_style_mapping['image_mapping']['sizes'] : '100vw',
-          '#description' => $this->t('Enter the value for the sizes attribute: for example "(min-width:700px) 700px, 100vw)".'),
+          '#description' => $this->t('Enter the value for the sizes attribute, for example: %example_sizes.', ['%example_sizes' => '(min-width:700px) 700px, 100vw']),
           '#states' => array(
             'visible' => array(
               ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'),
diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
index 68ba8974a..d9ed30a07 100644
--- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
+++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
@@ -138,10 +138,9 @@ class DataFieldRow extends RowPluginBase {
     $output = array();
 
     foreach ($this->view->field as $id => $field) {
-      // If this is not unknown and the raw output option has been set, just get
-      // the raw value.
-      if (($field->field_alias != 'unknown') && !empty($this->rawOutputOptions[$id])) {
-        $value = $field->sanitizeValue($field->getValue($row), 'xss_admin');
+      // If the raw output option has been set, just get the raw value.
+      if (!empty($this->rawOutputOptions[$id])) {
+        $value = $field->getValue($row);
       }
       // Otherwise, pass this through the field advancedRender() method.
       else {
diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php
index b6f94e3b4..468cc5c30 100644
--- a/core/modules/rest/src/Routing/ResourceRoutes.php
+++ b/core/modules/rest/src/Routing/ResourceRoutes.php
@@ -75,7 +75,7 @@ class ResourceRoutes extends RouteSubscriberBase {
         $methods = $route->getMethods();
         // Only expose routes where the method is enabled in the configuration.
         if ($methods && ($method = $methods[0]) && $method && isset($enabled_methods[$method])) {
-          $route->setRequirement('_access_rest_csrf',  'TRUE');
+          $route->setRequirement('_access_rest_csrf', 'TRUE');
 
           // Check that authentication providers are defined.
           if (empty($enabled_methods[$method]['supported_auth']) || !is_array($enabled_methods[$method]['supported_auth'])) {
diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
index e3b8d263c..b42da4218 100644
--- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
@@ -445,16 +445,30 @@ class StyleSerializerTest extends PluginTestBase {
 
     // Test an empty string for an alias, this should not be used. This also
     // tests that the form can be submitted with no aliases.
-    $this->drupalPostForm($row_options, array('row_options[field_options][created][raw_output]' => '1'), t('Apply'));
+    $values = array(
+      'row_options[field_options][created][raw_output]' => '1',
+      'row_options[field_options][name][raw_output]' => '1',
+    );
+    $this->drupalPostForm($row_options, $values, t('Apply'));
     $this->drupalPostForm(NULL, array(), t('Save'));
 
     $view = Views::getView('test_serializer_display_field');
     $view->setDisplay('rest_export_1');
     $this->executeView($view);
 
+    $storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
+
+    // Update the name for each to include a script tag.
+    foreach ($storage->loadMultiple() as $entity_test) {
+      $name = $entity_test->name->value;
+      $entity_test->set('name', "<script>$name</script>");
+      $entity_test->save();
+    }
+
     // Just test the raw 'created' value against each row.
     foreach ($this->drupalGetJSON('test/serialize/field') as $index => $values) {
       $this->assertIdentical($values['created'], $view->result[$index]->views_test_data_created, 'Expected raw created value found.');
+      $this->assertIdentical($values['name'], $view->result[$index]->views_test_data_name, 'Expected raw name value found.');
     }
   }
 
@@ -545,6 +559,52 @@ class StyleSerializerTest extends PluginTestBase {
     $result = $this->drupalGetJSON('test/serialize/node-field');
     $this->assertEqual($result[1]['nid'], $node->id());
     $this->assertTrue(strpos($this->getRawContent(), "<script") === FALSE, "No script tag is present in the raw page contents.");
+
+    $this->drupalLogin($this->adminUser);
+
+    // Add an alias and make the output raw.
+    $row_options = 'admin/structure/views/nojs/display/test_serializer_node_display_field/rest_export_1/row_options';
+
+    // Test an empty string for an alias, this should not be used. This also
+    // tests that the form can be submitted with no aliases.
+    $this->drupalPostForm($row_options, ['row_options[field_options][title][raw_output]' => '1'], t('Apply'));
+    $this->drupalPostForm(NULL, [], t('Save'));
+
+    $view = Views::getView('test_serializer_node_display_field');
+    $view->setDisplay('rest_export_1');
+    $this->executeView($view);
+
+    // Test the raw 'created' value against each row.
+    foreach ($this->drupalGetJSON('test/serialize/node-field') as $index => $values) {
+      $this->assertIdentical($values['title'], $view->result[$index]->_entity->title->value, 'Expected raw title value found.');
+    }
+
+    // Test that multiple raw body fields are shown.
+    // Make the body field unlimited cardinatlity.
+    $storage_definition = $node->getFieldDefinition('body')->getFieldStorageDefinition();
+    $storage_definition->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
+    $storage_definition->save();
+
+    $this->drupalPostForm($row_options, ['row_options[field_options][body][raw_output]' => '1'], t('Apply'));
+    $this->drupalPostForm(NULL, [], t('Save'));
+
+    $node = $this->drupalCreateNode();
+
+    $body = [
+      'value' => '<script type="text/javascript">alert("node-body");</script>' . $this->randomMachineName(32),
+      'format' => filter_default_format(),
+    ];
+    // Add two body items.
+    $node->body = [$body, $body];
+    $node->save();
+
+    $view = Views::getView('test_serializer_node_display_field');
+    $view->setDisplay('rest_export_1');
+    $this->executeView($view);
+
+    $result = $this->drupalGetJSON('test/serialize/node-field');
+    $this->assertEqual(count($result[2]['body']), $node->body->count(), 'Expected count of values');
+    $this->assertEqual($result[2]['body'], array_map(function($item) { return $item['value']; }, $node->body->getValue()), 'Expected raw body values found.');
   }
 
   /**
diff --git a/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_node_display_field.yml b/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_node_display_field.yml
index 7699fb14d..34133a5ac 100644
--- a/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_node_display_field.yml
+++ b/core/modules/rest/tests/modules/rest_test_views/test_views/views.view.test_serializer_node_display_field.yml
@@ -46,6 +46,26 @@ display:
           plugin_id: field
           entity_type: node
           entity_field: nid
+        title:
+          id: title
+          table: node_field_data
+          field: title
+          label: Title
+          exclude: false
+          alter:
+            alter_text: false
+          element_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          entity_type: node
+          entity_field: title
+          type: string
+          settings:
+            link_to_entity: true
+          plugin_id: field
         body:
           id: body
           table: node__body
diff --git a/core/modules/search/src/Tests/SearchExcerptTest.php b/core/modules/search/src/Tests/SearchExcerptTest.php
index 865d79a3f..7998c1aee 100644
--- a/core/modules/search/src/Tests/SearchExcerptTest.php
+++ b/core/modules/search/src/Tests/SearchExcerptTest.php
@@ -69,7 +69,7 @@ class SearchExcerptTest extends KernelTestBase {
     // 123456789 HTMLTest +123456789+&lsquo;  +&lsquo;  +&lsquo;  +&lsquo;  +12345678  &nbsp;&nbsp;  +&lsquo;  +&lsquo;  +&lsquo;   &lsquo;
     $text = "<div class=\"field field--name-body field--type-text-with-summary field--label-hidden\"><div class=\"field__items\"><div class=\"field__item even\" property=\"content:encoded\"><p>123456789 HTMLTest +123456789+‘  +‘  +‘  +‘  +12345678      +‘  +‘  +‘   ‘</p>\n</div></div></div> ";
     $result = $this->doSearchExcerpt('HTMLTest', $text);
-    $this->assertFalse(empty($result),  'Rendered Multi-byte HTML encodings are not corrupted in search excerpts');
+    $this->assertFalse(empty($result), 'Rendered Multi-byte HTML encodings are not corrupted in search excerpts');
   }
 
   /**
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php
index 3f253881a..dc14d6f42 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php
@@ -36,7 +36,7 @@ class ComplexDataNormalizerTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->normalizer = new ComplexDataNormalizer();
   }
 
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php
index c0c2e9f92..a86b6f7e5 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php
@@ -45,7 +45,7 @@ class EntityReferenceFieldItemNormalizerTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->normalizer = new EntityReferenceFieldItemNormalizer();
 
     $this->serializer = $this->prophesize(Serializer::class);
diff --git a/core/modules/shortcut/migration_templates/d7_shortcut.yml b/core/modules/shortcut/migration_templates/d7_shortcut.yml
index da3d89494..ba986eb85 100644
--- a/core/modules/shortcut/migration_templates/d7_shortcut.yml
+++ b/core/modules/shortcut/migration_templates/d7_shortcut.yml
@@ -23,4 +23,4 @@ destination:
 migration_dependencies:
   required:
     - d7_shortcut_set
-    - d7_menu_links
+    - menu_links
diff --git a/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetTest.php b/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetTest.php
index a1fb995c9..ff2cd8f06 100644
--- a/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetTest.php
+++ b/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetTest.php
@@ -38,9 +38,10 @@ class MigrateShortcutSetTest extends MigrateDrupal7TestBase {
     $this->installSchema('system', array('router'));
     $this->installEntitySchema('shortcut');
     $this->installEntitySchema('menu_link_content');
+    \Drupal::service('router.builder')->rebuild();
     $this->executeMigration('d7_shortcut_set');
     $this->executeMigration('menu');
-    $this->executeMigration('d7_menu_links');
+    $this->executeMigration('menu_links');
     $this->executeMigration('d7_shortcut');
   }
 
diff --git a/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetUsersTest.php b/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetUsersTest.php
index c6d4530f1..ed63ac031 100644
--- a/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetUsersTest.php
+++ b/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutSetUsersTest.php
@@ -38,11 +38,12 @@ class MigrateShortcutSetUsersTest extends MigrateDrupal7TestBase {
     $this->installEntitySchema('shortcut');
     $this->installEntitySchema('menu_link_content');
     $this->installSchema('shortcut', ['shortcut_set_users']);
+    \Drupal::service('router.builder')->rebuild();
     $this->executeMigration('d7_user_role');
     $this->executeMigration('d7_user');
     $this->executeMigration('d7_shortcut_set');
     $this->executeMigration('menu');
-    $this->executeMigration('d7_menu_links');
+    $this->executeMigration('menu_links');
     $this->executeMigration('d7_shortcut');
     $this->executeMigration('d7_shortcut_set_users');
   }
diff --git a/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutTest.php b/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutTest.php
index 8bf10ee09..0d333fe5b 100644
--- a/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutTest.php
+++ b/core/modules/shortcut/src/Tests/Migrate/d7/MigrateShortcutTest.php
@@ -38,9 +38,10 @@ class MigrateShortcutTest extends MigrateDrupal7TestBase {
     $this->installSchema('system', array('router'));
     $this->installEntitySchema('shortcut');
     $this->installEntitySchema('menu_link_content');
+    \Drupal::service('router.builder')->rebuild();
     $this->executeMigration('d7_shortcut_set');
     $this->executeMigration('menu');
-    $this->executeMigration('d7_menu_links');
+    $this->executeMigration('menu_links');
     $this->executeMigration('d7_shortcut');
   }
 
diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index e52b9b6b0..d034e3bfc 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -54,7 +54,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
       '/admin',
       '/admin/config/system/site-information',
       '/node/' . $this->node->id() . '/edit',
-      '/' . $path['alias'],
+      $path['alias'],
       '/router_test/test2',
       '/router_test/test3/value',
     ];
diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php
index ed64f0833..d93ed8b78 100644
--- a/core/modules/simpletest/src/BrowserTestBase.php
+++ b/core/modules/simpletest/src/BrowserTestBase.php
@@ -41,11 +41,6 @@ use Symfony\Component\HttpFoundation\Request;
  * Drupal\Tests\yourmodule\Functional namespace and live in the
  * modules/yourmodule/Tests/Functional directory.
  *
- * All BrowserTestBase tests must have two annotations to ensure process
- * isolation:
- * - @runTestsInSeparateProcesses
- * - @preserveGlobalState disabled
- *
  * @ingroup testing
  *
  * @see \Drupal\simpletest\WebTestBase
@@ -216,6 +211,19 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
    */
   protected $mink;
 
+  /**
+   * {@inheritdoc}
+   *
+   * Browser tests are run in separate processes to prevent collisions between
+   * code that may be loaded by tests.
+   */
+  protected $runTestInSeparateProcess = TRUE;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $preserveGlobalState = FALSE;
+
   /**
    * Initializes Mink sessions.
    */
@@ -291,7 +299,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
     // coverage against.
     $base_url = getenv('SIMPLETEST_BASE_URL');
     if (!$base_url) {
-      $this->markTestSkipped(
+      throw new \Exception(
         'You must provide a SIMPLETEST_BASE_URL environment variable to run some PHPUnit based functional tests.'
       );
     }
@@ -800,24 +808,6 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
     return $options;
   }
 
-  /**
-   * Override to use Mink exceptions.
-   *
-   * @return mixed
-   *   Either a test result or NULL.
-   *
-   * @throws \PHPUnit_Framework_AssertionFailedError
-   *   When exception was thrown inside the test.
-   */
-  protected function runTest() {
-    try {
-      return parent::runTest();
-    }
-    catch (Exception $e) {
-      throw new \PHPUnit_Framework_AssertionFailedError($e->getMessage());
-    }
-  }
-
   /**
    * Installs Drupal into the Simpletest site.
    */
@@ -1338,4 +1328,22 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
     return $logged_in;
   }
 
+  /**
+   * Prevents serializing any properties.
+   *
+   * Browser tests are run in a separate process. To do this PHPUnit creates a
+   * script to run the test. If it fails, the test result object will contain a
+   * stack trace which includes the test object. It will attempt to serialize
+   * it. Returning an empty array prevents it from serializing anything it
+   * should not.
+   *
+   * @return array
+   *   An empty array.
+   *
+   * @see vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist
+   */
+  public function __sleep() {
+    return [];
+  }
+
 }
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index 56c800e46..10463d9ad 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -485,6 +485,12 @@ EOD;
   /**
    * Enables modules for this test.
    *
+   * To install test modules outside of the testing environment, add
+   * @code
+   * $settings['extension_discovery_scan_tests'] = TRUE;
+   * @encode
+   * to your settings.php.
+   *
    * @param array $modules
    *   A list of modules to enable. Dependencies are not resolved; i.e.,
    *   multiple modules have to be specified with dependent modules first.
@@ -518,7 +524,8 @@ EOD;
     $module_filenames = $module_handler->getModuleList();
     $this->kernel->updateModules($module_filenames, $module_filenames);
 
-    // Ensure isLoaded() is TRUE in order to make _theme() work.
+    // Ensure isLoaded() is TRUE in order to make
+    // \Drupal\Core\Theme\ThemeManagerInterface::render() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $this->container->get('module_handler')->reload();
@@ -551,7 +558,8 @@ EOD;
     // Update the kernel to remove their services.
     $this->kernel->updateModules($module_filenames, $module_filenames);
 
-    // Ensure isLoaded() is TRUE in order to make _theme() work.
+    // Ensure isLoaded() is TRUE in order to make
+    // \Drupal\Core\Theme\ThemeManagerInterface::render() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $module_handler = $this->container->get('module_handler');
diff --git a/core/modules/simpletest/src/RouteProvider.php b/core/modules/simpletest/src/RouteProvider.php
new file mode 100644
index 000000000..acff99af5
--- /dev/null
+++ b/core/modules/simpletest/src/RouteProvider.php
@@ -0,0 +1,114 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\ProxyClass\Routing\RouteProvider.
+ */
+
+namespace Drupal\simpletest;
+
+use Drupal\Core\Routing\PreloadableRouteProviderInterface;
+use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Rebuilds the router when the provider is instantiated.
+ */
+class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
+
+  use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
+
+  /**
+   * Loads the real route provider from the container and rebuilds the router.
+   *
+   * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
+   *   The route provider.
+   */
+  protected function lazyLoadItself() {
+    if (!isset($this->service)) {
+      $container = \Drupal::getContainer();
+      $this->service = $container->get('simpletest.router.route_provider');
+      $container->get('router.builder')->rebuild();
+    }
+
+    return $this->service;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRouteCollectionForRequest(Request $request) {
+    return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRouteByName($name) {
+    return $this->lazyLoadItself()->getRouteByName($name);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function preLoadRoutes($names){
+    return $this->lazyLoadItself()->preLoadRoutes($names);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRoutesByNames($names) {
+    return $this->lazyLoadItself()->getRoutesByNames($names);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCandidateOutlines(array $parts) {
+    return $this->lazyLoadItself()->getCandidateOutlines($parts);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRoutesByPattern($pattern) {
+    return $this->lazyLoadItself()->getRoutesByPattern($pattern);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function routeProviderRouteCompare(array $a, array $b) {
+    return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getAllRoutes() {
+    return $this->lazyLoadItself()->getAllRoutes();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function reset() {
+    return $this->lazyLoadItself()->reset();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRoutesPaged($offset, $length = NULL) {
+    return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getRoutesCount() {
+    return $this->lazyLoadItself()->getRoutesCount();
+  }
+
+}
diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php
index 60ad26095..1cdc231c4 100644
--- a/core/modules/simpletest/src/TestBase.php
+++ b/core/modules/simpletest/src/TestBase.php
@@ -96,7 +96,7 @@ abstract class TestBase {
   /**
    * Incrementing identifier for verbose output filenames.
    *
-   * @var integer
+   * @var int
    */
   protected $verboseId = 0;
 
diff --git a/core/modules/simpletest/src/TestServiceProvider.php b/core/modules/simpletest/src/TestServiceProvider.php
index 64dedb8bb..5a1a398ab 100644
--- a/core/modules/simpletest/src/TestServiceProvider.php
+++ b/core/modules/simpletest/src/TestServiceProvider.php
@@ -8,9 +8,11 @@
 namespace Drupal\simpletest;
 
 use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\DependencyInjection\ServiceModifierInterface;
 use Drupal\Core\DependencyInjection\ServiceProviderInterface;
+use Symfony\Component\DependencyInjection\Definition;
 
-class TestServiceProvider implements ServiceProviderInterface {
+class TestServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
 
   /**
    * @var \Drupal\simpletest\TestBase;
@@ -25,4 +27,21 @@ class TestServiceProvider implements ServiceProviderInterface {
       static::$currentTest->containerBuild($container);
     }
   }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function alter(ContainerBuilder $container) {
+    if (static::$currentTest instanceof KernelTestBase) {
+      // While $container->get() does a recursive resolve, getDefinition() does
+      // not, so do it ourselves.
+      foreach (['router.route_provider' => 'RouteProvider'] as $original_id => $class) {
+        for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id));
+        $definition = $container->getDefinition($id);
+        $definition->clearTag('needs_destruction');
+        $container->setDefinition("simpletest.$original_id", $definition);
+        $container->setDefinition($id, new Definition('Drupal\simpletest\\' . $class));
+      }
+    }
+  }
 }
diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
index ae3742e90..2187cccb3 100644
--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
+++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
@@ -290,7 +290,7 @@ EOS;
   }
 
   /**
-   * Tests that _theme() works right after loading a module.
+   * Tests that ThemeManager works right after loading a module.
    */
   function testEnableModulesTheme() {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
@@ -301,7 +301,8 @@ EOS;
       '#attributes' => array(),
     );
     $this->enableModules(array('system'));
-    // _theme() throws an exception if modules are not loaded yet.
+    // \Drupal\Core\Theme\ThemeManager::render() throws an exception if modules
+    // are not loaded yet.
     $this->assertTrue($renderer->renderRoot($element));
 
     $element = $original_element;
diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
index 574da77d9..5c0114d08 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
@@ -24,7 +24,7 @@ class SimpleTestBrowserTest extends WebTestBase {
    */
   public static $modules = array('simpletest', 'test_page_test');
 
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     // Create and log in an admin user.
     $this->drupalLogin($this->drupalCreateUser(array('administer unit tests')));
diff --git a/core/modules/simpletest/src/UserCreationTrait.php b/core/modules/simpletest/src/UserCreationTrait.php
index 92262cf4d..9b308b916 100644
--- a/core/modules/simpletest/src/UserCreationTrait.php
+++ b/core/modules/simpletest/src/UserCreationTrait.php
@@ -92,7 +92,7 @@ trait UserCreationTrait {
    *   (optional) The role ID (machine name). Defaults to a random name.
    * @param string $name
    *   (optional) The label for the role. Defaults to a random string.
-   * @param integer $weight
+   * @param int $weight
    *   (optional) The weight for the role. Defaults NULL so that entity_create()
    *   sets the weight to maximum + 1.
    *
@@ -119,7 +119,7 @@ trait UserCreationTrait {
    *   (optional) The role ID (machine name). Defaults to a random name.
    * @param string $name
    *   (optional) The label for the role. Defaults to a random string.
-   * @param integer $weight
+   * @param int $weight
    *   (optional) The weight for the role. Defaults NULL so that entity_create()
    *   sets the weight to maximum + 1.
    *
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 1e3bfdb08..3ad7d56b9 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -1010,6 +1010,12 @@ abstract class WebTestBase extends TestBase {
   /**
    * Install modules defined by `static::$modules`.
    *
+   * To install test modules outside of the testing environment, add
+   * @code
+   * $settings['extension_discovery_scan_tests'] = TRUE;
+   * @encode
+   * to your settings.php.
+   *
    * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
    *   The container.
    */
diff --git a/core/modules/simpletest/tests/fixtures/simpletest_phpunit_run_command_test.php b/core/modules/simpletest/tests/fixtures/simpletest_phpunit_run_command_test.php
index 872753e84..c86a9e619 100644
--- a/core/modules/simpletest/tests/fixtures/simpletest_phpunit_run_command_test.php
+++ b/core/modules/simpletest/tests/fixtures/simpletest_phpunit_run_command_test.php
@@ -17,6 +17,7 @@ class SimpletestPhpunitRunCommandTestWillDie extends UnitTestCase {
     if (getenv('SimpletestPhpunitRunCommandTestWillDie') === 'fail') {
       exit(2);
     }
+    $this->assertTrue(TRUE, 'Assertion to ensure test pass');
   }
 }
 
diff --git a/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
index 48865e1e3..c082d0372 100644
--- a/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
@@ -13,9 +13,6 @@ use Drupal\simpletest\BrowserTestBase;
  * Tests BrowserTestBase functionality.
  *
  * @group simpletest
- *
- * @runTestsInSeparateProcesses
- * @preserveGlobalState disabled
  */
 class BrowserTestBaseTest extends BrowserTestBase {
 
diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php
index d54cd9141..7d64b5f4b 100644
--- a/core/modules/system/src/Controller/ThemeController.php
+++ b/core/modules/system/src/Controller/ThemeController.php
@@ -37,7 +37,7 @@ class ThemeController extends ControllerBase {
    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    *   The config factory.
    */
-  public function __construct(ThemeHandlerInterface $theme_handler,ConfigFactoryInterface $config_factory) {
+  public function __construct(ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory) {
     $this->themeHandler = $theme_handler;
     $this->configFactory = $config_factory;
   }
diff --git a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
index 69e32396d..991832259 100644
--- a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
+++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php
@@ -148,7 +148,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
     );
 
     // List the dependent entities.
-    $this->addDependencyListsToForm($form, 'module', $this->modules ,$this->configManager, $this->entityManager);
+    $this->addDependencyListsToForm($form, 'module', $this->modules , $this->configManager, $this->entityManager);
 
     return parent::buildForm($form, $form_state);
   }
diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php
index 7f02517d0..82ad415f7 100644
--- a/core/modules/system/src/Form/ThemeSettingsForm.php
+++ b/core/modules/system/src/Form/ThemeSettingsForm.php
@@ -178,17 +178,11 @@ class ThemeSettingsForm extends ConfigFormBase {
     }
 
     // Logo settings, only available when file.module is enabled.
-    if ((!$theme) || in_array('logo', $features) && $this->moduleHandler->moduleExists('file')) {
+    if ((!$theme || in_array('logo', $features)) && $this->moduleHandler->moduleExists('file')) {
       $form['logo'] = array(
         '#type' => 'details',
         '#title' => t('Logo image settings'),
         '#open' => TRUE,
-        '#states' => array(
-          // Hide the logo image settings fieldset when logo display is disabled.
-          'invisible' => array(
-            'input[name="toggle_logo"]' => array('checked' => FALSE),
-          ),
-        ),
       );
       $form['logo']['default_logo'] = array(
         '#type' => 'checkbox',
@@ -430,7 +424,6 @@ class ThemeSettingsForm extends ConfigFormBase {
       $filename = file_unmanaged_copy($values['logo_upload']->getFileUri());
       $values['default_logo'] = 0;
       $values['logo_path'] = $filename;
-      $values['toggle_logo'] = 1;
     }
     if (!empty($values['favicon_upload'])) {
       $filename = file_unmanaged_copy($values['favicon_upload']->getFileUri());
diff --git a/core/modules/system/src/Tests/Ajax/AjaxFormPageCacheTest.php b/core/modules/system/src/Tests/Ajax/AjaxFormPageCacheTest.php
index 41132638b..b38ef2901 100644
--- a/core/modules/system/src/Tests/Ajax/AjaxFormPageCacheTest.php
+++ b/core/modules/system/src/Tests/Ajax/AjaxFormPageCacheTest.php
@@ -17,7 +17,7 @@ class AjaxFormPageCacheTest extends AjaxTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $config = $this->config('system.performance');
diff --git a/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
index 7cdd8750a..8d9022a97 100644
--- a/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
+++ b/core/modules/system/src/Tests/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
@@ -91,7 +91,7 @@ class ResolvedLibraryDefinitionsFilesMatchTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->themeHandler = $this->container->get('theme_handler');
diff --git a/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php b/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
index fafac7ed4..9cc39761e 100644
--- a/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
+++ b/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Cache;
 
+use Drupal\Core\Cache\Apcu4Backend;
 use Drupal\Core\Cache\ApcuBackend;
 
 /**
@@ -21,7 +22,7 @@ class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
    * Get a list of failed requirements.
    *
    * This specifically bypasses checkRequirements because it fails tests. PHP 7
-   * does not have APC and simpletest does not have a explicit "skip"
+   * does not have APCu and simpletest does not have a explicit "skip"
    * functionality so to emulate it we override all test methods and explicitly
    * pass when  requirements are not met.
    *
@@ -29,13 +30,10 @@ class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
    */
   protected function getRequirements() {
     $requirements = [];
-    if (!extension_loaded('apc')) {
-      $requirements[] = 'APC extension not found.';
+    if (!extension_loaded('apcu')) {
+      $requirements[] = 'APCu extension not found.';
     }
     else {
-      if (version_compare(phpversion('apc'), '3.1.1', '<')) {
-        $requirements[] = 'APC extension must be newer than 3.1.1 for APCIterator support.';
-      }
       if (PHP_SAPI === 'cli' && !ini_get('apc.enable_cli')) {
         $requirements[] = 'apc.enable_cli must be enabled to run this test.';
       }
@@ -66,7 +64,12 @@ class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
    * {@inheritdoc}
    */
   protected function createCacheBackend($bin) {
-    return new ApcuBackend($bin, $this->databasePrefix, \Drupal::service('cache_tags.invalidator.checksum'));
+    if (version_compare(phpversion('apcu'), '5.0.0', '>=')) {
+      return new ApcuBackend($bin, $this->databasePrefix, \Drupal::service('cache_tags.invalidator.checksum'));
+    }
+    else {
+      return new Apcu4Backend($bin, $this->databasePrefix, \Drupal::service('cache_tags.invalidator.checksum'));
+    }
   }
 
   /**
@@ -91,7 +94,15 @@ class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
     // Make sure entries are permanent (i.e. no TTL).
     $backend = $this->getCacheBackend($this->getTestBin());
     $key = $backend->getApcuKey('TEST8');
-    foreach (new \APCIterator('user', '/^' . $key . '/') as $item) {
+
+    if (class_exists('\APCUIterator')) {
+      $iterator = new \APCUIterator('/^' . $key . '/');
+    }
+    else {
+      $iterator = new \APCIterator('user', '/^' . $key . '/');
+    }
+
+    foreach ($iterator as $item) {
       $this->assertEqual(0, $item['ttl']);
       $found = TRUE;
     }
diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
index 742bd464d..f18c01340 100644
--- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
+++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
@@ -268,7 +268,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
       'test3' => '',
       'test4' => 12.64,
       'test5' => FALSE,
-      'test6' => array(1,2,3),
+      'test6' => array(1, 2, 3),
     );
 
     // Create cache entries.
diff --git a/core/modules/system/src/Tests/Database/ConnectionUnitTest.php b/core/modules/system/src/Tests/Database/ConnectionUnitTest.php
index 4327ac5e0..d1916b32c 100644
--- a/core/modules/system/src/Tests/Database/ConnectionUnitTest.php
+++ b/core/modules/system/src/Tests/Database/ConnectionUnitTest.php
@@ -66,7 +66,7 @@ class ConnectionUnitTest extends KernelTestBase {
   /**
    * Returns the connection ID of the current test connection.
    *
-   * @return integer
+   * @return int
    */
   protected function getConnectionID() {
     return (int) Database::getConnection($this->target, $this->key)->query('SELECT CONNECTION_ID()')->fetchField();
@@ -75,7 +75,7 @@ class ConnectionUnitTest extends KernelTestBase {
   /**
    * Asserts that a connection ID exists.
    *
-   * @param integer $id
+   * @param int $id
    *   The connection ID to verify.
    */
   protected function assertConnection($id) {
@@ -86,7 +86,7 @@ class ConnectionUnitTest extends KernelTestBase {
   /**
    * Asserts that a connection ID does not exist.
    *
-   * @param integer $id
+   * @param int $id
    *   The connection ID to verify.
    */
   protected function assertNoConnection($id) {
diff --git a/core/modules/system/src/Tests/Database/InsertTest.php b/core/modules/system/src/Tests/Database/InsertTest.php
index 4b2e1e464..f021ff5eb 100644
--- a/core/modules/system/src/Tests/Database/InsertTest.php
+++ b/core/modules/system/src/Tests/Database/InsertTest.php
@@ -145,7 +145,7 @@ class InsertTest extends DatabaseTestBase {
     // re-ordered.
     $query->addExpression('tp.age', 'age');
     $query
-      ->fields('tp', array('name','job'))
+      ->fields('tp', array('name', 'job'))
       ->condition('tp.name', 'Meredith');
 
     // The resulting query should be equivalent to:
diff --git a/core/modules/system/src/Tests/Database/SchemaTest.php b/core/modules/system/src/Tests/Database/SchemaTest.php
index e6aea7481..716a6a16e 100644
--- a/core/modules/system/src/Tests/Database/SchemaTest.php
+++ b/core/modules/system/src/Tests/Database/SchemaTest.php
@@ -644,7 +644,7 @@ class SchemaTest extends KernelTestBase {
    */
   function testSchemaChangeField() {
     $field_specs = array(
-      array('type' => 'int', 'size' => 'normal','not null' => FALSE),
+      array('type' => 'int', 'size' => 'normal', 'not null' => FALSE),
       array('type' => 'int', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 17),
       array('type' => 'float', 'size' => 'normal', 'not null' => FALSE),
       array('type' => 'float', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 7.3),
diff --git a/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php b/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php
index 564245b67..94c9b12bf 100644
--- a/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php
+++ b/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php
@@ -40,7 +40,7 @@ class ContentEntityChangedTest extends EntityUnitTestBase {
   protected $mulRevChangedStorage;
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   protected function setUp() {
     parent::setUp();
diff --git a/core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php b/core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php
index 376b02e60..3eeee3bce 100644
--- a/core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php
+++ b/core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php
@@ -27,7 +27,7 @@ class ContentEntityNullStorageTest extends KernelTestBase {
    *
    * @var array
    */
-  public static $modules = array('system',  'contact', 'user');
+  public static $modules = array('system', 'contact', 'user');
 
   /**
    * Tests using entity query with ContentEntityNullStorage.
diff --git a/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php b/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php
index ab73ee12a..38334766a 100644
--- a/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\system\Tests\Entity;
 
+use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Access\AccessibleInterface;
 use Drupal\Core\Entity\EntityAccessControlHandler;
@@ -155,6 +156,10 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase  {
     // Test hook_entity_create_access() and hook_ENTITY_TYPE_create_access().
     $entity->access('create');
     $this->assertEqual($state->get('entity_test_entity_create_access'), TRUE);
+    $this->assertIdentical($state->get('entity_test_entity_create_access_context'), [
+      'entity_type_id' => 'entity_test',
+      'langcode' => LanguageInterface::LANGCODE_DEFAULT,
+    ]);
     $this->assertEqual($state->get('entity_test_entity_test_create_access'), TRUE);
 
     // Test hook_entity_access() and hook_ENTITY_TYPE_access().
diff --git a/core/modules/system/src/Tests/Entity/EntityApiTest.php b/core/modules/system/src/Tests/Entity/EntityApiTest.php
index 617687073..e8153ce60 100644
--- a/core/modules/system/src/Tests/Entity/EntityApiTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityApiTest.php
@@ -18,7 +18,7 @@ use Drupal\user\UserInterface;
 class EntityApiTest extends EntityUnitTestBase {
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   protected function setUp() {
     parent::setUp();
diff --git a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php
index 47b10ba14..08395ff57 100644
--- a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php
+++ b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php
@@ -26,7 +26,7 @@ class EntitySchemaTest extends EntityUnitTestBase  {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->installSchema('user', array('users_data'));
     $this->installSchema('system', array('router'));
diff --git a/core/modules/system/src/Tests/Entity/Update/UpdateApiEntityDefinitionUpdateTest.php b/core/modules/system/src/Tests/Entity/Update/UpdateApiEntityDefinitionUpdateTest.php
index f8ada0882..fcfff4aa2 100644
--- a/core/modules/system/src/Tests/Entity/Update/UpdateApiEntityDefinitionUpdateTest.php
+++ b/core/modules/system/src/Tests/Entity/Update/UpdateApiEntityDefinitionUpdateTest.php
@@ -44,7 +44,7 @@ class UpdateApiEntityDefinitionUpdateTest extends WebTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->entityManager = $this->container->get('entity.manager');
@@ -60,7 +60,7 @@ class UpdateApiEntityDefinitionUpdateTest extends WebTestBase {
   public function testSingleUpdates() {
     // Create a test entity.
     $user_ids = [mt_rand(), mt_rand()];
-    $entity = EntityTest::create(['name' => $this->randomString(),  'user_id' => $user_ids]);
+    $entity = EntityTest::create(['name' => $this->randomString(), 'user_id' => $user_ids]);
     $entity->save();
 
     // Check that only a single value is stored for 'user_id'.
@@ -108,7 +108,7 @@ class UpdateApiEntityDefinitionUpdateTest extends WebTestBase {
   public function testMultipleUpdates() {
     // Create a test entity.
     $user_ids = [mt_rand(), mt_rand()];
-    $entity = EntityTest::create(['name' => $this->randomString(),  'user_id' => $user_ids]);
+    $entity = EntityTest::create(['name' => $this->randomString(), 'user_id' => $user_ids]);
     $entity->save();
 
     // Check that only a single value is stored for 'user_id'.
@@ -138,7 +138,7 @@ class UpdateApiEntityDefinitionUpdateTest extends WebTestBase {
    */
   function testStatusReport() {
     // Create a test entity.
-    $entity = EntityTest::create(['name' => $this->randomString(),  'user_id' => mt_rand()]);
+    $entity = EntityTest::create(['name' => $this->randomString(), 'user_id' => mt_rand()]);
     $entity->save();
 
     // Check that the status report initially displays no error.
diff --git a/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
index ef3818962..69a7acb70 100644
--- a/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
+++ b/core/modules/system/src/Tests/Entity/ValidReferenceConstraintValidatorTest.php
@@ -30,9 +30,9 @@ class ValidReferenceConstraintValidatorTest extends EntityUnitTestBase {
   public static $modules = array('field', 'user');
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->installSchema('user', array('users_data'));
     $this->typedData = $this->container->get('typed_data_manager');
diff --git a/core/modules/system/src/Tests/File/HtaccessUnitTest.php b/core/modules/system/src/Tests/File/HtaccessUnitTest.php
index 9f5273c25..4b7f39d11 100644
--- a/core/modules/system/src/Tests/File/HtaccessUnitTest.php
+++ b/core/modules/system/src/Tests/File/HtaccessUnitTest.php
@@ -63,10 +63,10 @@ class HtaccessUnitTest extends KernelTestBase {
     mkdir($stream, 0777, TRUE);
     $this->assertTrue(file_save_htaccess($stream));
     $content = file_get_contents($stream . '/.htaccess');
-    $this->assertTrue(strpos($content,"SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006") !== FALSE);
+    $this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006") !== FALSE);
     $this->assertTrue(strpos($content, "Require all denied") !== FALSE);
-    $this->assertTrue(strpos($content,"Deny from all") !== FALSE);
-    $this->assertTrue(strpos($content,"Options -Indexes -ExecCGI -Includes -MultiViews") !== FALSE);
+    $this->assertTrue(strpos($content, "Deny from all") !== FALSE);
+    $this->assertTrue(strpos($content, "Options -Indexes -ExecCGI -Includes -MultiViews") !== FALSE);
     $this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003") !== FALSE);
     $this->assertFilePermissions($stream . '/.htaccess', 0444);
 
diff --git a/core/modules/system/src/Tests/Render/Element/TableTest.php b/core/modules/system/src/Tests/Render/Element/TableTest.php
index 725f339b6..7d94cd916 100644
--- a/core/modules/system/src/Tests/Render/Element/TableTest.php
+++ b/core/modules/system/src/Tests/Render/Element/TableTest.php
@@ -38,7 +38,7 @@ class TableTest extends KernelTestBase {
    */
   function testThemeTableStickyHeaders() {
     $header = array('one', 'two', 'three');
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+    $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
     $table = array(
       '#type' => 'table',
       '#header' => $header,
@@ -57,7 +57,7 @@ class TableTest extends KernelTestBase {
    */
   function testThemeTableNoStickyHeaders() {
     $header = array('one', 'two', 'three');
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+    $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
     $attributes = array();
     $caption = NULL;
     $colgroups = array();
@@ -172,7 +172,7 @@ class TableTest extends KernelTestBase {
    */
   public function testThemeTableResponsive() {
     $header = array('one', 'two', 'three');
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+    $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
     $table = array(
       '#type' => 'table',
       '#header' => $header,
@@ -187,7 +187,7 @@ class TableTest extends KernelTestBase {
    * Tests that the 'responsive-table' class is not applied without headers.
    */
   public function testThemeTableNotResponsiveHeaders() {
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+    $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
     $table = array(
       '#type' => 'table',
       '#rows' => $rows,
@@ -202,7 +202,7 @@ class TableTest extends KernelTestBase {
    */
   public function testThemeTableNotResponsiveProperty() {
     $header = array('one', 'two', 'three');
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+    $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
     $table = array(
       '#type' => 'table',
       '#header' => $header,
@@ -260,7 +260,7 @@ class TableTest extends KernelTestBase {
         ),
       ),
     );
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
+    $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
     $table = array(
       '#type' => 'table',
       '#header' => $header,
diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php
index 278353db5..5a079ec18 100644
--- a/core/modules/system/src/Tests/System/ThemeTest.php
+++ b/core/modules/system/src/Tests/System/ThemeTest.php
@@ -189,10 +189,6 @@ class ThemeTest extends WebTestBase {
     $this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename));
 
     $this->container->get('theme_handler')->install(array('bartik'));
-    $this->drupalGet('admin/appearance/settings/bartik');
-    // The logo field should only be present on the global theme settings form.
-    $this->assertNoFieldByName('logo_path');
-    $this->drupalPostForm(NULL, [], t('Save configuration'));
 
     // Ensure only valid themes are listed in the local tasks.
     $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']);
@@ -212,6 +208,29 @@ class ThemeTest extends WebTestBase {
     $this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.');
   }
 
+  /**
+   * Test the theme settings logo form.
+   */
+  function testThemeSettingsLogo() {
+    // Visit Bartik's theme settings page to replace the logo.
+    $this->container->get('theme_handler')->install(['bartik']);
+    $this->drupalGet('admin/appearance/settings/bartik');
+    $edit = [
+      'default_logo' => FALSE,
+      'logo_path' => 'core/misc/druplicon.png',
+    ];
+    $this->drupalPostForm('admin/appearance/settings/bartik', $edit, t('Save configuration'));
+    $this->assertFieldByName('default_logo', FALSE);
+    $this->assertFieldByName('logo_path', 'core/misc/druplicon.png');
+
+    // Make sure the logo and favicon settings are not available when the file
+    // module is not enabled.
+    \Drupal::service('module_installer')->uninstall(['file']);
+    $this->drupalGet('admin/appearance/settings');
+    $this->assertNoText('Logo image settings');
+    $this->assertNoText('Shortcut icon settings');
+  }
+
   /**
    * Test the administration theme functionality.
    */
diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
index cbffff75d..b8ac4f31c 100644
--- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
+++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php
@@ -21,7 +21,7 @@ use Drupal\Core\Render\BubbleableMetadata;
 class TokenReplaceUnitTest extends TokenReplaceUnitTestBase {
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   protected function setUp() {
     parent::setUp();
diff --git a/core/modules/system/src/Tests/Theme/StableLibraryOverrideTest.php b/core/modules/system/src/Tests/Theme/StableLibraryOverrideTest.php
index 526be51c1..a52895427 100644
--- a/core/modules/system/src/Tests/Theme/StableLibraryOverrideTest.php
+++ b/core/modules/system/src/Tests/Theme/StableLibraryOverrideTest.php
@@ -54,7 +54,7 @@ class StableLibraryOverrideTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->themeManager = $this->container->get('theme.manager');
diff --git a/core/modules/system/src/Tests/Theme/StableThemeTest.php b/core/modules/system/src/Tests/Theme/StableThemeTest.php
index 06866b5c4..1f898ba7b 100644
--- a/core/modules/system/src/Tests/Theme/StableThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/StableThemeTest.php
@@ -40,7 +40,7 @@ class StableThemeTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->themeHandler = $this->container->get('theme_handler');
diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php
index 28d473862..a84ef8fec 100644
--- a/core/modules/system/src/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/ThemeTest.php
@@ -40,7 +40,7 @@ class ThemeTest extends WebTestBase {
    * Render arrays that use a render element and templates (and hence call
    * template_preprocess()) must ensure the attributes at different occasions
    * are all merged correctly:
-   *   - $variables['attributes'] as passed in to _theme()
+   *   - $variables['attributes'] as passed in to the theme hook implementation.
    *   - the render element's #attributes
    *   - any attributes set in the template's preprocessing function
    */
@@ -57,7 +57,7 @@ class ThemeTest extends WebTestBase {
   }
 
   /**
-   * Test that _theme() returns expected data types.
+   * Test that ThemeManager renders the expected data types.
    */
   function testThemeDataTypes() {
     // theme_test_false is an implemented theme hook so \Drupal::theme() service
diff --git a/core/modules/system/src/Tests/Update/DbDumpTest.php b/core/modules/system/src/Tests/Update/DbDumpTest.php
index e04bb0502..7cd099b95 100644
--- a/core/modules/system/src/Tests/Update/DbDumpTest.php
+++ b/core/modules/system/src/Tests/Update/DbDumpTest.php
@@ -81,7 +81,7 @@ class DbDumpTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Determine what database backend is running, and set the skip flag.
diff --git a/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php b/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php
index 0665f40ac..09362dad8 100644
--- a/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php
+++ b/core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php
@@ -31,7 +31,7 @@ class LocalActionsAndTasksConvertedIntoBlocksUpdateTest extends UpdatePathTestBa
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
     $theme_handler = \Drupal::service('theme_handler');
diff --git a/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php b/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php
index 79086b34d..e9a9041aa 100644
--- a/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php
+++ b/core/modules/system/src/Tests/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php
@@ -29,7 +29,7 @@ class SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest extends UpdatePathTes
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
     $theme_handler = \Drupal::service('theme_handler');
diff --git a/core/modules/system/src/Tests/Update/UpdateSchemaTest.php b/core/modules/system/src/Tests/Update/UpdateSchemaTest.php
index d92809589..4a8ae6aed 100644
--- a/core/modules/system/src/Tests/Update/UpdateSchemaTest.php
+++ b/core/modules/system/src/Tests/Update/UpdateSchemaTest.php
@@ -37,7 +37,7 @@ class UpdateSchemaTest extends WebTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     require_once \Drupal::root() . '/core/includes/update.inc';
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index d3b55f9da..ae6142f32 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1062,10 +1062,13 @@ function system_rebuild_module_data() {
 
 /**
  * Returns an array of default theme features.
+ *
+ * @see \Drupal\Core\Extension\ThemeHandler::$defaultFeatures
  */
 function _system_default_theme_features() {
   return array(
     'favicon',
+    'logo',
     'node_user_picture',
     'comment_user_picture',
     'comment_user_verification',
@@ -1163,9 +1166,9 @@ function system_default_region($theme) {
  * for the user by \Drupal\system\Controller\SystemController::compactPage().
  *
  * If the user does not have the cookie, the default value is given by the
- * system variable 'admin_compact_mode', which itself defaults to FALSE. This
- * does not have a user interface to set it: it is a hidden variable which can
- * be set in the settings.php file.
+ * configuration variable 'system.site.admin_compact_mode', which itself
+ * defaults to FALSE. This does not have a user interface to set it: it is a
+ * hidden variable which can be set in the settings.php file.
  *
  * @return bool
  *   TRUE when in compact mode, FALSE when in expanded mode.
diff --git a/core/modules/system/templates/container.html.twig b/core/modules/system/templates/container.html.twig
index b03cc8be1..6cb299bfc 100644
--- a/core/modules/system/templates/container.html.twig
+++ b/core/modules/system/templates/container.html.twig
@@ -5,8 +5,10 @@
  *
  * Used for grouped form items. Can also be used as a theme wrapper for any
  * renderable element, to surround it with a <div> and HTML attributes.
- * See the @link forms_api_reference.html Form API reference @endlink for more
- * information on the #theme_wrappers render array property.
+ * See \Drupal\Core\Render\Element\RenderElement for more
+ * information on the #theme_wrappers render array property, and
+ * \Drupal\Core\Render\Element\container for usage of the container render
+ * element.
  *
  * Available variables:
  * - attributes: HTML attributes for the containing element.
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index e172576f6..59e44b699 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -656,6 +656,7 @@ function entity_test_entity_test_access(EntityInterface $entity, $operation, Acc
  */
 function entity_test_entity_create_access(AccountInterface $account, $context, $entity_bundle) {
   \Drupal::state()->set('entity_test_entity_create_access', TRUE);
+  \Drupal::state()->set('entity_test_entity_create_access_context', $context);
 
   // No opinion.
   return AccessResult::neutral();
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalActionTest.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalActionTest.php
index 729519a50..8dc639248 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalActionTest.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalActionTest.php
@@ -17,7 +17,7 @@ use Drupal\Component\Plugin\Derivative\DeriverBase;
 class LocalActionTest extends DeriverBase {
 
   /**
-   * @inheritDoc
+   * {@inheritdoc}
    */
   public function getDerivativeDefinitions($base_plugin_definition) {
     $this->derivatives['example'] = $base_plugin_definition + [
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTestWithUnsafeTitle.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTestWithUnsafeTitle.php
index af6ff917e..b8edba796 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTestWithUnsafeTitle.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Derivative/LocalTaskTestWithUnsafeTitle.php
@@ -17,7 +17,7 @@ use Drupal\Component\Plugin\Derivative\DeriverBase;
 class LocalTaskTestWithUnsafeTitle extends DeriverBase {
 
   /**
-   * @inheritDoc
+   * {@inheritdoc}
    */
   public function getDerivativeDefinitions($base_plugin_definition) {
     $this->derivatives['unsafe'] = [
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTaskWithUserInput.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTaskWithUserInput.php
index 6ef610220..aea3256af 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTaskWithUserInput.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTaskWithUserInput.php
@@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
 class TestTaskWithUserInput extends LocalTaskDefault {
 
   /**
-   * @inheritDoc
+   * {@inheritdoc}
    */
   public function getTitle(Request $request = NULL) {
     return "<script>alert('Welcome to the jungle!')</script>";
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php
index 7ca628fc0..8c12a666d 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlock.php
@@ -24,7 +24,7 @@ class MockMenuBlock {
   /**
    * The number of menu levels deep to render.
    *
-   * @var integer
+   * @var int
    */
   protected $depth;
 
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module
index 8a8841e5d..f64da1ea6 100644
--- a/core/modules/system/tests/modules/theme_test/theme_test.module
+++ b/core/modules/system/tests/modules/theme_test/theme_test.module
@@ -88,14 +88,14 @@ function template_preprocess_theme_test_function_suggestions(&$variables) {
 }
 
 /**
- * Theme function for testing _theme('theme_test_foo').
+ * Theme function for hook theme_test_foo.
  */
 function theme_theme_test_foo($variables) {
   return $variables['foo'];
 }
 
 /**
- * Theme function for testing _theme('theme_test_function_template_override').
+ * Theme function for hook theme_test_function_template_override.
  */
 function theme_theme_test_function_template_override($variables) {
   return 'theme_test_function_template_override test failed.';
@@ -140,7 +140,8 @@ function template_preprocess_theme_test_render_element(&$variables) {
  *
  * Theme hooks defining a 'render element' add an internal '#render_children'
  * property. When this property is found, drupal_render() avoids calling
- * _theme() on the top-level element to prevent infinite recursion.
+ * the 'theme.manager' service 'render' method on the top-level element to
+ * prevent infinite recursion.
  *
  * @param array $variables
  *   An associative array containing:
diff --git a/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php b/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php
index 3f6c76844..c0ce87c55 100644
--- a/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php
+++ b/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php
@@ -27,7 +27,7 @@ class DbDumpCommandTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Determine what database backend is running, and set the skip flag.
diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php
index c8cc1c0e9..5d6ae1d6a 100644
--- a/core/modules/taxonomy/src/Entity/Vocabulary.php
+++ b/core/modules/taxonomy/src/Entity/Vocabulary.php
@@ -82,14 +82,14 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
    * - TAXONOMY_HIERARCHY_SINGLE: Single parent.
    * - TAXONOMY_HIERARCHY_MULTIPLE: Multiple parents.
    *
-   * @var integer
+   * @var int
    */
   protected $hierarchy = TAXONOMY_HIERARCHY_DISABLED;
 
   /**
    * The weight of this vocabulary in relation to other vocabularies.
    *
-   * @var integer
+   * @var int
    */
   protected $weight = 0;
 
diff --git a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
index 9420d955d..995a6f6cd 100644
--- a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
+++ b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
@@ -73,7 +73,7 @@ class TermSelection extends DefaultSelection {
       if ($vocabulary = Vocabulary::load($bundle)) {
         if ($terms = $this->entityManager->getStorage('taxonomy_term')->loadTree($vocabulary->id(), 0, NULL, TRUE)) {
           foreach ($terms as $term) {
-            $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($term->getName());
+            $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . Html::escape($this->entityManager->getTranslationFromContext($term)->label());
           }
         }
       }
diff --git a/core/modules/taxonomy/src/Plugin/migrate/builder/d6/TermNode.php b/core/modules/taxonomy/src/Plugin/migrate/builder/d6/TermNode.php
index 36458acde..d64ee2311 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/builder/d6/TermNode.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/builder/d6/TermNode.php
@@ -11,7 +11,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\migrate\Entity\Migration;
 use Drupal\migrate\MigrateExecutable;
 use Drupal\migrate\MigrateMessage;
-use Drupal\migrate\MigrateTemplateStorage;
+use Drupal\migrate\MigrateTemplateStorageInterface;
 use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -36,10 +36,10 @@ class TermNode extends BuilderBase implements ContainerFactoryPluginInterface {
    *   The plugin ID.
    * @param mixed $plugin_definition
    *   The plugin definition.
-   * @param \Drupal\migrate\MigrateTemplateStorage $template_storage
+   * @param \Drupal\migrate\MigrateTemplateStorageInterface $template_storage
    *   The migration template storage handler.
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateTemplateStorage $template_storage) {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateTemplateStorageInterface $template_storage) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->templateStorage = $template_storage;
   }
diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php b/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
index 368c81976..4a69ba6e5 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
@@ -47,7 +47,7 @@ class Vocabulary extends DrupalSqlBase {
       'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
       'module' => $this->t('Module responsible for the vocabulary.'),
       'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
-      'machine_name' => $this->t('Unique achine name of the vocabulary.')
+      'machine_name' => $this->t('Unique machine name of the vocabulary.')
     );
   }
 
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
index 690ec6d76..c660d20ff 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -89,7 +89,12 @@ class TaxonomyIndexTid extends ManyToOne {
 
   public function hasExtraOptions() { return TRUE; }
 
-  public function getValueOptions() { /* don't overwrite the value options */ }
+  /**
+   * {@inheritdoc}
+   */
+  public function getValueOptions() {
+    return $this->valueOptions;
+  }
 
   protected function defineOptions() {
     $options = parent::defineOptions();
@@ -253,6 +258,9 @@ class TaxonomyIndexTid extends ManyToOne {
     if (!$form_state->get('exposed')) {
       // Retain the helper option
       $this->helper->buildOptionsForm($form, $form_state);
+
+      // Show help text if not exposed to end users.
+      $form['value']['#description'] = t('Leave blank for all. Otherwise, the first selected term will be the default instead of "Any".');
     }
   }
 
diff --git a/core/modules/taxonomy/src/Tests/TermCacheTagsTest.php b/core/modules/taxonomy/src/Tests/TermCacheTagsTest.php
index 5acaf7fce..23bcef107 100644
--- a/core/modules/taxonomy/src/Tests/TermCacheTagsTest.php
+++ b/core/modules/taxonomy/src/Tests/TermCacheTagsTest.php
@@ -26,7 +26,7 @@ class TermCacheTagsTest extends EntityWithUriCacheTagsTestBase {
    */
   protected function createEntity() {
     // Create a "Camelids" vocabulary.
-    $vocabulary = entity_create('taxonomy_vocabulary',  array(
+    $vocabulary = entity_create('taxonomy_vocabulary', array(
       'name' => 'Camelids',
       'vid' => 'camelids',
     ));
diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php
index 4bf221f1a..71657224f 100644
--- a/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTest.php
@@ -551,4 +551,38 @@ class TermTest extends TaxonomyTestBase {
     $this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
   }
 
+  /**
+   * Check the breadcrumb on edit and delete a term page.
+   */
+  public function testTermBreadcrumbs() {
+    $edit = [
+      'name[0][value]' => $this->randomMachineName(14),
+      'description[0][value]' => $this->randomMachineName(100),
+      'parent[]' => [0],
+    ];
+
+    // Create the term.
+    $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
+
+    $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
+    $term = reset($terms);
+    $this->assertNotNull($term, 'Term found in database.');
+
+    // Check the breadcrumb on the term edit page.
+    $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
+    $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a');
+    $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.');
+    $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home');
+    $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term edit page.');
+    $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.');
+
+    // Check the breadcrumb on the term delete page.
+    $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
+    $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a');
+    $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.');
+    $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home');
+    $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term delete page.');
+    $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.');
+  }
+
 }
diff --git a/core/modules/taxonomy/src/Tests/TermTranslationBreadcrumbTest.php b/core/modules/taxonomy/src/Tests/TermTranslationTest.php
similarity index 77%
rename from core/modules/taxonomy/src/Tests/TermTranslationBreadcrumbTest.php
rename to core/modules/taxonomy/src/Tests/TermTranslationTest.php
index 0da68162a..13b957782 100644
--- a/core/modules/taxonomy/src/Tests/TermTranslationBreadcrumbTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTranslationTest.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Contains \Drupal\taxonomy\Tests\TermTranslationBreadcrumbTest.
+ * Contains \Drupal\taxonomy\Tests\TermTranslationTest.
  */
 
 namespace Drupal\taxonomy\Tests;
@@ -15,7 +15,7 @@ use Drupal\system\Tests\Menu\AssertBreadcrumbTrait;
  *
  * @group taxonomy
  */
-class TermTranslationBreadcrumbTest extends TaxonomyTestBase {
+class TermTranslationTest extends TaxonomyTestBase {
 
   use AssertBreadcrumbTrait;
   use TaxonomyTranslationTestTrait;
@@ -86,6 +86,34 @@ class TermTranslationBreadcrumbTest extends TaxonomyTestBase {
     $term = $this->getLeafTerm();
     $translated = $term->getTranslation($this->translateToLangcode);
     $this->assertBreadcrumb($translated->urlInfo('canonical', ['language' => $languages[$this->translateToLangcode]]), $breadcrumb, $translated->label());
+
+  }
+
+  /**
+   * Test translation of terms are showed in the node.
+   */
+  protected function testTermsTranslation() {
+
+    // Set the display of the term reference field on the article content type
+    // to "Check boxes/radio buttons".
+    entity_get_form_display('node', 'article', 'default')
+      ->setComponent($this->termFieldName, array(
+        'type' => 'options_buttons',
+      ))
+      ->save();
+    $this->drupalLogin($this->drupalCreateUser(['create article content']));
+
+    // Test terms are listed.
+    $this->drupalget('node/add/article');
+    $this->assertText('one');
+    $this->assertText('two');
+    $this->assertText('three');
+
+    // Test terms translated are listed.
+    $this->drupalget('hu/node/add/article');
+    $this->assertText('translatedOne');
+    $this->assertText('translatedTwo');
+    $this->assertText('translatedThree');
   }
 
   /**
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
index d58b2d5a7..5dec79626 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
@@ -61,7 +61,7 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
     );
 
     // Create a vocabulary.
-    $this->vocabulary = entity_create('taxonomy_vocabulary',  array(
+    $this->vocabulary = entity_create('taxonomy_vocabulary', array(
       'name' => 'Views testing tags',
       'vid' => 'views_testing_tags',
     ));
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php
index e4f74a93c..5ed003505 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php
@@ -37,7 +37,7 @@ class TaxonomyTermArgumentDepthTest extends TaxonomyTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Create a term with markup in the label.
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php
index 2704c9f6c..503fb36ea 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php
@@ -39,7 +39,7 @@ class TaxonomyTermFilterDepthTest extends TaxonomyTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     // Create a hierarchy 3 deep. Note the parent setup function creates two
@@ -118,9 +118,9 @@ class TaxonomyTermFilterDepthTest extends TaxonomyTestBase {
   /**
    * Changes the tid filter to given term and depth.
    *
-   * @param integer $tid
+   * @param int $tid
    *   The term ID to filter on.
-   * @param integer $depth
+   * @param int $depth
    *   The depth to search.
    * @param array $expected
    *   The expected views result.
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
index e33924a84..cb16f1a18 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
@@ -82,7 +82,7 @@ abstract class TaxonomyTestBase extends ViewTestBase {
       'type' => 'article',
     ));
     // Create the vocabulary for the tag field.
-    $this->vocabulary = entity_create('taxonomy_vocabulary',  array(
+    $this->vocabulary = entity_create('taxonomy_vocabulary', array(
       'name' => 'Views testing tags',
       'vid' => 'views_testing_tags',
     ));
diff --git a/core/modules/taxonomy/src/VocabularyInterface.php b/core/modules/taxonomy/src/VocabularyInterface.php
index 78b38d7e9..e6e9e79fd 100644
--- a/core/modules/taxonomy/src/VocabularyInterface.php
+++ b/core/modules/taxonomy/src/VocabularyInterface.php
@@ -17,7 +17,7 @@ interface VocabularyInterface extends ConfigEntityInterface {
   /**
    * Returns the vocabulary hierarchy.
    *
-   * @return integer
+   * @return int
    *   The vocabulary hierarchy.
    */
   public function getHierarchy();
@@ -25,7 +25,7 @@ interface VocabularyInterface extends ConfigEntityInterface {
   /**
    * Sets the vocabulary hierarchy.
    *
-   * @param integer $hierarchy
+   * @param int $hierarchy
    *   The hierarchy type of vocabulary.
    *   Possible values:
    *    - TAXONOMY_HIERARCHY_DISABLED: No parents.
diff --git a/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php b/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
index 117919dad..78060d681 100644
--- a/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
+++ b/core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
@@ -32,7 +32,7 @@ class TextFieldTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->plugin = new TextField([], 'text', []);
 
     $migration = $this->prophesize(MigrationInterface::class);
diff --git a/core/modules/toolbar/tests/src/Unit/PageCache/AllowToolbarPathTest.php b/core/modules/toolbar/tests/src/Unit/PageCache/AllowToolbarPathTest.php
index f1223be02..906b59c9e 100644
--- a/core/modules/toolbar/tests/src/Unit/PageCache/AllowToolbarPathTest.php
+++ b/core/modules/toolbar/tests/src/Unit/PageCache/AllowToolbarPathTest.php
@@ -25,7 +25,7 @@ class AllowToolbarPathTest extends UnitTestCase {
    */
   protected $policy;
 
-  public function setUp() {
+  protected function setUp() {
     $this->policy = new AllowToolbarPath();
   }
 
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index 745b42f0b..eeaa422a3 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -135,8 +135,8 @@ function tracker_cron() {
 /**
  * Access callback: Determines access permission for a user's own account.
  *
- * @param int $account
- *   The account ID to check.
+ * @param \Drupal\Core\Session\AccountInterface $account
+ *   The user account to track.
  *
  * @return bool
  *   TRUE if a user is accessing tracking info for their own account and
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index 68c066705..e3082acfc 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -14,6 +14,9 @@ use Drupal\node\Entity\Node;
  * Queries the database for info, adds RDFa info if applicable, and generates
  * the render array that will be used to render the page.
  *
+ * @param \Drupal\user\UserInterface $account
+ *   (optional) The user account to track.
+ *
  * @return array
  *   A renderable array.
  *
diff --git a/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php
index cafa4d13f..80cc83031 100644
--- a/core/modules/update/src/Form/UpdateManagerUpdate.php
+++ b/core/modules/update/src/Form/UpdateManagerUpdate.php
@@ -197,9 +197,9 @@ class UpdateManagerUpdate extends FormBase {
 
       if ($needs_manual) {
         // There are no checkboxes in the 'Manual updates' table so it will be
-        // rendered by _theme('table'), not _theme('tableselect'). Since the data
-        // formats are incompatible, we convert now to the format expected by
-        // _theme('table').
+        // rendered by '#theme' => 'table', not '#theme' => 'tableselect'. Since
+        // the data formats are incompatible, we convert now to the format
+        // expected by '#theme' => 'table'.
         unset($entry['#weight']);
         $attributes = $entry['#attributes'];
         unset($entry['#attributes']);
diff --git a/core/modules/update/src/Tests/UpdateUploadTest.php b/core/modules/update/src/Tests/UpdateUploadTest.php
index f3194480b..cad7d78e8 100644
--- a/core/modules/update/src/Tests/UpdateUploadTest.php
+++ b/core/modules/update/src/Tests/UpdateUploadTest.php
@@ -46,7 +46,7 @@ class UpdateUploadTest extends UpdateTestBase {
     );
     // This also checks that the correct archive extensions are allowed.
     $this->drupalPostForm('admin/modules/install', $edit, t('Install'));
-    $this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', array('@archive_extensions' => archiver_get_extensions())),'Only valid archives can be uploaded.');
+    $this->assertText(t('Only files with the following extensions are allowed: @archive_extensions.', array('@archive_extensions' => archiver_get_extensions())), 'Only valid archives can be uploaded.');
     $this->assertUrl('admin/modules/install');
 
     // Check to ensure an existing module can't be reinstalled. Also checks that
diff --git a/core/modules/user/migration_templates/d6_user_settings.yml b/core/modules/user/migration_templates/d6_user_settings.yml
index 3db99e98d..6e25ece37 100644
--- a/core/modules/user/migration_templates/d6_user_settings.yml
+++ b/core/modules/user/migration_templates/d6_user_settings.yml
@@ -20,7 +20,7 @@ process:
     default_value: visitors_admin_approval
     map:
       2: visitors_admin_approval
-      1: user_register
+      1: visitors
       0: admin_only
   anonymous: anonymous
 destination:
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php b/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
index 1204c7b3d..d713bff5f 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
@@ -41,7 +41,7 @@ class UserMailRequired extends Constraint implements ConstraintValidatorInterfac
   protected $context;
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   public function initialize(ExecutionContextInterface $context) {
     $this->context = $context;
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
index 12d4fa3cc..2ae1a0c6f 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
@@ -44,7 +44,7 @@ class UserNameConstraintValidator extends ConstraintValidator {
         '\x{FEFF}' .              // Byte order mark
         '\x{FF01}-\x{FF60}' .     // Full-width latin
         '\x{FFF9}-\x{FFFD}' .     // Replacement characters
-        '\x{0}-\x{1F}]/u',        // NULL byte and control characters
+        '\x{0}-\x{1F}]/u', // NULL byte and control characters
         $name)
     ) {
       $this->context->addViolation($constraint->illegalMessage);
diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php
index a4be2f547..0066f7127 100644
--- a/core/modules/user/src/Plugin/views/filter/Name.php
+++ b/core/modules/user/src/Plugin/views/filter/Name.php
@@ -101,8 +101,12 @@ class Name extends InOperator {
     // prevent array filter from removing our anonymous user.
   }
 
-  // Override to do nothing.
-  public function getValueOptions() { }
+/**
+ * {@inheritdoc}
+ */
+  public function getValueOptions() {
+    return $this->valueOptions;
+  }
 
   public function adminSummary() {
     // set up $this->valueOptions for the parent summary
diff --git a/core/modules/user/src/Plugin/views/filter/Permissions.php b/core/modules/user/src/Plugin/views/filter/Permissions.php
index c113b2eee..6cbb70397 100644
--- a/core/modules/user/src/Plugin/views/filter/Permissions.php
+++ b/core/modules/user/src/Plugin/views/filter/Permissions.php
@@ -78,6 +78,7 @@ class Permissions extends ManyToOne {
         $display_name = $this->moduleHandler->getName($provider);
         $this->valueOptions[$display_name][$perm] = Html::escape(strip_tags($perm_item['title']));
       }
+      return $this->valueOptions;
     }
     else {
       return $this->valueOptions;
diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php
index bcae6f94c..e017c647a 100644
--- a/core/modules/user/src/Plugin/views/filter/Roles.php
+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -60,6 +60,8 @@ class Roles extends ManyToOne {
   public function getValueOptions() {
     $this->valueOptions = user_role_names(TRUE);
     unset($this->valueOptions[RoleInterface::AUTHENTICATED_ID]);
+    return $this->valueOptions;
+
   }
 
   /**
diff --git a/core/modules/user/src/PrivateTempStore.php b/core/modules/user/src/PrivateTempStore.php
index 3b5fe4abc..7215805a6 100644
--- a/core/modules/user/src/PrivateTempStore.php
+++ b/core/modules/user/src/PrivateTempStore.php
@@ -77,16 +77,16 @@ class PrivateTempStore {
    *   The key/value storage object used for this data. Each storage object
    *   represents a particular collection of data and will contain any number
    *   of key/value pairs.
-   * @param \Drupal\Core\Lock\LockBackendInterface $lockBackend
+   * @param \Drupal\Core\Lock\LockBackendInterface $lock_backend
    *   The lock object used for this data.
    * @param mixed $owner
    *   The owner key to store along with the data (e.g. a user or session ID).
    * @param int $expire
    *   The time to live for items, in seconds.
    */
-  public function __construct(KeyValueStoreExpirableInterface $storage, LockBackendInterface $lockBackend, AccountProxyInterface $current_user, RequestStack $request_stack, $expire = 604800) {
+  public function __construct(KeyValueStoreExpirableInterface $storage, LockBackendInterface $lock_backend, AccountProxyInterface $current_user, RequestStack $request_stack, $expire = 604800) {
     $this->storage = $storage;
-    $this->lockBackend = $lockBackend;
+    $this->lockBackend = $lock_backend;
     $this->currentUser = $current_user;
     $this->requestStack = $request_stack;
     $this->expire = $expire;
diff --git a/core/modules/user/src/PrivateTempStoreFactory.php b/core/modules/user/src/PrivateTempStoreFactory.php
index b8cfdcdea..604edd437 100644
--- a/core/modules/user/src/PrivateTempStoreFactory.php
+++ b/core/modules/user/src/PrivateTempStoreFactory.php
@@ -55,16 +55,20 @@ class PrivateTempStoreFactory {
   /**
    * Constructs a Drupal\user\PrivateTempStoreFactory object.
    *
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The connection object used for this data.
-   * @param \Drupal\Core\Lock\LockBackendInterface $lockBackend
+   * @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $storage_factory
+   *   The key/value store factory.
+   * @param \Drupal\Core\Lock\LockBackendInterface $lock_backend
    *   The lock object used for this data.
+   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
+   *   The current account.
+   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
+   *   The request stack.
    * @param int $expire
    *   The time to live for items, in seconds.
    */
-  function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lockBackend, AccountProxyInterface $current_user, RequestStack $request_stack, $expire = 604800) {
+  function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lock_backend, AccountProxyInterface $current_user, RequestStack $request_stack, $expire = 604800) {
     $this->storageFactory = $storage_factory;
-    $this->lockBackend = $lockBackend;
+    $this->lockBackend = $lock_backend;
     $this->currentUser = $current_user;
     $this->requestStack = $request_stack;
     $this->expire = $expire;
diff --git a/core/modules/user/src/SharedTempStore.php b/core/modules/user/src/SharedTempStore.php
index 0a70b7fbf..07e475694 100644
--- a/core/modules/user/src/SharedTempStore.php
+++ b/core/modules/user/src/SharedTempStore.php
@@ -86,7 +86,7 @@ class SharedTempStore {
    *   The key/value storage object used for this data. Each storage object
    *   represents a particular collection of data and will contain any number
    *   of key/value pairs.
-   * @param \Drupal\Core\Lock\LockBackendInterface $lockBackend
+   * @param \Drupal\Core\Lock\LockBackendInterface $lock_backend
    *   The lock object used for this data.
    * @param mixed $owner
    *   The owner key to store along with the data (e.g. a user or session ID).
@@ -95,9 +95,9 @@ class SharedTempStore {
    * @param int $expire
    *   The time to live for items, in seconds.
    */
-  public function __construct(KeyValueStoreExpirableInterface $storage, LockBackendInterface $lockBackend, $owner, RequestStack $request_stack, $expire = 604800) {
+  public function __construct(KeyValueStoreExpirableInterface $storage, LockBackendInterface $lock_backend, $owner, RequestStack $request_stack, $expire = 604800) {
     $this->storage = $storage;
-    $this->lockBackend = $lockBackend;
+    $this->lockBackend = $lock_backend;
     $this->owner = $owner;
     $this->requestStack = $request_stack;
     $this->expire = $expire;
diff --git a/core/modules/user/src/SharedTempStoreFactory.php b/core/modules/user/src/SharedTempStoreFactory.php
index 1a537e37d..ed27c448e 100644
--- a/core/modules/user/src/SharedTempStoreFactory.php
+++ b/core/modules/user/src/SharedTempStoreFactory.php
@@ -47,18 +47,18 @@ class SharedTempStoreFactory {
   /**
    * Constructs a Drupal\user\SharedTempStoreFactory object.
    *
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The connection object used for this data.
-   * @param \Drupal\Core\Lock\LockBackendInterface $lockBackend
+   * @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $storage_factory
+   *   The key/value store factory.
+   * @param \Drupal\Core\Lock\LockBackendInterface $lock_backend
    *   The lock object used for this data.
    * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
    *   The request stack.
    * @param int $expire
    *   The time to live for items, in seconds.
    */
-  function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lockBackend, RequestStack $request_stack, $expire = 604800) {
+  function __construct(KeyValueExpirableFactoryInterface $storage_factory, LockBackendInterface $lock_backend, RequestStack $request_stack, $expire = 604800) {
     $this->storageFactory = $storage_factory;
-    $this->lockBackend = $lockBackend;
+    $this->lockBackend = $lock_backend;
     $this->requestStack = $request_stack;
     $this->expire = $expire;
   }
diff --git a/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php b/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php
index 89aa1b719..dd9c618ed 100644
--- a/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php
+++ b/core/modules/user/src/Tests/Migrate/d6/MigrateUserConfigsTest.php
@@ -9,6 +9,8 @@ namespace Drupal\user\Tests\Migrate\d6;
 
 use Drupal\config\Tests\SchemaCheckTestTrait;
 use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
+use Drupal\user\AccountSettingsForm;
+use Drupal\Core\Database\Database;
 
 /**
  * Upgrade variables to user.*.yml.
@@ -24,6 +26,8 @@ class MigrateUserConfigsTest extends MigrateDrupal6TestBase {
    */
   protected function setUp() {
     parent::setUp();
+    $this->installSchema('system', 'router');
+    $this->container->get('router.builder')->rebuild();
     $this->executeMigrations(['d6_user_mail', 'd6_user_settings']);
   }
 
@@ -60,6 +64,34 @@ class MigrateUserConfigsTest extends MigrateDrupal6TestBase {
     $this->assertIdentical(FALSE, $config->get('verify_mail'));
     $this->assertIdentical('admin_only', $config->get('register'));
     $this->assertIdentical('Guest', $config->get('anonymous'));
+
+    // Tests migration of user_register using the AccountSettingsForm.
+
+    // Map D6 value to D8 value
+    $user_register_map = [
+      [0, USER_REGISTER_ADMINISTRATORS_ONLY],
+      [1, USER_REGISTER_VISITORS],
+      [2, USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL],
+    ];
+
+    foreach ($user_register_map as $map) {
+      // Tests migration of user_register = 1
+      Database::getConnection('default', 'migrate')
+          ->update('variable')
+          ->fields(['value' => serialize($map[0])])
+          ->condition('name', 'user_register')
+          ->execute();
+
+      /** @var \Drupal\migrate\Entity\MigrationInterface $migration */
+      $migration = \Drupal::entityManager()
+          ->getStorage('migration')
+          ->loadUnchanged('d6_user_settings');
+      // Indicate we're rerunning a migration that's already run.
+      $migration->getIdMap()->prepareUpdate();
+      $this->executeMigration($migration);
+      $form = $this->container->get('form_builder')->getForm(AccountSettingsForm::create($this->container));
+      $this->assertIdentical($map[1], $form['registration_cancellation']['user_register']['#value']);
+    }
   }
 
 }
diff --git a/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php b/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php
index 786fcd26b..020e15cc2 100644
--- a/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php
+++ b/core/modules/user/src/Tests/Migrate/d7/MigrateUserFloodTest.php
@@ -35,6 +35,9 @@ class MigrateUserFloodTest extends MigrateDrupal7TestBase {
       'ip_window' => 7200,
       'user_limit' => 22,
       'user_window' => 86400,
+      '_core' => [
+        'default_config_hash' => 'UYfMzeP1S8jKm9PSvxf7nQNe8DsNS-3bc2WSNNXBQWs',
+      ],
     ];
     $this->assertIdentical($expected, $this->config('user.flood')->get());
   }
diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php
index 6c2034d7e..d3be1af8a 100644
--- a/core/modules/user/src/Tests/UserCancelTest.php
+++ b/core/modules/user/src/Tests/UserCancelTest.php
@@ -535,7 +535,7 @@ class UserCancelTest extends WebTestBase {
     $this->drupalPostForm(NULL, NULL, t('Cancel accounts'));
     $status = TRUE;
     foreach ($users as $account) {
-      $status = $status && (strpos($this->content,  $account->getUsername() . '</em> has been deleted.') !== FALSE);
+      $status = $status && (strpos($this->content, $account->getUsername() . '</em> has been deleted.') !== FALSE);
       $user_storage->resetCache(array($account->id()));
       $status = $status && !$user_storage->load($account->id());
     }
diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php
index 39ffed57b..ce1fb9478 100644
--- a/core/modules/user/src/Tests/UserLoginTest.php
+++ b/core/modules/user/src/Tests/UserLoginTest.php
@@ -30,7 +30,7 @@ class UserLoginTest extends WebTestBase {
     $this->drupalGet('user/login', array('query' => array('destination' => 'foo')));
     $edit = array('name' => $user->getUserName(), 'pass' => $user->pass_raw);
     $this->drupalPostForm(NULL, $edit, t('Log in'));
-    $this->assertUrl('foo', [],  'Redirected to the correct URL');
+    $this->assertUrl('foo', [], 'Redirected to the correct URL');
   }
 
   /**
diff --git a/core/modules/user/src/Tests/Views/BulkFormTest.php b/core/modules/user/src/Tests/Views/BulkFormTest.php
index 0cd84b3ea..b00cc95f3 100644
--- a/core/modules/user/src/Tests/Views/BulkFormTest.php
+++ b/core/modules/user/src/Tests/Views/BulkFormTest.php
@@ -30,7 +30,7 @@ class BulkFormTest extends UserTestBase {
    *
    * @var array
    */
-  public static $testViews = array('test_user_bulk_form');
+  public static $testViews = array('test_user_bulk_form', 'test_user_bulk_form_combine_filter');
 
   /**
    * Tests the user bulk form.
@@ -130,4 +130,14 @@ class BulkFormTest extends UserTestBase {
     $this->assertOption('edit-action', $action_id);
   }
 
+  /**
+   * Tests the user bulk form with a combined field filter on the bulk column.
+   */
+  public function testBulkFormCombineFilter() {
+    // Add a user.
+    $account = entity_load('user', $this->users[0]->id());
+    $view = Views::getView('test_user_bulk_form_combine_filter');
+    $errors = $view->validate();
+    $this->assertEqual(reset($errors['default']), t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', array('%field' => 'User: Bulk update', '%filter' => 'Global: Combine fields filter')));
+  }
 }
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php b/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
index b781f0748..5cdf6b90a 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterPermissionTest.php
@@ -74,7 +74,6 @@ class HandlerFilterPermissionTest extends UserKernelTestBase {
 
     $view->initDisplay();
     $view->initHandlers();
-    $view->filter['permission']->getValueOptions();
 
     // Test the value options.
     $value_options = $view->filter['permission']->getValueOptions();
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
index b105583d6..6873a7655 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
@@ -9,6 +9,7 @@ namespace Drupal\user\Tests\Views;
 
 use Drupal\user\Entity\Role;
 use Drupal\views\Entity\View;
+use Drupal\views\Views;
 
 /**
  * Tests the roles filter handler.
@@ -52,6 +53,11 @@ class HandlerFilterRolesTest extends UserKernelTestBase {
     $expected['config'][] = 'user.role.test_user_role';
     $this->assertEqual($expected, $view->getDependencies());
 
+    $view = Views::getView('test_user_name');
+    $view->initDisplay();
+    $view->initHandlers();
+    $this->assertEqual(array_keys($view->filter['roles_target_id']->getValueOptions()), ['test_user_role']);
+
     $view = View::load('test_user_name');
     $display = &$view->getDisplay('default');
     $display['display_options']['filters']['roles_target_id'] = [
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
index 00bc8c0c0..2e1fc3e8d 100644
--- a/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/src/Tests/Views/HandlerFilterUserNameTest.php
@@ -83,6 +83,8 @@ class HandlerFilterUserNameTest extends ViewTestBase {
 
     $this->executeView($view);
     $this->assertIdenticalResultset($view, array(array('uid' => $this->accounts[0]->id())), $this->columnMap);
+
+    $this->assertEqual($view->filter['uid']->getValueOptions(), NULL);
   }
 
   /**
diff --git a/core/modules/user/src/Theme/AdminNegotiator.php b/core/modules/user/src/Theme/AdminNegotiator.php
index aced48dba..1af422e23 100644
--- a/core/modules/user/src/Theme/AdminNegotiator.php
+++ b/core/modules/user/src/Theme/AdminNegotiator.php
@@ -56,6 +56,8 @@ class AdminNegotiator implements ThemeNegotiatorInterface {
    *   The config factory.
    * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
    *   The entity manager.
+   * @param \Drupal\Core\Routing\AdminContext $admin_context
+   *   The route admin context to determine whether the route is an admin one.
    */
   public function __construct(AccountInterface $user, ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, AdminContext $admin_context) {
     $this->user = $user;
diff --git a/core/modules/user/src/UserDataInterface.php b/core/modules/user/src/UserDataInterface.php
index d7305285f..be373f2a7 100644
--- a/core/modules/user/src/UserDataInterface.php
+++ b/core/modules/user/src/UserDataInterface.php
@@ -17,7 +17,7 @@ interface UserDataInterface {
    *
    * @param string $module
    *   The name of the module the data is associated with.
-   * @param integer $uid
+   * @param int $uid
    *   (optional) The user account ID the data is associated with.
    * @param string $name
    *   (optional) The name of the data key.
@@ -41,7 +41,7 @@ interface UserDataInterface {
    *
    * @param string $module
    *   The name of the module the data is associated with.
-   * @param integer $uid
+   * @param int $uid
    *   The user account ID the data is associated with.
    * @param string $name
    *   The name of the data key.
@@ -58,7 +58,7 @@ interface UserDataInterface {
    * @param string|array $module
    *   (optional) The name of the module the data is associated with. Can also
    *   be an array to delete the data of multiple modules.
-   * @param integer|array $uid
+   * @param int|array $uid
    *   (optional) The user account ID the data is associated with. If omitted,
    *   all data for $module is deleted. Can also be an array of IDs to delete
    *   the data of multiple user accounts.
diff --git a/core/modules/user/src/UserListBuilder.php b/core/modules/user/src/UserListBuilder.php
index a61ce89b9..b2889fe12 100644
--- a/core/modules/user/src/UserListBuilder.php
+++ b/core/modules/user/src/UserListBuilder.php
@@ -58,7 +58,7 @@ class UserListBuilder extends EntityListBuilder {
    * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
    *   The redirect destination service.
    */
-  public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, QueryFactory $query_factory, DateFormatterInterface $date_formatter,  RedirectDestinationInterface $redirect_destination) {
+  public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, QueryFactory $query_factory, DateFormatterInterface $date_formatter, RedirectDestinationInterface $redirect_destination) {
     parent::__construct($entity_type, $storage);
     $this->queryFactory = $query_factory;
     $this->dateFormatter = $date_formatter;
diff --git a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_user_bulk_form_combine_filter.yml b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_user_bulk_form_combine_filter.yml
new file mode 100644
index 000000000..075b4f6d9
--- /dev/null
+++ b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_user_bulk_form_combine_filter.yml
@@ -0,0 +1,243 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - user
+id: test_user_bulk_form_combine_filter
+label: test_user_bulk_form_combine_filter
+module: views
+description: ''
+tag: ''
+base_table: users_field_data
+base_field: uid
+core: 8.x
+display:
+  default:
+    display_plugin: default
+    id: default
+    display_title: Master
+    position: 0
+    display_options:
+      access:
+        type: none
+        options: {  }
+      cache:
+        type: tag
+        options: {  }
+      query:
+        type: views_query
+        options:
+          disable_sql_rewrite: false
+          distinct: false
+          replica: false
+          query_comment: ''
+          query_tags: {  }
+      exposed_form:
+        type: basic
+        options:
+          submit_button: Apply
+          reset_button: false
+          reset_button_label: Reset
+          exposed_sorts_label: 'Sort by'
+          expose_sort_order: true
+          sort_asc_label: Asc
+          sort_desc_label: Desc
+      pager:
+        type: full
+        options:
+          items_per_page: 10
+          offset: 0
+          id: 0
+          total_pages: null
+          expose:
+            items_per_page: false
+            items_per_page_label: 'Items per page'
+            items_per_page_options: '5, 10, 25, 50'
+            items_per_page_options_all: false
+            items_per_page_options_all_label: '- All -'
+            offset: false
+            offset_label: Offset
+          tags:
+            previous: '‹ Previous'
+            next: 'Next ›'
+            first: '« First'
+            last: 'Last »'
+          quantity: 9
+      style:
+        type: default
+      row:
+        type: fields
+      fields:
+        user_bulk_form:
+          id: user_bulk_form
+          table: users
+          field: user_bulk_form
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: ''
+          exclude: false
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: false
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          action_title: 'With selection'
+          include_exclude: exclude
+          selected_actions: {  }
+          entity_type: user
+          plugin_id: user_bulk_form
+        name:
+          id: name
+          table: users_field_data
+          field: name
+          entity_type: user
+          entity_field: name
+          label: ''
+          alter:
+            alter_text: false
+            make_link: false
+            absolute: false
+            trim: false
+            word_boundary: false
+            ellipsis: false
+            strip_tags: false
+            html: false
+          hide_empty: false
+          empty_zero: false
+          plugin_id: field
+          relationship: none
+          group_type: group
+          admin_label: ''
+          exclude: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_alter_empty: true
+          click_sort_column: value
+          type: user_name
+          settings: {  }
+          group_column: value
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+      filters:
+        combine:
+          id: combine
+          table: views
+          field: combine
+          relationship: none
+          group_type: group
+          admin_label: ''
+          operator: contains
+          value: dummy
+          group: 1
+          exposed: false
+          expose:
+            operator_id: ''
+            label: ''
+            description: ''
+            use_operator: false
+            operator: ''
+            identifier: ''
+            required: false
+            remember: false
+            multiple: false
+            remember_roles:
+              authenticated: authenticated
+          is_grouped: false
+          group_info:
+            label: ''
+            description: ''
+            identifier: ''
+            optional: true
+            widget: select
+            multiple: false
+            remember: false
+            default_group: All
+            default_group_multiple: {  }
+            group_items: {  }
+          fields:
+            user_bulk_form: user_bulk_form
+            name: name
+          plugin_id: combine
+      sorts: {  }
+      title: test_user_bulk_form_combine_filter
+      header: {  }
+      footer: {  }
+      empty: {  }
+      relationships: {  }
+      arguments: {  }
+      display_extenders: {  }
+      filter_groups:
+        operator: AND
+        groups:
+          1: AND
+    cache_metadata:
+      max-age: 0
+      contexts:
+        - 'languages:language_content'
+        - 'languages:language_interface'
+        - url.query_args
+      tags: {  }
+  page_1:
+    display_plugin: page
+    id: page_1
+    display_title: Page
+    position: 1
+    display_options:
+      display_extenders: {  }
+      path: test-user-bulk-form-combine-filter
+    cache_metadata:
+      max-age: 0
+      contexts:
+        - 'languages:language_content'
+        - 'languages:language_interface'
+        - url.query_args
+      tags: {  }
diff --git a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
index 26bd3a98c..4e237bb86 100644
--- a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
+++ b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
@@ -61,7 +61,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
diff --git a/core/modules/views/src/Plugin/Block/ViewsBlock.php b/core/modules/views/src/Plugin/Block/ViewsBlock.php
index 20dbace38..681a3f93d 100644
--- a/core/modules/views/src/Plugin/Block/ViewsBlock.php
+++ b/core/modules/views/src/Plugin/Block/ViewsBlock.php
@@ -28,6 +28,9 @@ class ViewsBlock extends ViewsBlockBase {
   public function build() {
     $this->view->display_handler->preBlockBuild($this);
 
+    // We ask ViewExecutable::buildRenderable() to avoid creating a render cache
+    // entry for the view output by passing FALSE, because we're going to cache
+    // the whole block instead.
     if ($output = $this->view->buildRenderable($this->displayID, [], FALSE)) {
       // Override the label to the dynamic title configured in the view.
       if (empty($this->configuration['views_label']) && $this->view->getTitle()) {
diff --git a/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php b/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php
index f38d48521..7d76bfe96 100644
--- a/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php
+++ b/core/modules/views/src/Plugin/Block/ViewsExposedFilterBlock.php
@@ -6,6 +6,7 @@
  */
 
 namespace Drupal\views\Plugin\Block;
+use Drupal\Core\Cache\Cache;
 
 /**
  * Provides a 'Views Exposed Filter' block.
@@ -18,11 +19,20 @@ namespace Drupal\views\Plugin\Block;
  */
 class ViewsExposedFilterBlock extends ViewsBlockBase {
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheContexts() {
+    $contexts = $this->view->display_handler->getCacheMetadata()->getCacheContexts();
+    return Cache::mergeContexts(parent::getCacheContexts(), $contexts);
+  }
+
   /**
    * {@inheritdoc}
    */
   public function build() {
     $output = $this->view->display_handler->viewExposedFormBlocks();
+
     // Before returning the block output, convert it to a renderable array with
     // contextual links.
     $this->addContextualLinks($output, 'exposed_filter');
diff --git a/core/modules/views/src/Plugin/views/area/Messages.php b/core/modules/views/src/Plugin/views/area/Messages.php
index 56bd4e4a2..e5f02b3bf 100644
--- a/core/modules/views/src/Plugin/views/area/Messages.php
+++ b/core/modules/views/src/Plugin/views/area/Messages.php
@@ -12,7 +12,7 @@ namespace Drupal\views\Plugin\views\area;
  *
  * @ingroup views_area_handlers
  *
- * @PluginID("messages")
+ * @ViewsArea("messages")
  */
 class Messages extends AreaPluginBase {
 
diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
index 738fbf4d1..402e00c68 100644
--- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
@@ -270,6 +270,10 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
         // that parameter conversion options is carried over.
         $route->setOptions($route->getOptions() + $original_route->getOptions());
 
+        if ($original_route->hasDefault('_title_callback')) {
+          $route->setDefault('_title_callback', $original_route->getDefault('_title_callback'));
+        }
+
         // Set the corrected path and the mapping to the route object.
         $route->setOption('_view_argument_map', $argument_map);
         $route->setPath($path);
diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
index 5a47cfec3..33267b264 100644
--- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
+++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
@@ -359,6 +359,14 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
       }
     }
 
+    // Merge in cache contexts for all exposed filters to prevent display of
+    // cached forms.
+    foreach ($this->displayHandler->getHandlers('filter') as $filter_hander) {
+      if ($filter_hander->isExposed()) {
+        $contexts = Cache::mergeContexts($contexts, $filter_hander->getCacheContexts());
+      }
+    }
+
     return $contexts;
   }
 
diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php
index 33253d11c..c9ab37a7e 100644
--- a/core/modules/views/src/Plugin/views/field/Field.php
+++ b/core/modules/views/src/Plugin/views/field/Field.php
@@ -242,8 +242,11 @@ class Field extends FieldPluginBase implements CacheableDependencyInterface, Mul
 
       // Go through the list and determine the actual column name from field api.
       $fields = array();
+      $table_mapping = $this->getTableMapping();
+      $field_definition = $this->getFieldStorageDefinition();
+
       foreach ($options as $column) {
-        $fields[$column] = $this->getTableMapping()->getFieldColumnName($this->getFieldStorageDefinition(), $column);
+        $fields[$column] = $table_mapping->getFieldColumnName($field_definition, $column);
       }
 
       $this->group_fields = $fields;
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index 64d6fc73b..460621f74 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -86,9 +86,11 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
   public $original_value = NULL;
 
   /**
-   * @var array
-   * Stores additional fields which get's added to the query.
+   * Stores additional fields that get added to the query.
+   *
    * The generated aliases are stored in $aliases.
+   *
+   * @var array
    */
   var $additional_fields = array();
 
@@ -1384,7 +1386,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
       // In that case the original path looks like
       // internal:/admin/content/files/usage/{{ fid }}, which will be escaped by
       // the toUriString() call above.
-      $path = preg_replace(['/(\%7B){2}(\%20)*/', '/(\%20)*(\%7D){2}/'], ['{{','}}'], $path);
+      $path = preg_replace(['/(\%7B){2}(\%20)*/', '/(\%20)*(\%7D){2}/'], ['{{', '}}'], $path);
 
       // Use strip tags as there should never be HTML in the path.
       // However, we need to preserve special characters like " that are escaped
diff --git a/core/modules/views/src/Plugin/views/field/NumericField.php b/core/modules/views/src/Plugin/views/field/NumericField.php
index 06f4a66b4..0c514da36 100644
--- a/core/modules/views/src/Plugin/views/field/NumericField.php
+++ b/core/modules/views/src/Plugin/views/field/NumericField.php
@@ -138,7 +138,7 @@ class NumericField extends FieldPluginBase {
   }
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   public function submitOptionsForm(&$form, FormStateInterface $form_state) {
     // Merge plural format options into one string and drop the individual
diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
index e936ac9dd..e37ed319b 100644
--- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Plugin\views\filter;
 
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\ViewExecutable;
@@ -31,6 +32,20 @@ use Drupal\views\ViewExecutable;
  */
 class BooleanOperator extends FilterPluginBase {
 
+  /**
+   * The equal query operator.
+   *
+   * @var string
+   */
+  const EQUAL = '=';
+
+  /**
+   * The non equal query operator.
+   *
+   * @var string
+   */
+  const NOT_EQUAL = '<>';
+
   // exposed filter options
   protected $alwaysMultiple = TRUE;
   // Don't display empty space where the operator would be.
@@ -61,15 +76,17 @@ class BooleanOperator extends FilterPluginBase {
     return array(
       '=' => array(
         'title' => $this->t('Is equal to'),
-        'method' => 'queryOpBoolean',
+        'method' => '_queryOperatorBoolean',
         'short' => $this->t('='),
         'values' => 1,
+        'query_operator' => static::EQUAL,
       ),
       '!=' => array(
         'title' => $this->t('Is not equal to'),
-        'method' => 'queryOpBoolean',
+        'method' => '_queryOperatorBoolean',
         'short' => $this->t('!='),
         'values' => 1,
+        'query_operator' => static::NOT_EQUAL,
       ),
     );
   }
@@ -185,7 +202,7 @@ class BooleanOperator extends FilterPluginBase {
     // human-readable label based on the current value.  The valueOptions
     // array is keyed with either 0 or 1, so if the current value is not
     // empty, use the label for 1, and if it's empty, use the label for 0.
-    return $this->valueOptions[!empty($this->value)];
+    return $this->operator . ' ' . $this->valueOptions[!empty($this->value)];
   }
 
   public function defaultExposeOptions() {
@@ -204,34 +221,64 @@ class BooleanOperator extends FilterPluginBase {
 
     $info = $this->operators();
     if (!empty($info[$this->operator]['method'])) {
-      call_user_func(array($this, $info[$this->operator]['method']), $field);
+      call_user_func(array($this, $info[$this->operator]['method']), $field, $info[$this->operator]['query_operator']);
     }
   }
 
+  /**
+   * Adds a where condition to the query for a boolean value. This function
+   * remains to prevent breaks in public-facing API's.
+   *
+   * @param string $field
+   *   The field name to add the where condition for.
+   */
+  protected function queryOpBoolean($field) {
+    $this->_queryOperatorBoolean($field, static::EQUAL);
+  }
+
   /**
    * Adds a where condition to the query for a boolean value.
    *
    * @param string $field
    *   The field name to add the where condition for.
+   * @param string $query_operator
+   *   Either static::EQUAL or static::NOT_EQUAL.
+   *
+   * @internal
+   *   This method will be removed in 8.1.0 and is here to maintain backwards-
+   *   compatibility in 8.0.x releases.
    */
-  protected function queryOpBoolean($field) {
+  protected function _queryOperatorBoolean($field, $query_operator) {
     if (empty($this->value)) {
       if ($this->accept_null) {
-        $or = db_or()
-          ->condition($field, 0, '=')
-          ->condition($field, NULL, 'IS NULL');
-        $this->query->addWhere($this->options['group'], $or);
+        if ($query_operator == static::EQUAL) {
+          $condition = (new Condition('OR'))
+            ->condition($field, 0, $query_operator)
+            ->isNull($field);
+        }
+        else {
+          $condition = (new Condition('AND'))
+            ->condition($field, 0, $query_operator)
+            ->isNotNull($field);
+        }
+        $this->query->addWhere($this->options['group'], $condition);
       }
       else {
-        $this->query->addWhere($this->options['group'], $field, 0, '=');
+        $this->query->addWhere($this->options['group'], $field, 0, $query_operator);
       }
     }
     else {
       if (!empty($this->definition['use_equal'])) {
-        $this->query->addWhere($this->options['group'], $field, 1, '=');
+        // Forces an '=' operator instead of a '<>' for performance reasons.
+        if ($query_operator == static::EQUAL) {
+          $this->query->addWhere($this->options['group'], $field, 1, static::EQUAL);
+        }
+        else {
+          $this->query->addWhere($this->options['group'], $field, 0, static::EQUAL);
+        }
       }
       else {
-        $this->query->addWhere($this->options['group'], $field, 0, '<>');
+        $this->query->addWhere($this->options['group'], $field, 1, $query_operator);
       }
     }
   }
diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php
index 9c62fb38d..a0889c9b9 100644
--- a/core/modules/views/src/Plugin/views/filter/Combine.php
+++ b/core/modules/views/src/Plugin/views/filter/Combine.php
@@ -38,7 +38,11 @@ class Combine extends StringFilter {
     if ($this->view->style_plugin->usesFields()) {
       $options = array();
       foreach ($this->view->display_handler->getHandlers('field') as $name => $field) {
-        $options[$name] = $field->adminLabel(TRUE);
+        // Only allow clickSortable fields. Fields without clickSorting will
+        // probably break in the Combine filter.
+        if ($field->clickSortable()) {
+          $options[$name] = $field->adminLabel(TRUE);
+        }
       }
       if ($options) {
         $form['fields'] = array(
@@ -108,6 +112,13 @@ class Combine extends StringFilter {
         $errors[] = $this->t('Field %field set in %filter is not set in this display.', array('%field' => $id, '%filter' => $this->adminLabel()));
         break;
       }
+      elseif (!$fields[$id]->clickSortable()) {
+        // Combined field filter only works with simple fields. If the field is
+        // not click sortable we can assume it is not a simple field.
+        // @todo change this check to isComputed. See
+        // https://www.drupal.org/node/2349465
+        $errors[] = $this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', array('%field' => $fields[$id]->adminLabel(), '%filter' => $this->adminLabel()));
+      }
     }
     return $errors;
   }
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index 3e3482a02..042dca55a 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -59,8 +59,8 @@ class InOperator extends FilterPluginBase {
    * This can use a guard to be used to reduce database hits as much as
    * possible.
    *
-   * @return
-   *   Return the stored values in $this->valueOptions if someone expects it.
+   * @return array|NULL
+   *   The stored values from $this->valueOptions.
    */
   public function getValueOptions() {
     if (isset($this->valueOptions)) {
diff --git a/core/modules/views/src/Plugin/views/filter/LanguageFilter.php b/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
index c42122c4d..f7eefb9a4 100644
--- a/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/LanguageFilter.php
@@ -69,6 +69,7 @@ class LanguageFilter extends InOperator implements ContainerFactoryPluginInterfa
       // lost when there are changes in the language configuration.
       $this->valueOptions = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED, array_keys($this->value));
     }
+    return $this->valueOptions;
   }
 
   /**
diff --git a/core/modules/views/src/Plugin/views/filter/NumericFilter.php b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
index 116402843..af3047205 100644
--- a/core/modules/views/src/Plugin/views/filter/NumericFilter.php
+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -199,9 +199,10 @@ class NumericFilter extends FilterPluginBase {
     if ($which == 'all' || $which == 'minmax') {
       $form['value']['min'] = array(
         '#type' => 'textfield',
-        '#title' => !$exposed ? $this->t('Min') : '',
+        '#title' => !$exposed ? $this->t('Min') : $this->exposedInfo()['label'],
         '#size' => 30,
         '#default_value' => $this->value['min'],
+        '#description' => !$exposed ? '' : $this->exposedInfo()['description']
       );
       $form['value']['max'] = array(
         '#type' => 'textfield',
diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
index e4d0f571f..719ee58e4 100644
--- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php
+++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
@@ -134,6 +134,9 @@ abstract class StylePluginBase extends PluginBase {
 
   }
 
+  /**
+   * {@inheritdoc}
+   */
   public function destroy() {
     parent::destroy();
 
@@ -255,6 +258,9 @@ abstract class StylePluginBase extends PluginBase {
     return !empty($this->definition['even empty']);
   }
 
+  /**
+   * {@inheritdoc}
+   */
   protected function defineOptions() {
     $options = parent::defineOptions();
     $options['grouping'] = array('default' => array());
@@ -267,6 +273,9 @@ abstract class StylePluginBase extends PluginBase {
     return $options;
   }
 
+  /**
+   * {@inheritdoc}
+   */
   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
     parent::buildOptionsForm($form, $form_state);
     // Only fields-based views can handle grouping.  Style plugins can also exclude
@@ -358,6 +367,9 @@ abstract class StylePluginBase extends PluginBase {
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
   public function validateOptionsForm(&$form, FormStateInterface $form_state) {
     // Don't run validation on style plugins without the grouping setting.
     if ($form_state->hasValue(array('style_options', 'grouping'))) {
@@ -783,6 +795,9 @@ abstract class StylePluginBase extends PluginBase {
     return $value;
   }
 
+  /**
+   * {@inheritdoc}
+   */
   public function validate() {
     $errors = parent::validate();
 
@@ -801,6 +816,9 @@ abstract class StylePluginBase extends PluginBase {
     return $errors;
   }
 
+  /**
+   * {@inheritdoc}
+   */
   public function query() {
     parent::query();
     if (isset($this->view->rowPlugin)) {
diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
index 4632db4db..95acc95a9 100644
--- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
+++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php
@@ -1249,7 +1249,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
   }
 
   /**
-   * {@inheritDoc}
+   * {@inheritdoc}
    */
   public function createView(array $form, FormStateInterface $form_state) {
     $view = $this->retrieveValidatedView($form, $form_state);
diff --git a/core/modules/views/src/ResultRow.php b/core/modules/views/src/ResultRow.php
index d93d05613..790cc8a6b 100644
--- a/core/modules/views/src/ResultRow.php
+++ b/core/modules/views/src/ResultRow.php
@@ -29,7 +29,7 @@ class ResultRow {
   /**
    * An incremental number which represents the row in the entire result.
    *
-   * @var integer
+   * @var int
    */
   public $index;
 
diff --git a/core/modules/views/src/Tests/Handler/AreaMessagesTest.php b/core/modules/views/src/Tests/Handler/AreaMessagesTest.php
new file mode 100644
index 000000000..c17deb1c3
--- /dev/null
+++ b/core/modules/views/src/Tests/Handler/AreaMessagesTest.php
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\views\Tests\Handler\AreaMessagesTest.
+ */
+
+namespace Drupal\views\Tests\Handler;
+
+use Drupal\views\Tests\ViewKernelTestBase;
+use Drupal\views\Views;
+
+/**
+ * Tests the messages area handler.
+ *
+ * @group views
+ * @see \Drupal\views\Plugin\views\area\Messages
+ */
+class AreaMessagesTest extends ViewKernelTestBase {
+
+  /**
+   * Views used by this test.
+   *
+   * @var array
+   */
+  public static $testViews = array('test_area_messages');
+
+  /**
+   * Tests the messages area handler.
+   */
+  public function testMessageText() {
+    drupal_set_message('My drupal set message.');
+
+    $view = Views::getView('test_area_messages');
+
+    $view->setDisplay('default');
+    $this->executeView($view);
+    $output = $view->render();
+    $output = \Drupal::service('renderer')->renderRoot($output);
+    $this->setRawContent($output);
+    $this->assertText('My drupal set message.');
+  }
+
+}
diff --git a/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php b/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php
index 574f7e4dc..44880328e 100644
--- a/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php
@@ -32,7 +32,7 @@ class FieldDropButtonTest extends HandlerTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $admin_user = $this->drupalCreateUser(['access content overview', 'administer nodes', 'bypass node access']);
diff --git a/core/modules/views/src/Tests/Handler/FilterBooleanOperatorTest.php b/core/modules/views/src/Tests/Handler/FilterBooleanOperatorTest.php
index 049d439db..7e6c3104a 100644
--- a/core/modules/views/src/Tests/Handler/FilterBooleanOperatorTest.php
+++ b/core/modules/views/src/Tests/Handler/FilterBooleanOperatorTest.php
@@ -95,6 +95,30 @@ class FilterBooleanOperatorTest extends ViewKernelTestBase {
 
     $this->assertEqual(3, count($view->result));
     $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
+
+    $view->destroy();
+    $view->setDisplay();
+
+    // Testing the same scenario but using the reverse status and operation.
+    $view->displayHandlers->get('default')->overrideOption('filters', array(
+      'status' => array(
+        'id' => 'status',
+        'field' => 'status',
+        'table' => 'views_test_data',
+        'value' => 0,
+        'operator' => '!=',
+      ),
+    ));
+    $this->executeView($view);
+
+    $expected_result = array(
+      array('id' => 1),
+      array('id' => 3),
+      array('id' => 5),
+    );
+
+    $this->assertEqual(3, count($view->result));
+    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
   }
 
   /**
@@ -133,6 +157,24 @@ class FilterBooleanOperatorTest extends ViewKernelTestBase {
 
     $this->assertEqual(2, count($view->result));
     $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
+
+    $view->destroy();
+
+    // Expecting the same results as for ['status' => 1].
+    $view->setExposedInput(['status' => 3]);
+    $view->setDisplay();
+    $view->displayHandlers->get('default')->overrideOption('filters', $filters);
+
+    $this->executeView($view);
+
+    $expected_result = array(
+      array('id' => 1),
+      array('id' => 3),
+      array('id' => 5),
+    );
+
+    $this->assertEqual(3, count($view->result));
+    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
   }
 
   /**
@@ -169,6 +211,13 @@ class FilterBooleanOperatorTest extends ViewKernelTestBase {
               'operator' => '=',
               'value' => '0',
             ),
+            // This group should return the same results as group 1, because it
+            // is the negation of group 2.
+            3 => array(
+              'title' => 'Active (reverse)',
+              'operator' => '!=',
+              'value' => '0',
+            ),
           ),
         ),
       ),
diff --git a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
index 8906cfda3..1c520e0b8 100644
--- a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
+++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
@@ -151,6 +151,7 @@ class ExposedFormTest extends ViewTestBase {
    * Tests the exposed block functionality.
    */
   public function testExposedBlock() {
+    $this->drupalCreateContentType(['type' => 'page']);
     $view = Views::getView('test_exposed_block');
     $view->setDisplay('page_1');
     $block = $this->drupalPlaceBlock('views_exposed_filter_block:test_exposed_block-page_1');
@@ -167,6 +168,15 @@ class ExposedFormTest extends ViewTestBase {
     // Test there is only one views exposed form on the page.
     $elements = $this->xpath('//form[@id=:id]', array(':id' => $this->getExpectedExposedFormId($view)));
     $this->assertEqual(count($elements), 1, 'One exposed form block found.');
+
+    // Test that the correct option is selected after form submission.
+    $this->assertCacheContext('url');
+    $this->assertOptionSelected('edit-type', 'All');
+    foreach (['All', 'article', 'page'] as $argument) {
+      $this->drupalGet('test_exposed_block', ['query' => ['type' => $argument]]);
+      $this->assertCacheContext('url');
+      $this->assertOptionSelected('edit-type', $argument);
+    }
   }
 
   /**
diff --git a/core/modules/views/src/Tests/Plugin/PluginBaseTest.php b/core/modules/views/src/Tests/Plugin/PluginBaseTest.php
index cb794349e..4161db405 100644
--- a/core/modules/views/src/Tests/Plugin/PluginBaseTest.php
+++ b/core/modules/views/src/Tests/Plugin/PluginBaseTest.php
@@ -24,7 +24,7 @@ class PluginBaseTest extends KernelTestBase {
    */
   var $testPluginBase;
 
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->testPluginBase = new TestPluginBase();
   }
diff --git a/core/modules/views/src/Tests/Plugin/StyleTableTest.php b/core/modules/views/src/Tests/Plugin/StyleTableTest.php
index 0c423a9a6..30ea61039 100644
--- a/core/modules/views/src/Tests/Plugin/StyleTableTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleTableTest.php
@@ -136,4 +136,99 @@ class StyleTableTest extends PluginTestBase {
     $this->assertTrue(count($result), 'Ensure that the baby\'s age is shown');
   }
 
+  /**
+   * Test that empty columns are hidden when empty_column is set.
+   */
+  public function testEmptyColumn() {
+    // Empty the 'job' data.
+    \Drupal::database()->update('views_test_data')
+      ->fields(['job' => ''])
+      ->execute();
+
+    $this->drupalGet('test-table');
+
+    // Test that only one of the job columns still shows.
+    $result = $this->xpath('//thead/tr/th/a[text()="Job"]');
+    $this->assertEqual(count($result), 1, 'Ensure that empty column header is hidden.');
+
+    $result = $this->xpath('//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job-1 ")]');
+    $this->assertEqual(count($result), 0, 'Ensure the empty table cells are hidden.');
+  }
+
+  /**
+   * Tests grouping by a field.
+   */
+  public function testGrouping() {
+    /** @var \Drupal\views\ViewEntityInterface $view */
+    $view = \Drupal::entityTypeManager()->getStorage('view')->load('test_table');
+    // Get a reference to the display configuration so we can alter some
+    // specific style options.
+    $display = &$view->getDisplay('default');
+    // Set job as the grouping field.
+    $display['display_options']['style']['options']['grouping'][0] = array(
+      'field' => 'job',
+      'rendered' => TRUE,
+      'rendered_strip' => FALSE,
+    );
+    // Clear the caption text, the rendered job field will be used as a caption.
+    $display['display_options']['style']['options']['caption'] = '';
+    $display['display_options']['style']['options']['summary'] = '';
+    $display['display_options']['style']['options']['description'] = '';
+    $view->save();
+
+    // Add a record containing unsafe markup to be sure it's filtered out.
+    $unsafe_markup = '<script>alert("Rapper");</script>';
+    $unsafe_markup_data = array(
+      'name' => 'Marshall',
+      'age' => 42,
+      'job' => $unsafe_markup,
+      'created' => gmmktime(0, 0, 0, 2, 15, 2001),
+      'status' => 1,
+    );
+    $database = $this->container->get('database');
+    $database->insert('views_test_data')
+      ->fields(array_keys($unsafe_markup_data))
+      ->values($unsafe_markup_data)
+      ->execute();
+
+    $this->drupalGet('test-table');
+    $expected_captions = array(
+      'Job: Speaker',
+      'Job: Songwriter',
+      'Job: Drummer',
+      'Job: Singer',
+      'Job: ' . $unsafe_markup,
+    );
+
+    // Ensure that we don't find the caption containing unsafe markup.
+    $this->assertNoRaw($unsafe_markup, "Didn't find caption containing unsafe markup.");
+
+    // Ensure that all expected captions are found.
+    foreach ($expected_captions as $raw_caption) {
+      $this->assertEscaped($raw_caption);
+    }
+
+    $display = &$view->getDisplay('default');
+    // Remove the label from the grouping field.
+    $display['display_options']['fields']['job']['label'] = '';
+    $view->save();
+
+    $this->drupalGet('test-table');
+    $expected_captions = array(
+      'Speaker',
+      'Songwriter',
+      'Drummer',
+      'Singer',
+      $unsafe_markup,
+    );
+
+    // Ensure that we don't find the caption containing unsafe markup.
+    $this->assertNoRaw($unsafe_markup, "Didn't find caption containing unsafe markup.");
+
+    // Ensure that all expected captions are found.
+    foreach ($expected_captions as $raw_caption) {
+      $this->assertEscaped($raw_caption);
+    }
+  }
+
 }
diff --git a/core/modules/views/src/Tests/ViewResultAssertionTrait.php b/core/modules/views/src/Tests/ViewResultAssertionTrait.php
index 66685fa9b..021e4e582 100644
--- a/core/modules/views/src/Tests/ViewResultAssertionTrait.php
+++ b/core/modules/views/src/Tests/ViewResultAssertionTrait.php
@@ -130,7 +130,7 @@ trait ViewResultAssertionTrait {
 
     $this->verbose('<pre style="white-space: pre-wrap;">'
       . "\n\nQuery:\n" . $view->build_info['query']
-      . "\n\nQuery arguments:\n" . var_export($view->build_info['query_args'], TRUE)
+      . "\n\nQuery arguments:\n" . var_export($view->build_info['query']->getArguments(), TRUE)
       . "\n\nActual result:\n" . var_export($result, TRUE)
       . "\n\nExpected result:\n" . var_export($expected_result, TRUE));
 
diff --git a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
index 4b93c0037..e62c17374 100644
--- a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
+++ b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
@@ -77,7 +77,7 @@ class TaggedWithTest extends WizardTestBase {
     $this->nodeTypeWithoutTags = $this->drupalCreateContentType();
 
     // Create the vocabulary for the tag field.
-    $this->tagVocabulary = entity_create('taxonomy_vocabulary',  array(
+    $this->tagVocabulary = entity_create('taxonomy_vocabulary', array(
       'name' => 'Views testing tags',
       'vid' => 'views_testing_tags',
     ));
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_messages.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_messages.yml
new file mode 100644
index 000000000..829228192
--- /dev/null
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_messages.yml
@@ -0,0 +1,58 @@
+langcode: en
+status: true
+dependencies: {  }
+id: test_area_messages
+label: ''
+module: views
+description: ''
+tag: ''
+base_table: views_test_data
+base_field: nid
+core: '8'
+display:
+  default:
+    display_options:
+      defaults:
+        fields: false
+        pager: false
+        sorts: false
+      fields:
+        id:
+          field: id
+          id: id
+          relationship: none
+          table: views_test_data
+          plugin_id: numeric
+      pager:
+        options:
+          offset: 0
+        type: none
+      sorts:
+        id:
+          field: id
+          id: id
+          order: ASC
+          relationship: none
+          table: views_test_data
+          plugin_id: numeric
+      empty:
+        title:
+          field: title
+          id: title
+          table: views
+          plugin_id: title
+          title: test_title_empty
+      header:
+        messages:
+          id: messages
+          table: views
+          field: messages
+          relationship: none
+          group_type: group
+          admin_label: ''
+          empty: true
+          plugin_id: messages
+    display_plugin: default
+    display_title: Master
+    id: default
+    position: 0
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_preview_error.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_preview_error.yml
new file mode 100644
index 000000000..1c4d39032
--- /dev/null
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_preview_error.yml
@@ -0,0 +1,23 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - user
+id: test_preview_error
+label: test_preview_error
+module: views
+description: ''
+tag: ''
+base_table: views_test_data
+base_field: id
+core: 8.x
+display:
+  default:
+    display_plugin: default
+    id: default
+    display_title: Master
+    position: null
+    display_options:
+      row:
+        type: fields
+      fields: { }
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_table.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_table.yml
index 698e072e3..b391efc0b 100644
--- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_table.yml
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_table.yml
@@ -108,7 +108,7 @@ display:
               default_sort_order: asc
               align: ''
               separator: ''
-              empty_column: false
+              empty_column: true
               responsive: ''
           default: id
           empty_table: true
diff --git a/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php b/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
index 87c79a3d9..785028c04 100644
--- a/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/area/ResultTest.php
@@ -135,7 +135,7 @@ class ResultTest extends UnitTestCase {
     $this->view->pager = $pager;
     $this->view->style_plugin = new \stdClass();
     $this->view->total_rows = 100;
-    $this->view->result = array(1,2,3,4,5);
+    $this->view->result = array(1, 2, 3, 4, 5);
   }
 
 }
diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
index bae789a93..90d2ae74c 100644
--- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
@@ -260,6 +260,44 @@ class PathPluginBaseTest extends UnitTestCase {
     $this->assertSame($collection->get('test_route_2'), $route_2);
   }
 
+  /**
+   * Tests the alter route method with preexisting title callback.
+   */
+  public function testAlterRouteWithAlterCallback() {
+    $collection = new RouteCollection();
+    $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content', '_title_callback' => '\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle')));
+    $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content'));
+    $collection->add('test_route_2', $route_2);
+
+    list($view) = $this->setupViewExecutableAccessPlugin();
+
+    $display = array();
+    $display['display_plugin'] = 'page';
+    $display['id'] = 'page_1';
+    $display['display_options'] = array(
+      'path' => 'test_route',
+    );
+    $this->pathPlugin->initDisplay($view, $display);
+
+    $view_route_names = $this->pathPlugin->alterRoutes($collection);
+    $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
+
+    // Ensure that the test_route is overridden.
+    $route = $collection->get('test_route');
+    $this->assertTrue($route instanceof Route);
+    $this->assertEquals('test_id', $route->getDefault('view_id'));
+    $this->assertEquals('\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle', $route->getDefault('_title_callback'));
+    $this->assertEquals('page_1', $route->getDefault('display_id'));
+    $this->assertEquals('my views title', $route->getDefault('_title'));
+
+    // Ensure that the test_route_2 is not overridden.
+    $route = $collection->get('test_route_2');
+    $this->assertTrue($route instanceof Route);
+    $this->assertFalse($route->hasDefault('view_id'));
+    $this->assertFalse($route->hasDefault('display_id'));
+    $this->assertSame($collection->get('test_route_2'), $route_2);
+  }
+
   /**
    * Tests the collectRoutes method with a path containing named parameters.
    *
@@ -457,3 +495,20 @@ class PathPluginBaseTest extends UnitTestCase {
   }
 
 }
+
+/**
+ * A page controller for use by tests in this file.
+ */
+class TestController {
+
+  /**
+   * A page title callback.
+   *
+   * @return string
+   *   The page title.
+   */
+  public function testTitle() {
+    return 'Test title';
+  }
+
+}
diff --git a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
index 7300118ca..fc4b2a880 100644
--- a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
@@ -43,7 +43,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
    *
    * @covers ::__construct
    */
-  public function setUp() {
+  protected function setUp() {
     $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
     $this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
 
diff --git a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php
index 614aa299d..e4da4b553 100644
--- a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php
@@ -46,7 +46,7 @@ class ViewsHandlerManagerTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->viewsData = $this->getMockBuilder('Drupal\views\ViewsData')
       ->disableOriginalConstructor()
       ->getMock();
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index 47f964499..0faa5bbad 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -8,6 +8,7 @@
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Database\Query\AlterableInterface;
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\Element;
 use Drupal\Core\Routing\RouteMatchInterface;
@@ -804,3 +805,18 @@ function views_local_tasks_alter(&$local_tasks) {
   $local_task = ViewsLocalTask::create($container, 'views_view');
   $local_task->alterLocalTasks($local_tasks);
 }
+
+/**
+ * Implements hook_ENTITY_TYPE_delete().
+ */
+function views_view_delete(EntityInterface $entity) {
+  // Rebuild the routes in case there is a routed display.
+  $executable = Views::executableFactory()->get($entity);
+  $executable->initDisplay();
+  foreach ($executable->displayHandlers as $display) {
+    if ($display->getRoutedDisplay()) {
+      \Drupal::service('router.builder')->setRebuildNeeded();
+      break;
+    }
+  }
+}
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index d84277f3f..4ddfc5e62 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -547,18 +547,18 @@ function template_preprocess_views_view_table(&$variables) {
       $column_reference['attributes'] = new Attribute($column_reference['attributes']);
     }
 
-    // Remove columns if the option is hide empty column is checked and the
-    // field is not empty.
+    // Remove columns if the "empty_column" option is checked and the
+    // field is empty.
     if (!empty($options['info'][$field]['empty_column'])) {
       $empty = TRUE;
       foreach ($variables['rows'] as $columns) {
-        $empty &= empty($columns[$column]);
+        $empty &= empty($columns['columns'][$column]['content']);
       }
       if ($empty) {
         foreach ($variables['rows'] as &$column_items) {
-          unset($column_items[$column]);
-          unset($variables['header'][$column]);
+          unset($column_items['columns'][$column]);
         }
+        unset($variables['header'][$column]);
       }
     }
   }
@@ -598,6 +598,10 @@ function template_preprocess_views_view_table(&$variables) {
     $variables['caption'] = ['#markup' => $handler->options['caption']];
     $variables['caption_needed'] = TRUE;
   }
+  elseif (!empty($variables['title'])) {
+    $variables['caption'] = ['#markup' => $variables['title']];
+    $variables['caption_needed'] = TRUE;
+  }
   else {
     $variables['caption'] = '';
     $variables['caption_needed'] = FALSE;
diff --git a/core/modules/views_ui/src/Controller/ViewsUIController.php b/core/modules/views_ui/src/Controller/ViewsUIController.php
index be7193262..68bed4aa0 100644
--- a/core/modules/views_ui/src/Controller/ViewsUIController.php
+++ b/core/modules/views_ui/src/Controller/ViewsUIController.php
@@ -19,6 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Drupal\Core\Ajax\AjaxResponse;
 use Drupal\Core\Ajax\ReplaceCommand;
+use Drupal\Component\Utility\Html;
 
 /**
  * Returns responses for Views UI routes.
@@ -189,12 +190,17 @@ class ViewsUIController extends ControllerBase {
     $string = $request->query->get('q');
     // Get matches from default views.
     $views = $this->entityManager()->getStorage('view')->loadMultiple();
+    // Keep track of previously processed tags so they can be skipped.
+    $tags = [];
     foreach ($views as $view) {
       $tag = $view->get('tag');
-      if ($tag && strpos($tag, $string) === 0) {
-        $matches[$tag] = $tag;
-        if (count($matches) >= 10) {
-          break;
+      if ($tag && !in_array($tag, $tags)) {
+        $tags[] = $tag;
+        if (strpos($tag, $string) === 0) {
+          $matches[] = ['value' => $tag, 'label' => Html::escape($tag)];
+          if (count($matches) >= 10) {
+            break;
+          }
         }
       }
     }
diff --git a/core/modules/views_ui/src/Tests/DefaultViewsTest.php b/core/modules/views_ui/src/Tests/DefaultViewsTest.php
index 84496ee03..21be36637 100644
--- a/core/modules/views_ui/src/Tests/DefaultViewsTest.php
+++ b/core/modules/views_ui/src/Tests/DefaultViewsTest.php
@@ -142,6 +142,23 @@ class DefaultViewsTest extends UITestBase {
     $this->drupalGet($edit_href);
     $this->assertResponse(404);
     $this->assertText('Page not found');
+
+    // Delete all duplicated Glossary views.
+    $this->drupalGet('admin/structure/views');
+    $this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
+    // Submit the confirmation form.
+    $this->drupalPostForm(NULL, array(), t('Delete'));
+
+    $this->drupalGet('glossary');
+    $this->assertResponse(200);
+
+    $this->drupalGet('admin/structure/views');
+    $this->clickViewsOperationLink(t('Delete'), $random_name);
+    // Submit the confirmation form.
+    $this->drupalPostForm(NULL, array(), t('Delete'));
+    $this->drupalGet('glossary');
+    $this->assertResponse(404);
+    $this->assertText('Page not found');
   }
 
   /**
diff --git a/core/modules/views_ui/src/Tests/FilterNumericWebTest.php b/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
index d687b4a57..f89199579 100644
--- a/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
+++ b/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
@@ -92,6 +92,26 @@ class FilterNumericWebTest extends UITestBase {
     $this->assertNoText('Ringo');
     $this->assertNoText('George');
     $this->assertNoText('Meredith');
+
+    // Change the filter to a 'between' filter to test if the label and
+    // description are set for the 'minimum' filter element.
+    $this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/age');
+    $edit = array();
+    $edit['options[expose][label]'] = 'Age between';
+    $edit['options[expose][description]'] = 'Description of the exposed filter';
+    $edit['options[operator]'] = 'between';
+    $edit['options[value][min]'] = 26;
+    $edit['options[value][max]'] = 28;
+    $this->drupalPostForm(NULL, $edit, t('Apply'));
+    $this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
+    $this->assertConfigSchemaByName('views.view.test_view');
+
+    $this->drupalPostForm(NULL, array(), t('Update preview'));
+    // Check the max field label.
+    $this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
+    $this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
+    // Check that the description is shown in the right place.
+    $this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]), 'Description of the exposed filter');
   }
 
 }
diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php
index ff10213ce..69d1feeb8 100644
--- a/core/modules/views_ui/src/Tests/PreviewTest.php
+++ b/core/modules/views_ui/src/Tests/PreviewTest.php
@@ -21,7 +21,7 @@ class PreviewTest extends UITestBase {
    *
    * @var array
    */
-  public static $testViews = array('test_preview', 'test_pager_full', 'test_mini_pager');
+  public static $testViews = array('test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager');
 
   /**
    * Tests contextual links in the preview form.
@@ -90,6 +90,34 @@ class PreviewTest extends UITestBase {
     $this->drupalPostForm(NULL, array(), t('Update preview'));
     $result = $this->xpath('//div[@id="views-live-preview"]/pre');
     $this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.');
+
+    // Test the non-default UI display options.
+    // Statistics only, no query.
+    $settings = \Drupal::configFactory()->getEditable('views.settings');
+    $settings->set('ui.show.performance_statistics', TRUE)->save();
+    $this->drupalGet('admin/structure/views/view/test_preview/edit');
+    $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+    $this->assertText(t('Query build time'));
+    $this->assertText(t('Query execute time'));
+    $this->assertText(t('View render time'));
+    $this->assertNoRaw('<strong>Query</strong>');
+
+    // Statistics and query.
+    $settings->set('ui.show.sql_query.enabled', TRUE)->save();
+    $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+    $this->assertText(t('Query build time'));
+    $this->assertText(t('Query execute time'));
+    $this->assertText(t('View render time'));
+    $this->assertRaw('<strong>Query</strong>');
+    $this->assertText("SELECT views_test_data.name AS views_test_data_name\nFROM \n{views_test_data} views_test_data\nWHERE (( (views_test_data.id = &#039;100&#039; ) ))");
+
+    // Test that the statistics and query are rendered above the preview.
+    $this->assertTrue(strpos($this->getRawContent(), 'views-query-info') < strpos($this->getRawContent(), 'view-test-preview') , 'Statistics shown above the preview.');
+
+    // Test that statistics and query rendered below the preview.
+    $settings->set('ui.show.sql_query.where', 'below')->save();
+    $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
+    $this->assertTrue(strpos($this->getRawContent(), 'view-test-preview') < strpos($this->getRawContent(), 'views-query-info'), 'Statistics shown below the preview.');
   }
 
   /**
@@ -230,6 +258,18 @@ class PreviewTest extends UITestBase {
     $this->assertRaw('css/views_ui_test.test.css', 'Attached CSS asset found.');
   }
 
+  /**
+   * Tests view validation error messages in the preview.
+   */
+  public function testPreviewError() {
+    $this->drupalGet('admin/structure/views/view/test_preview_error/edit');
+    $this->assertResponse(200);
+
+    $this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
+
+    $this->assertText('Unable to preview due to validation errors.', 'Preview error text found.');
+  }
+
   /**
    * Get the preview form and force an AJAX preview update.
    *
diff --git a/core/modules/views_ui/src/Tests/TagTest.php b/core/modules/views_ui/src/Tests/TagTest.php
index 0dd6f4f79..b18ee98ae 100644
--- a/core/modules/views_ui/src/Tests/TagTest.php
+++ b/core/modules/views_ui/src/Tests/TagTest.php
@@ -9,6 +9,7 @@ namespace Drupal\views_ui\Tests;
 
 use Drupal\views\Tests\ViewKernelTestBase;
 use Drupal\views_ui\Controller\ViewsUIController;
+use Drupal\Component\Utility\Html;
 
 /**
  * Tests the views ui tagging functionality.
@@ -44,16 +45,25 @@ class TagTest extends ViewKernelTestBase {
     $request = $this->container->get('request_stack')->getCurrentRequest();
     $request->query->set('q', 'autocomplete_tag_test');
     $result = $controller->autocompleteTag($request);
-    $matches = (array) json_decode($result->getContent());
+    $matches = (array) json_decode($result->getContent(), TRUE);
     $this->assertEqual(count($matches), 10, 'Make sure the maximum amount of tag results is 10.');
 
+    // Make sure the returned array has the proper format.
+    $suggestions = array_map(function ($tag) {
+      return array('value' => $tag, 'label' => Html::escape($tag));
+    }, $tags);
+    foreach ($matches as $match) {
+      $this->assertTrue(in_array($match, $suggestions), 'Make sure the returned array has the proper format.');
+    }
+
+
     // Make sure that matching by a certain prefix works.
     $request->query->set('q', 'autocomplete_tag_test_even');
     $result = $controller->autocompleteTag($request);
-    $matches = (array) json_decode($result->getContent());
+    $matches = (array) json_decode($result->getContent(), TRUE);
     $this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
     foreach ($matches as $tag) {
-      $this->assertTrue(array_search($tag, $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag)));
+      $this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag['value'])));
     }
 
     // Make sure an invalid result doesn't return anything.
diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php
index fe3198b26..33c328423 100644
--- a/core/modules/views_ui/src/ViewUI.php
+++ b/core/modules/views_ui/src/ViewUI.php
@@ -45,26 +45,12 @@ class ViewUI implements ViewEntityInterface {
   public $changed_display;
 
   /**
-   * How long the view takes to build.
+   * How long the view takes to render in microseconds.
    *
-   * @var int
-   */
-  public $build_time;
-
-  /**
-   * How long the view takes to render.
-   *
-   * @var int
+   * @var float
    */
   public $render_time;
 
-  /**
-   * How long the view takes to execute.
-   *
-   * @var int
-   */
-  public $execute_time;
-
   /**
    * If this view is locked for editing.
    *
@@ -636,12 +622,15 @@ class ViewUI implements ViewEntityInterface {
         $this->endQueryCapture();
       }
 
-      $this->render_time = Timer::stop('entity.view.preview_form');
+      $this->render_time = Timer::stop('entity.view.preview_form')['time'];
 
       views_ui_contextual_links_suppress_pop();
 
       // Prepare the query information and statistics to show either above or
       // below the view preview.
+      // Initialise the empty rows arrays so we can safely merge them later.
+      $rows['query'] = [];
+      $rows['statistics'] = [];
       if ($show_info || $show_query || $show_stats) {
         // Get information from the preview for display.
         if (!empty($executable->build_info['query'])) {
@@ -769,7 +758,7 @@ class ViewUI implements ViewEntityInterface {
                   '#template' => "<strong>{% trans 'View render time' %}</strong>",
                 ),
               ),
-              t('@time ms', array('@time' => intval($executable->render_time * 100000) / 100)),
+              t('@time ms', array('@time' => intval($this->render_time * 100) / 100)),
             );
           }
           \Drupal::moduleHandler()->alter('views_preview_info', $rows, $executable);
@@ -818,7 +807,7 @@ class ViewUI implements ViewEntityInterface {
           drupal_set_message($error, 'error');
         }
       }
-      $preview = t('Unable to preview due to validation errors.');
+      $preview = ['#markup' => t('Unable to preview due to validation errors.')];
     }
 
     // Assemble the preview, the query info, and the query statistics in the
@@ -827,26 +816,16 @@ class ViewUI implements ViewEntityInterface {
       '#type' => 'table',
       '#prefix' => '<div class="views-query-info">',
       '#suffix' => '</div>',
+      '#rows' => array_merge($rows['query'], $rows['statistics']),
     );
-    if ($show_location === 'above' || $show_location === 'below') {
-      if ($combined) {
-        $table['#rows'] = array_merge($rows['query'], $rows['statistics']);
-      }
-      else {
-        $table['#rows'] = $rows['query'];
-      }
-    }
-    elseif ($show_stats === 'above' || $show_stats === 'below') {
-      $table['#rows'] = $rows['statistics'];
-    }
 
-    if ($show_location === 'above' || $show_stats === 'above') {
+    if ($show_location == 'above') {
       $output = [
         'table' => $table,
         'preview' => $preview,
       ];
     }
-    elseif ($show_location === 'below' || $show_stats === 'below') {
+    else {
       $output = [
         'preview' => $preview,
         'table' => $table,
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 4d5c950bd..25abf71c4 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -42,7 +42,6 @@
     <exclude name="Drupal.Semantics.RemoteAddress"/>
     <exclude name="Drupal.Strings.UnnecessaryStringConcat"/>
     <exclude name="Drupal.WhiteSpace.CloseBracketSpacing"/>
-    <exclude name="Drupal.WhiteSpace.Comma"/>
     <exclude name="Drupal.WhiteSpace.EmptyLines"/>
     <exclude name="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
     <exclude name="Drupal.WhiteSpace.OpenBracketSpacing"/>
diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist
index 48396388c..2620fe925 100644
--- a/core/phpunit.xml.dist
+++ b/core/phpunit.xml.dist
@@ -1,6 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<phpunit bootstrap="tests/bootstrap.php" colors="true">
+<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
+<phpunit bootstrap="tests/bootstrap.php" colors="true"
+         beStrictAboutTestsThatDoNotTestAnything="true"
+         beStrictAboutOutputDuringTests="true"
+         beStrictAboutChangesToGlobalState="true"
+         checkForUnintentionallyCoveredCode="false">
   <php>
     <!-- Set error reporting to E_ALL. -->
     <ini name="error_reporting" value="32767"/>
diff --git a/core/rebuild.php b/core/rebuild.php
index b401c5a60..ccd4976e9 100644
--- a/core/rebuild.php
+++ b/core/rebuild.php
@@ -42,10 +42,7 @@ if (Settings::get('rebuild_access', FALSE) ||
     ((REQUEST_TIME - $request->get('timestamp')) < 300) &&
     Crypt::hashEquals(Crypt::hmacBase64($request->get('timestamp'), Settings::get('hash_salt')), $request->get('token'))
   )) {
-  // Clear the APC cache to ensure APC class loader is reset.
-  if (function_exists('apc_clear_cache')) {
-    apc_clear_cache('user');
-  }
+  // Clear the APCu cache to ensure APCu class loader is reset.
   if (function_exists('apcu_clear_cache')) {
     apcu_clear_cache();
   }
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index bf46a4018..44657f198 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -17,9 +17,13 @@ use Symfony\Component\HttpFoundation\Request;
 
 $autoloader = require_once __DIR__ . '/../../autoload.php';
 
-const SIMPLETEST_SCRIPT_COLOR_PASS = 32; // Green.
-const SIMPLETEST_SCRIPT_COLOR_FAIL = 31; // Red.
-const SIMPLETEST_SCRIPT_COLOR_EXCEPTION = 33; // Brown.
+// Define some colors for display.
+// A nice calming green.
+const SIMPLETEST_SCRIPT_COLOR_PASS = 32;
+// An alerting Red.
+const SIMPLETEST_SCRIPT_COLOR_FAIL = 31;
+// An annoying brown.
+const SIMPLETEST_SCRIPT_COLOR_EXCEPTION = 33;
 
 // Restricting the chunk of queries prevents memory exhaustion.
 const SIMPLETEST_SCRIPT_SQLITE_VARIABLE_LIMIT = 350;
@@ -58,7 +62,7 @@ if ($args['execute-test']) {
 if ($args['list']) {
   // Display all available tests.
   echo "\nAvailable test groups & classes\n";
-  echo   "-------------------------------\n\n";
+  echo "-------------------------------\n\n";
   try {
     $groups = simpletest_test_get_all($args['module']);
   }
@@ -268,7 +272,8 @@ EOF;
 /**
  * Parse execution argument and ensure that all are valid.
  *
- * @return The list of arguments.
+ * @return array
+ *   The list of arguments.
  */
 function simpletest_script_parse_args() {
   // Set default values.
@@ -334,7 +339,7 @@ function simpletest_script_parse_args() {
     }
   }
 
-  // Validate the concurrency argument
+  // Validate the concurrency argument.
   if (!is_numeric($args['concurrency']) || $args['concurrency'] <= 0) {
     simpletest_script_print_error("--concurrency must be a strictly positive integer.");
     exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
@@ -356,18 +361,20 @@ function simpletest_script_init() {
   $path = '';
   $port = '80';
 
-  // Determine location of php command automatically, unless a command line argument is supplied.
+  // Determine location of php command automatically, unless a command line
+  // argument is supplied.
   if (!empty($args['php'])) {
     $php = $args['php'];
   }
   elseif ($php_env = getenv('_')) {
-    // '_' is an environment variable set by the shell. It contains the command that was executed.
+    // '_' is an environment variable set by the shell. It contains the command
+    // that was executed.
     $php = $php_env;
   }
   elseif ($sudo = getenv('SUDO_COMMAND')) {
     // 'SUDO_COMMAND' is an environment variable set by the sudo program.
     // Extract only the PHP interpreter, not the rest of the command.
-    list($php, ) = explode(' ', $sudo, 2);
+    list($php) = explode(' ', $sudo, 2);
   }
   else {
     simpletest_script_print_error('Unable to automatically determine the path to the PHP interpreter. Supply the --php command line argument.');
@@ -408,11 +415,11 @@ function simpletest_script_init() {
   $_SERVER['SERVER_PORT'] = $port;
   $_SERVER['SERVER_SOFTWARE'] = NULL;
   $_SERVER['SERVER_NAME'] = 'localhost';
-  $_SERVER['REQUEST_URI'] = $path .'/';
+  $_SERVER['REQUEST_URI'] = $path . '/';
   $_SERVER['REQUEST_METHOD'] = 'GET';
-  $_SERVER['SCRIPT_NAME'] = $path .'/index.php';
-  $_SERVER['SCRIPT_FILENAME'] = $path .'/index.php';
-  $_SERVER['PHP_SELF'] = $path .'/index.php';
+  $_SERVER['SCRIPT_NAME'] = $path . '/index.php';
+  $_SERVER['SCRIPT_FILENAME'] = $path . '/index.php';
+  $_SERVER['PHP_SELF'] = $path . '/index.php';
   $_SERVER['HTTP_USER_AGENT'] = 'Drupal command line';
 
   if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
@@ -459,7 +466,6 @@ function simpletest_script_setup_database($new = FALSE) {
   // hold the default database connection already. This connection is assumed to
   // be valid, and this connection will be used in tests, so that they run
   // against e.g. MySQL instead of SQLite.
-
   // However, in case no Drupal installation exists, this default database
   // connection can be set and/or overridden with the --dburl parameter.
   if (!empty($args['dburl'])) {
@@ -619,12 +625,15 @@ function simpletest_script_execute_batch($test_classes) {
           echo $message . "\n";
           // Insert a fail for xml results.
           TestBase::insertAssert($child['test_id'], $child['class'], FALSE, $message, 'run-tests.sh check');
-          /// Ensure that an error line is displayed for the class.
-          simpletest_script_reporter_display_summary($child['class'], ['#pass' => 0, '#fail' => 1, '#exception' => 0, '#debug' => 0]);
+          // Ensure that an error line is displayed for the class.
+          simpletest_script_reporter_display_summary(
+            $child['class'],
+            ['#pass' => 0, '#fail' => 1, '#exception' => 0, '#debug' => 0]
+          );
           if ($args['die-on-fail']) {
-            list($db_prefix, ) = simpletest_last_test_get($child['test_id']);
+            list($db_prefix) = simpletest_last_test_get($child['test_id']);
             $test_directory = 'sites/simpletest/' . substr($db_prefix, 10);
-            echo 'Simpletest database and files kept and test exited immediately on fail so should be reproducible if you change settings.php to use the database prefix '. $db_prefix . ' and config directories in '. $test_directory . "\n";
+            echo 'Simpletest database and files kept and test exited immediately on fail so should be reproducible if you change settings.php to use the database prefix ' . $db_prefix . ' and config directories in ' . $test_directory . "\n";
             $args['keep-results'] = TRUE;
             // Exit repeat loop immediately.
             $args['repeat'] = -1;
@@ -644,7 +653,7 @@ function simpletest_script_execute_batch($test_classes) {
 }
 
 /**
- * Run a group of phpunit tests.
+ * Run a PHPUnit-based test.
  */
 function simpletest_script_run_phpunit($test_id, $class) {
   $reflection = new \ReflectionClass($class);
@@ -672,12 +681,15 @@ function simpletest_script_run_phpunit($test_id, $class) {
       case 'pass':
         $summaries[$result['test_class']]['#pass']++;
         break;
+
       case 'fail':
         $summaries[$result['test_class']]['#fail']++;
         break;
+
       case 'exception':
         $summaries[$result['test_class']]['#exception']++;
         break;
+
       case 'debug':
         $summaries[$result['test_class']]['#debug']++;
         break;
@@ -691,7 +703,7 @@ function simpletest_script_run_phpunit($test_id, $class) {
 }
 
 /**
- * Bootstrap Drupal and run a single test.
+ * Run a single test, bootstrapping Drupal if needed.
  */
 function simpletest_script_run_one_test($test_id, $test_class) {
   global $args;
@@ -736,10 +748,13 @@ function simpletest_script_run_one_test($test_id, $test_class) {
 /**
  * Return a command used to run a test in a separate process.
  *
- * @param $test_id
- *  The current test ID.
- * @param $test_class
- *  The name of the test class to run.
+ * @param int $test_id
+ *   The current test ID.
+ * @param string $test_class
+ *   The name of the test class to run.
+ *
+ * @return string
+ *   The assembled command string.
  */
 function simpletest_script_command($test_id, $test_class) {
   global $args, $php;
@@ -792,7 +807,7 @@ function simpletest_script_cleanup($test_id, $test_class, $exitcode) {
   }
   // Retrieve the last database prefix used for testing.
   try {
-    list($db_prefix,) = simpletest_last_test_get($test_id);
+    list($db_prefix) = simpletest_last_test_get($test_id);
   }
   catch (Exception $e) {
     echo (string) $e;
@@ -864,12 +879,13 @@ function simpletest_script_cleanup($test_id, $test_class, $exitcode) {
 }
 
 /**
- * Get list of tests based on arguments. If --all specified then
- * returns all available tests, otherwise reads list of tests.
+ * Get list of tests based on arguments.
  *
- * Will print error and exit if no valid tests were found.
+ * If --all specified then return all available tests, otherwise reads list of
+ * tests.
  *
- * @return List of tests.
+ * @return array
+ *   List of tests.
  */
 function simpletest_script_get_test_list() {
   global $args;
@@ -893,7 +909,7 @@ function simpletest_script_get_test_list() {
     if ($args['class']) {
       $test_list = array();
       foreach ($args['test_names'] as $test_class) {
-        list($class_name, ) = explode('::', $test_class, 2);
+        list($class_name) = explode('::', $test_class, 2);
         if (class_exists($class_name)) {
           $test_list[] = $test_class;
         }
@@ -964,13 +980,13 @@ function simpletest_script_get_test_list() {
         // '/Tests/' can be contained anywhere in the file's path (there can be
         // sub-directories below /Tests), but must be contained literally.
         // Case-insensitive to match all Simpletest and PHPUnit tests:
-        //   ./lib/Drupal/foo/Tests/Bar/Baz.php
-        //   ./foo/src/Tests/Bar/Baz.php
-        //   ./foo/tests/Drupal/foo/Tests/FooTest.php
-        //   ./foo/tests/src/FooTest.php
+        // ./lib/Drupal/foo/Tests/Bar/Baz.php
+        // ./foo/src/Tests/Bar/Baz.php
+        // ./foo/tests/Drupal/foo/Tests/FooTest.php
+        // ./foo/tests/src/FooTest.php
         // $file->filename doesn't give us a directory, so we use $file->uri
-        // Strip the drupal root directory and trailing slash off the URI
-        $filename = substr($file->uri, strlen(DRUPAL_ROOT)+1);
+        // Strip the drupal root directory and trailing slash off the URI.
+        $filename = substr($file->uri, strlen(DRUPAL_ROOT) + 1);
         if (stripos($filename, '/Tests/')) {
           $files[$filename] = $filename;
         }
@@ -1035,7 +1051,7 @@ function simpletest_script_reporter_init() {
   $results_map = array(
     'pass' => 'Pass',
     'fail' => 'Fail',
-    'exception' => 'Exception'
+    'exception' => 'Exception',
   );
 
   echo "\n";
@@ -1079,10 +1095,10 @@ function simpletest_script_reporter_display_summary($class, $results) {
   // by default (more than 999 assertions are rare).
   $output = vsprintf('%-60.60s %10s %9s %14s %12s', array(
     $class,
-                                   $results['#pass']      . ' passes',
-    !$results['#fail']      ? '' : $results['#fail']      . ' fails',
+    $results['#pass'] . ' passes',
+    !$results['#fail'] ? '' : $results['#fail'] . ' fails',
     !$results['#exception'] ? '' : $results['#exception'] . ' exceptions',
-    !$results['#debug']     ? '' : $results['#debug']     . ' messages',
+    !$results['#debug'] ? '' : $results['#debug'] . ' messages',
   ));
 
   $status = ($results['#fail'] || $results['#exception'] ? 'fail' : 'pass');
@@ -1109,7 +1125,8 @@ function simpletest_script_reporter_write_xml_results() {
   foreach ($results as $result) {
     if (isset($results_map[$result->status])) {
       if ($result->test_class != $test_class) {
-        // We've moved onto a new class, so write the last classes results to a file:
+        // We've moved onto a new class, so write the last classes results to a
+        // file:
         if (isset($xml_files[$test_class])) {
           file_put_contents($args['xml'] . '/' . str_replace('\\', '_', $test_class) . '.xml', $xml_files[$test_class]['doc']->saveXML());
           unset($xml_files[$test_class]);
@@ -1137,7 +1154,8 @@ function simpletest_script_reporter_write_xml_results() {
       }
       $case->setAttribute('name', $name);
 
-      // Passes get no further attention, but failures and exceptions get to add more detail:
+      // Passes get no further attention, but failures and exceptions get to add
+      // more detail:
       if ($result->status == 'fail') {
         $fail = $dom_document->createElement('failure');
         $fail->setAttribute('type', 'failure');
@@ -1218,10 +1236,10 @@ function simpletest_script_reporter_display_results() {
 }
 
 /**
- * Format the result so that it fits within the default 80 character
- * terminal size.
+ * Format the result so that it fits within 80 characters.
  *
- * @param $result The result object to format.
+ * @param object $result
+ *   The result object to format.
  */
 function simpletest_script_format_result($result) {
   global $args, $results_map, $color;
@@ -1242,21 +1260,25 @@ function simpletest_script_format_result($result) {
 }
 
 /**
- * Print error message prefixed with "  ERROR: " and displayed in fail color
- * if color output is enabled.
+ * Print error messages so the user will notice them.
  *
- * @param $message The message to print.
+ * Print error message prefixed with "  ERROR: " and displayed in fail color if
+ * color output is enabled.
+ *
+ * @param string $message
+ *   The message to print.
  */
 function simpletest_script_print_error($message) {
   simpletest_script_print("  ERROR: $message\n", SIMPLETEST_SCRIPT_COLOR_FAIL);
 }
 
 /**
- * Print a message to the console, if color is enabled then the specified
- * color code will be used.
+ * Print a message to the console, using a color.
  *
- * @param $message The message to print.
- * @param $color_code The color code to use for coloring.
+ * @param string $message
+ *   The message to print.
+ * @param int $color_code
+ *   The color code to use for coloring.
  */
 function simpletest_script_print($message, $color_code) {
   global $args;
@@ -1271,19 +1293,26 @@ function simpletest_script_print($message, $color_code) {
 /**
  * Get the color code associated with the specified status.
  *
- * @param $status The status string to get code for.
- * @return Color code.
+ * @param string $status
+ *   The status string to get code for. Special cases are: 'pass', 'fail', or
+ *   'exception'.
+ *
+ * @return int
+ *   Color code. Returns 0 for default case.
  */
 function simpletest_script_color_code($status) {
   switch ($status) {
     case 'pass':
       return SIMPLETEST_SCRIPT_COLOR_PASS;
+
     case 'fail':
       return SIMPLETEST_SCRIPT_COLOR_FAIL;
+
     case 'exception':
       return SIMPLETEST_SCRIPT_COLOR_EXCEPTION;
   }
-  return 0; // Default formatting.
+  // Default formatting.
+  return 0;
 }
 
 /**
@@ -1292,8 +1321,6 @@ function simpletest_script_color_code($status) {
  * Searches the provided array of string values for close matches based on the
  * Levenshtein algorithm.
  *
- * @see http://php.net/manual/en/function.levenshtein.php
- *
  * @param string $string
  *   A string to test.
  * @param array $array
@@ -1303,6 +1330,8 @@ function simpletest_script_color_code($status) {
  *   4 means that the function will return strings from $array if the candidate
  *   string in $array would be identical to $string by changing 1/4 or fewer of
  *   its characters.
+ *
+ * @see http://php.net/manual/en/function.levenshtein.php
  */
 function simpletest_script_print_alternatives($string, $array, $degree = 4) {
   $alternatives = array();
@@ -1391,7 +1420,11 @@ function simpletest_script_open_browser() {
   // Get the assets to make the details element collapsible and theme the result
   // form.
   $assets = new \Drupal\Core\Asset\AttachedAssets();
-  $assets->setLibraries(['core/drupal.collapse', 'system/admin', 'simpletest/drupal.simpletest']);
+  $assets->setLibraries([
+    'core/drupal.collapse',
+    'system/admin',
+    'simpletest/drupal.simpletest',
+  ]);
   $resolver = \Drupal::service('asset.resolver');
   list($js_assets_header, $js_assets_footer) = $resolver->getJsAssets($assets, FALSE);
   $js_collection_renderer = \Drupal::service('asset.js.collection_renderer');
@@ -1401,14 +1434,14 @@ function simpletest_script_open_browser() {
 
   // Make the html page to write to disk.
   $render_service = \Drupal::service('renderer');
-  $html = '<head>' . $render_service->renderPlain($js_assets_header) . $render_service->renderPlain($css_assets) . '</head><body>' . $render_service->renderPlain($form) . $render_service->renderPlain($js_assets_footer) .'</body>';
+  $html = '<head>' . $render_service->renderPlain($js_assets_header) . $render_service->renderPlain($css_assets) . '</head><body>' . $render_service->renderPlain($form) . $render_service->renderPlain($js_assets_footer) . '</body>';
 
-  // Ensure we have assets verbose directory - tests with no verbose output will not
-  // have created one.
+  // Ensure we have assets verbose directory - tests with no verbose output will
+  // not have created one.
   $directory = PublicStream::basePath() . '/simpletest/verbose';
   file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
   $uuid = new Php();
-  $filename = $directory .'/results-'. $uuid->generate() .'.html';
+  $filename = $directory . '/results-' . $uuid->generate() . '.html';
   file_put_contents($filename, $html);
 
   // See if we can find an OS helper to open URLs in default browser.
diff --git a/core/tests/Drupal/KernelTests/AssertConfigTrait.php b/core/tests/Drupal/KernelTests/AssertConfigTrait.php
index 24d393e77..203e85f04 100644
--- a/core/tests/Drupal/KernelTests/AssertConfigTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertConfigTrait.php
@@ -74,6 +74,10 @@ trait AssertConfigTrait {
           }
           break;
         case 'Drupal\Component\Diff\Engine\DiffOpAdd':
+          // The _core property does not exist in the default config.
+          if ($op->closing[0] === '_core:') {
+            continue;
+          }
           foreach ($op->closing as $closing) {
             // The UUIDs don't exist in the default config.
             if (strpos($closing, 'uuid: ') === 0)  {
diff --git a/core/tests/Drupal/KernelTests/Core/Cache/CacheCollectorTest.php b/core/tests/Drupal/KernelTests/Core/Cache/CacheCollectorTest.php
index e9ca67a0a..c05d63046 100644
--- a/core/tests/Drupal/KernelTests/Core/Cache/CacheCollectorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Cache/CacheCollectorTest.php
@@ -25,7 +25,7 @@ class CacheCollectorTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->installSchema('system', ['semaphore']);
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php b/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php
index 504675e9e..9b597c62b 100644
--- a/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php
@@ -25,7 +25,7 @@ class DrupalSetMessageTest extends KernelTestBase {
     $this->assertEquals('A message: bar', (string) $messages['status'][0]);
   }
 
-  public function tearDown() {
+  protected function tearDown() {
     // Clear session to prevent global leakage.
     unset($_SESSION['messages']);
     parent::tearDown();
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php
index 69d9e8c61..d0578afef 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php
@@ -48,7 +48,7 @@ class StableTemplateOverrideTest extends KernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->themeHandler = $this->container->get('theme_handler');
 
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index fd7b86436..f1a141425 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -235,8 +235,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
     $this->streamWrappers = array();
     \Drupal::unsetContainer();
 
-    // @see /core/tests/bootstrap.php
-    $this->classLoader = $GLOBALS['loader'];
+    $this->classLoader = require $this->root . '/autoload.php';
 
     require_once $this->root . '/core/includes/bootstrap.inc';
 
@@ -407,7 +406,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
     // If the test is run with argument dburl then use it.
     $db_url = getenv('SIMPLETEST_DB');
     if (empty($db_url)) {
-      $this->markTestSkipped('There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.');
+      throw new \Exception('There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.');
     }
     else {
       $database = Database::convertDbUrlToConnectionInfo($db_url, $this->root);
@@ -509,7 +508,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
       ];
       // @todo Use extension_loaded('apcu') for non-testbot
       //  https://www.drupal.org/node/2447753.
-      if (function_exists('apc_fetch')) {
+      if (function_exists('apcu_fetch')) {
         $configuration['default']['cache_backend_class'] = ApcuFileCacheBackend::class;
       }
     }
@@ -787,6 +786,12 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
   /**
    * Enables modules for this test.
    *
+   * To install test modules outside of the testing environment, add
+   * @code
+   * $settings['extension_discovery_scan_tests'] = TRUE;
+   * @encode
+   * to your settings.php.
+   *
    * @param string[] $modules
    *   A list of modules to enable. Dependencies are not resolved; i.e.,
    *   multiple modules have to be specified individually. The modules are only
@@ -882,7 +887,8 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
     // Update the kernel to remove their services.
     $this->container->get('kernel')->updateModules($module_filenames, $module_filenames);
 
-    // Ensure isLoaded() is TRUE in order to make _theme() work.
+    // Ensure isLoaded() is TRUE in order to make
+    // \Drupal\Core\Theme\ThemeManagerInterface::render() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $module_handler = $this->container->get('module_handler');
@@ -1116,4 +1122,22 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
     }
   }
 
+  /**
+   * Prevents serializing any properties.
+   *
+   * Kernel tests are run in a separate process. To do this PHPUnit creates a
+   * script to run the test. If it fails, the test result object will contain a
+   * stack trace which includes the test object. It will attempt to serialize
+   * it. Returning an empty array prevents it from serializing anything it
+   * should not.
+   *
+   * @return array
+   *   An empty array.
+   *
+   * @see vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist
+   */
+  public function __sleep() {
+    return [];
+  }
+
 }
diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
index 259233347..56a03b3c0 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
@@ -376,7 +376,7 @@ class DateTimePlusTest extends UnitTestCase {
       // Test for invalid minute from date array.
       array(array('year' => 2010, 'month' => 7, 'day' => 8, 'hour' => 8, 'minute' => 88, 'second' => 0), 'America/Chicago'),
       // Regression test for https://www.drupal.org/node/2084455.
-      array(array('hour' => 59, 'minute' => 1,'second' => 1), 'America/Chicago'),
+      array(array('hour' => 59, 'minute' => 1, 'second' => 1), 'America/Chicago'),
     );
   }
 
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
index 21f6f5f17..5721c64a9 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
@@ -49,7 +49,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->machineFormat = TRUE;
     $this->containerClass = '\Drupal\Component\DependencyInjection\Container';
     $this->containerDefinition = $this->getMockContainerDefinition();
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
index ca9a2e475..cf4d8227f 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
@@ -58,7 +58,7 @@ namespace Drupal\Tests\Component\DependencyInjection\Dumper {
     /**
      * {@inheritdoc}
      */
-    public function setUp() {
+    protected function setUp() {
       // Setup a mock container builder.
       $this->containerBuilder = $this->prophesize('\Symfony\Component\DependencyInjection\ContainerBuilder');
       $this->containerBuilder->getAliases()->willReturn(array());
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php
index 55e9a5f23..d97710864 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/PhpArrayDumperTest.php
@@ -18,7 +18,7 @@ class PhpArrayDumperTest extends OptimizedPhpArrayDumperTest {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->machineFormat = FALSE;
     $this->dumperClass = '\Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper';
     parent::setUp();
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php
index 3a9f4fc86..76f5d1631 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/PhpArrayContainerTest.php
@@ -18,7 +18,7 @@ class PhpArrayContainerTest extends ContainerTest {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->machineFormat = FALSE;
     $this->containerClass = '\Drupal\Component\DependencyInjection\PhpArrayContainer';
     $this->containerDefinition = $this->getMockContainerDefinition();
diff --git a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
index f36d8368f..22b745ba7 100644
--- a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
+++ b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
@@ -25,7 +25,7 @@ use Symfony\Component\EventDispatcher\Tests\TestEventListener;
  *
  * @see https://github.com/symfony/symfony/pull/12521
  *
- * @group Symfony
+ * @group EventDispatcher
  */
 class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
 {
diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
index 42984c425..040573da7 100644
--- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
@@ -81,7 +81,7 @@ class HtmlTest extends UnitTestCase {
       // Verify that an identifier starting with two hyphens is replaced.
       array('__cssidentifier', '--cssidentifier', array()),
       // Verify that passing double underscores as a filter is processed.
-      array('_cssidentifier', '__cssidentifier',  array('__' => '_')),
+      array('_cssidentifier', '__cssidentifier', array('__' => '_')),
     );
   }
 
diff --git a/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php b/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
index 44110958b..271de1b16 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
@@ -30,7 +30,7 @@ class SortArrayTest extends UnitTestCase {
    *   The first input array for the SortArray::sortByWeightElement() method.
    * @param array $b
    *   The second input array for the SortArray::sortByWeightElement().
-   * @param integer $expected
+   * @param int $expected
    *   The expected output from calling the method.
    */
   public function testSortByWeightElement($a, $b, $expected) {
@@ -106,7 +106,7 @@ class SortArrayTest extends UnitTestCase {
    *   The first input array for the SortArray::sortByWeightProperty() method.
    * @param array $b
    *   The second input array for the SortArray::sortByWeightProperty().
-   * @param integer $expected
+   * @param int $expected
    *   The expected output from calling the method.
    */
   public function testSortByWeightProperty($a, $b, $expected) {
@@ -182,7 +182,7 @@ class SortArrayTest extends UnitTestCase {
    *   The first input item for comparison.
    * @param array $b
    *   The second item for comparison.
-   * @param integer $expected
+   * @param int $expected
    *   The expected output from calling the method.
    */
   public function testSortByTitleElement($a, $b, $expected) {
@@ -251,7 +251,7 @@ class SortArrayTest extends UnitTestCase {
    *   The first input item for comparison.
    * @param array $b
    *   The second item for comparison.
-   * @param integer $expected
+   * @param int $expected
    *   The expected output from calling the method.
    */
   public function testSortByTitleProperty($a, $b, $expected) {
diff --git a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
index e8100b89e..a1dc33d1f 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
@@ -24,7 +24,7 @@ class UnicodeTest extends UnitTestCase {
    *
    * @covers ::check
    */
-  public function setUp() {
+  protected function setUp() {
     // Initialize unicode component.
     Unicode::check();
   }
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
index b0c4b98df..9c04041ae 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
@@ -217,8 +217,8 @@ class AccessManagerTest extends UnitTestCase {
     $this->assertEquals(TRUE, $this->accessManager->check($route_matches['test_route_4'], $this->account));
     $this->assertEquals(AccessResult::neutral(), $this->accessManager->check($route_matches['test_route_1'], $this->account, NULL, TRUE));
     $this->assertEquals(AccessResult::allowed(), $this->accessManager->check($route_matches['test_route_2'], $this->account, NULL, TRUE));
-    $this->assertEquals(AccessResult::forbidden(), $this->accessManager->check($route_matches['test_route_3'],  $this->account, NULL, TRUE));
-    $this->assertEquals(AccessResult::allowed(), $this->accessManager->check($route_matches['test_route_4'],  $this->account, NULL, TRUE));
+    $this->assertEquals(AccessResult::forbidden(), $this->accessManager->check($route_matches['test_route_3'], $this->account, NULL, TRUE));
+    $this->assertEquals(AccessResult::allowed(), $this->accessManager->check($route_matches['test_route_4'], $this->account, NULL, TRUE));
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
index e8af81623..997636112 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
@@ -97,9 +97,9 @@ class LibraryDependencyResolverTest extends UnitTestCase {
       [['test/nested_deps_c'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
       [['test/nested_deps_a', 'test/nested_deps_b'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b']],
       [['test/nested_deps_b', 'test/nested_deps_a'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b']],
-      [['test/nested_deps_a', 'test/nested_deps_c'],                       ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
-      [['test/nested_deps_b', 'test/nested_deps_c'],                       ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
-      [['test/nested_deps_c', 'test/nested_deps_a'],                       ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
+      [['test/nested_deps_a', 'test/nested_deps_c'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
+      [['test/nested_deps_b', 'test/nested_deps_c'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
+      [['test/nested_deps_c', 'test/nested_deps_a'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
       [['test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
       [['test/nested_deps_a', 'test/nested_deps_c', 'test/nested_deps_b'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
       [['test/nested_deps_b', 'test/nested_deps_a', 'test/nested_deps_c'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
@@ -107,7 +107,7 @@ class LibraryDependencyResolverTest extends UnitTestCase {
       [['test/nested_deps_c', 'test/nested_deps_a', 'test/nested_deps_b'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
       [['test/nested_deps_c', 'test/nested_deps_b', 'test/nested_deps_a'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c']],
       // Complex dependencies, combining the above, with many intersections.
-      [['test/deps_c', 'test/nested_deps_b'],                   ['test/no_deps_b', 'test/no_deps_a', 'test/deps_c', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b']],
+      [['test/deps_c', 'test/nested_deps_b'], ['test/no_deps_b', 'test/no_deps_a', 'test/deps_c', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b']],
       [['test/no_deps_a', 'test/deps_c', 'test/nested_deps_b'], ['test/no_deps_a', 'test/no_deps_b', 'test/deps_c', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b']],
       [['test/nested_deps_b', 'test/deps_c', 'test/no_deps_c'], ['test/no_deps_a', 'test/deps_a', 'test/nested_deps_a', 'test/nested_deps_b', 'test/no_deps_b', 'test/deps_c', 'test/no_deps_c']],
     ];
@@ -149,9 +149,9 @@ class LibraryDependencyResolverTest extends UnitTestCase {
       [['test/nested_deps_c'], ['test/nested_deps_c']],
       [['test/nested_deps_a', 'test/nested_deps_b'], ['test/nested_deps_b']],
       [['test/nested_deps_b', 'test/nested_deps_a'], ['test/nested_deps_b']],
-      [['test/nested_deps_a', 'test/nested_deps_c'],                       ['test/nested_deps_c']],
-      [['test/nested_deps_b', 'test/nested_deps_c'],                       ['test/nested_deps_c']],
-      [['test/nested_deps_c', 'test/nested_deps_a'],                       ['test/nested_deps_c']],
+      [['test/nested_deps_a', 'test/nested_deps_c'], ['test/nested_deps_c']],
+      [['test/nested_deps_b', 'test/nested_deps_c'], ['test/nested_deps_c']],
+      [['test/nested_deps_c', 'test/nested_deps_a'], ['test/nested_deps_c']],
       [['test/nested_deps_a', 'test/nested_deps_b', 'test/nested_deps_c'], ['test/nested_deps_c']],
       [['test/nested_deps_a', 'test/nested_deps_c', 'test/nested_deps_b'], ['test/nested_deps_c']],
       [['test/nested_deps_b', 'test/nested_deps_a', 'test/nested_deps_c'], ['test/nested_deps_c']],
@@ -159,7 +159,7 @@ class LibraryDependencyResolverTest extends UnitTestCase {
       [['test/nested_deps_c', 'test/nested_deps_a', 'test/nested_deps_b'], ['test/nested_deps_c']],
       [['test/nested_deps_c', 'test/nested_deps_b', 'test/nested_deps_a'], ['test/nested_deps_c']],
       // Complex dependencies, combining the above, with many intersections.
-      [['test/deps_c', 'test/nested_deps_b'],                   ['test/deps_c', 'test/nested_deps_b']],
+      [['test/deps_c', 'test/nested_deps_b'], ['test/deps_c', 'test/nested_deps_b']],
       [['test/no_deps_a', 'test/deps_c', 'test/nested_deps_b'], ['test/deps_c', 'test/nested_deps_b']],
       [['test/nested_deps_b', 'test/deps_c', 'test/no_deps_c'], ['test/nested_deps_b', 'test/deps_c', 'test/no_deps_c']],
     ];
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigFactoryTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigFactoryTest.php
index 05d93114f..c06471acd 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigFactoryTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigFactoryTest.php
@@ -56,7 +56,7 @@ class ConfigFactoryTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->storage = $this->getMock('Drupal\Core\Config\StorageInterface');
     $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
     $this->typedConfig = $this->getMock('\Drupal\Core\Config\TypedConfigManagerInterface');
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
index a7ff94b79..e198bb347 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
@@ -58,7 +58,7 @@ class ConfigTest extends UnitTestCase {
    */
   protected $cacheTagsInvalidator;
 
-  public function setUp() {
+  protected function setUp() {
     $this->storage = $this->getMock('Drupal\Core\Config\StorageInterface');
     $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
     $this->typedConfig = $this->getMock('\Drupal\Core\Config\TypedConfigManagerInterface');
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
index 97bf172c7..8104efc32 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
@@ -163,6 +163,7 @@ class ConfigEntityTypeTest extends UnitTestCase {
         'status' => 'status',
         'dependencies' => 'dependencies',
         'third_party_settings' => 'third_party_settings',
+        '_core' => '_core',
         'id' => 'id',
         'custom_property' => 'customProperty',
       ],
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/StackedKernelPassTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/StackedKernelPassTest.php
index cbcae164d..537d705d2 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/StackedKernelPassTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/StackedKernelPassTest.php
@@ -33,7 +33,7 @@ class StackedKernelPassTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->stackedKernelPass = new StackedKernelPass();
     $this->containerBuilder = new ContainerBuilder();
   }
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
index c63cef87b..a44e6fc8c 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@@ -145,7 +145,7 @@ class EntityFieldManagerTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->container = $this->prophesize(ContainerInterface::class);
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php
index 1c19b15e9..7e19b3888 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php
@@ -76,13 +76,13 @@ class ModuleRouteSubscriberTest extends UnitTestCase {
     return array(
       array('enabled', array('_module_dependencies' => 'enabled'), FALSE),
       array('disabled', array('_module_dependencies' => 'disabled'), TRUE),
-      array('enabled_or',  array('_module_dependencies' => 'disabled,enabled'), FALSE),
-      array('enabled_or',  array('_module_dependencies' => 'enabled,disabled'), FALSE),
-      array('disabled_or',  array('_module_dependencies' => 'disabled,disabled'), TRUE),
-      array('enabled_and',  array('_module_dependencies' => 'enabled+enabled'), FALSE),
-      array('enabled_and',  array('_module_dependencies' => 'enabled+disabled'), TRUE),
-      array('enabled_and',  array('_module_dependencies' => 'disabled+enabled'), TRUE),
-      array('disabled_and',  array('_module_dependencies' => 'disabled+disabled'), TRUE),
+      array('enabled_or', array('_module_dependencies' => 'disabled,enabled'), FALSE),
+      array('enabled_or', array('_module_dependencies' => 'enabled,disabled'), FALSE),
+      array('disabled_or', array('_module_dependencies' => 'disabled,disabled'), TRUE),
+      array('enabled_and', array('_module_dependencies' => 'enabled+enabled'), FALSE),
+      array('enabled_and', array('_module_dependencies' => 'enabled+disabled'), TRUE),
+      array('enabled_and', array('_module_dependencies' => 'disabled+enabled'), TRUE),
+      array('disabled_and', array('_module_dependencies' => 'disabled+disabled'), TRUE),
       array('no_dependencies', array(), FALSE),
     );
   }
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php
index 2e3552ef4..9d89f4d67 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php
@@ -33,7 +33,7 @@ class PsrResponseSubscriberTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $factory = $this->getMock('Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface', [], [], '', NULL);
     $factory
       ->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php
index 71c90bf5f..7eb807f53 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php
@@ -14,8 +14,6 @@ use Drupal\Tests\UnitTestCase;
 /**
  * @coversDefaultClass \Drupal\Core\Form\FormCache
  * @group Form
- * @runTestsInSeparateProcesses
- * @preserveGlobalState disabled
  */
 class FormCacheTest extends UnitTestCase {
 
@@ -89,6 +87,16 @@ class FormCacheTest extends UnitTestCase {
    */
   protected $requestPolicy;
 
+  /**
+   * {@inheritdoc}
+   */
+  protected $runTestInSeparateProcess = TRUE;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $preserveGlobalState = FALSE;
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/tests/Drupal/Tests/Core/Http/ClientFactoryTest.php b/core/tests/Drupal/Tests/Core/Http/ClientFactoryTest.php
index 780616820..8aeb6c269 100644
--- a/core/tests/Drupal/Tests/Core/Http/ClientFactoryTest.php
+++ b/core/tests/Drupal/Tests/Core/Http/ClientFactoryTest.php
@@ -27,7 +27,7 @@ class ClientFactoryTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $stack = $this->getMockBuilder('GuzzleHttp\HandlerStack')
       ->disableOriginalConstructor()
       ->getMock();
diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
index e81bb768a..d39d8ca84 100644
--- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php
+++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
@@ -47,7 +47,7 @@ class ImageTest extends UnitTestCase {
   protected $toolkitOperation;
 
   /**
-   * @inheritdoc
+   * {@inheritdoc}
    */
   protected function setUp() {
     // Use the Druplicon image.
diff --git a/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php b/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
index 334373557..a0a852455 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
@@ -32,7 +32,7 @@ class ChainRequestPolicyTest extends UnitTestCase {
    */
   protected $request;
 
-  public function setUp() {
+  protected function setUp() {
     $this->policy = new ChainRequestPolicy();
     $this->request = new Request();
   }
diff --git a/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php b/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php
index d9916782d..d6de353fe 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php
@@ -40,7 +40,7 @@ class ChainResponsePolicyTest extends UnitTestCase {
    */
   protected $response;
 
-  public function setUp() {
+  protected function setUp() {
     $this->policy = new ChainResponsePolicy();
     $this->response = new Response();
     $this->request = new Request();
diff --git a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
index bb54fbca0..0a54a9f95 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
@@ -24,7 +24,7 @@ class CommandLineOrUnsafeMethodTest extends UnitTestCase {
    */
   protected $policy;
 
-  public function setUp() {
+  protected function setUp() {
     // Note that it is necessary to partially mock the class under test in
     // order to disable the isCli-check.
     $this->policy = $this->getMock('Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod', array('isCli'));
diff --git a/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php b/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php
index b6486c59e..d7668822e 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/NoSessionOpenTest.php
@@ -32,7 +32,7 @@ class NoSessionOpenTest extends UnitTestCase {
    */
   protected $policy;
 
-  public function setUp() {
+  protected function setUp() {
     $this->sessionConfiguration = $this->getMock('Drupal\Core\Session\SessionConfigurationInterface');
     $this->policy = new RequestPolicy\NoSessionOpen($this->sessionConfiguration);
   }
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
index 5d1c22d7b..36207f138 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@@ -43,7 +43,7 @@ class ContextTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
 
     $this->typedDataManager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager')
diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
index b343e3b86..90b19f4da 100644
--- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
@@ -49,7 +49,7 @@ class AccessAwareRouterTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     parent::setUp();
     $this->route = new Route('test');
     $this->accessManager = $this->getMock('Drupal\Core\Access\AccessManagerInterface');
diff --git a/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php b/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php
index f48117982..02285820d 100644
--- a/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php
@@ -32,7 +32,7 @@ class WriteSafeSessionHandlerTest extends UnitTestCase {
    */
   protected $sessionHandler;
 
-  public function setUp() {
+  protected function setUp() {
     $this->wrappedSessionHandler = $this->getMock('SessionHandlerInterface');
     $this->sessionHandler = new WriteSafeSessionHandler($this->wrappedSessionHandler);
   }
diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
index df5729088..60506f68b 100644
--- a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
+++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
@@ -27,7 +27,7 @@ class ReverseProxyMiddlewareTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
+  protected function setUp() {
     $this->mockHttpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php b/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php
index 80eed7a13..fc35ec578 100644
--- a/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Tests\Core\Template;
 
+use Drupal\Core\Template\Attribute;
 use Drupal\Core\Template\TwigSandboxPolicy;
 use Drupal\Core\Template\Loader\StringLoader;
 use Drupal\Tests\UnitTestCase;
@@ -64,6 +65,13 @@ class TwigSandboxTest extends UnitTestCase {
     ];
   }
 
+  /**
+   * Tests that white listed classes can be extended.
+   */
+  public function testExtendedClass() {
+    $this->twig->render('{{ attribute.addClass("kitten") }}', ['attribute' => new TestAttribute()]);
+  }
+
   /**
    * Tests that prefixed methods can be called from within Twig templates.
    *
@@ -133,3 +141,5 @@ class TwigSandboxTest extends UnitTestCase {
   }
 
 }
+
+class TestAttribute extends Attribute {}
diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php
index 626f4ba86..f1f786255 100644
--- a/core/tests/bootstrap.php
+++ b/core/tests/bootstrap.php
@@ -87,22 +87,41 @@ function drupal_phpunit_get_extension_namespaces($dirs) {
 if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
   define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/../../autoload.php');
 }
-// Start with classes in known locations.
-$loader = require __DIR__ . '/../../autoload.php';
-$loader->add('Drupal\\Tests', __DIR__);
-$loader->add('Drupal\\KernelTests', __DIR__);
 
-if (!isset($GLOBALS['namespaces'])) {
-  // Scan for arbitrary extension namespaces from core and contrib.
-  $extension_roots = drupal_phpunit_contrib_extension_directory_roots();
+/**
+ * Populate class loader with additional namespaces for tests.
+ *
+ * We run this in a function to avoid setting the class loader to a global
+ * that can change. This change can cause unpredictable false positives for
+ * phpunit's global state change watcher. The class loader can be retrieved from
+ * composer at any time by requiring autoload.php.
+ */
+function drupal_phpunit_populate_class_loader() {
 
-  $dirs = array_map('drupal_phpunit_find_extension_directories', $extension_roots);
-  $dirs = array_reduce($dirs, 'array_merge', array());
-  $GLOBALS['namespaces'] = drupal_phpunit_get_extension_namespaces($dirs);
-}
-foreach ($GLOBALS['namespaces'] as $prefix => $paths) {
-  $loader->addPsr4($prefix, $paths);
-}
+  /** @var \Composer\Autoload\ClassLoader $loader */
+  $loader = require __DIR__ . '/../../autoload.php';
+
+  // Start with classes in known locations.
+  $loader->add('Drupal\\Tests', __DIR__);
+  $loader->add('Drupal\\KernelTests', __DIR__);
+
+  if (!isset($GLOBALS['namespaces'])) {
+    // Scan for arbitrary extension namespaces from core and contrib.
+    $extension_roots = drupal_phpunit_contrib_extension_directory_roots();
+
+    $dirs = array_map('drupal_phpunit_find_extension_directories', $extension_roots);
+    $dirs = array_reduce($dirs, 'array_merge', array());
+    $GLOBALS['namespaces'] = drupal_phpunit_get_extension_namespaces($dirs);
+  }
+  foreach ($GLOBALS['namespaces'] as $prefix => $paths) {
+    $loader->addPsr4($prefix, $paths);
+  }
+
+  return $loader;
+};
+
+// Do class loader population.
+drupal_phpunit_populate_class_loader();
 
 // Set sane locale settings, to ensure consistent string, dates, times and
 // numbers handling.
diff --git a/core/themes/bartik/css/components/field.css b/core/themes/bartik/css/components/field.css
index 213d804b0..231f8d761 100644
--- a/core/themes/bartik/css/components/field.css
+++ b/core/themes/bartik/css/components/field.css
@@ -29,6 +29,10 @@
   margin: 0;
   list-style: none;
 }
+/* This is required to win over specificity of [dir="rtl"] .region-content ul */
+[dir="rtl"] .field--type-entity-reference ul.links {
+  padding: 0;
+}
 .field--type-entity-reference ul.links li {
   float: left; /* LTR */
   padding: 0 1em 0 0; /* LTR */
diff --git a/core/themes/classy/README.txt b/core/themes/classy/README.txt
new file mode 100644
index 000000000..a5181239f
--- /dev/null
+++ b/core/themes/classy/README.txt
@@ -0,0 +1,17 @@
+ABOUT CLASSY
+-----------
+
+Classy is a base theme that provides many classes in its markup. For cleaner
+markup (fewer classes), the default Stable base theme can be used instead.
+
+To use Classy as your base theme, set the 'base theme' in your theme's .info.yml
+file to "classy":
+  base theme: classy
+
+See https://www.drupal.org/theme-guide/8/classy for more information on using
+the Classy theme.
+
+ABOUT DRUPAL THEMING
+--------------------
+
+See https://www.drupal.org/theme-guide/8 for more information on Drupal theming.
diff --git a/core/themes/classy/css/components/dialog.css b/core/themes/classy/css/components/dialog.css
index d45d34b1c..179310836 100644
--- a/core/themes/classy/css/components/dialog.css
+++ b/core/themes/classy/css/components/dialog.css
@@ -56,7 +56,7 @@
   top: 48.5%;
   z-index: 1000;
   background-color: #232323;
-  background-image: url(loading-small.gif);
+  background-image: url(../../../../misc/loading-small.gif);
   background-position: center center;
   background-repeat: no-repeat;
   border-radius: 7px;
diff --git a/core/themes/classy/templates/form/container.html.twig b/core/themes/classy/templates/form/container.html.twig
index 3bd88ec25..0da6c388d 100644
--- a/core/themes/classy/templates/form/container.html.twig
+++ b/core/themes/classy/templates/form/container.html.twig
@@ -5,8 +5,10 @@
  *
  * Used for grouped form items. Can also be used as a theme wrapper for any
  * renderable element, to surround it with a <div> and HTML attributes.
- * See the @link forms_api_reference.html Form API reference @endlink for more
- * information on the #theme_wrappers render array property.
+ * See \Drupal\Core\Render\Element\RenderElement for more
+ * information on the #theme_wrappers render array property, and
+ * \Drupal\Core\Render\Element\container for usage of the container render
+ * element.
  *
  * Available variables:
  * - attributes: HTML attributes for the containing element.
diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine
index 4ce0bfca2..f4e18f5f3 100644
--- a/core/themes/engines/twig/twig.engine
+++ b/core/themes/engines/twig/twig.engine
@@ -40,7 +40,7 @@ function twig_init(Extension $theme) {
  *
  * Renders a Twig template.
  *
- * If the Twig debug setting is enabled, HTML comments including _theme() call
+ * If the Twig debug setting is enabled, HTML comments including the theme hook
  * and template file name suggestions will surround the template markup.
  *
  * @param string $template_file
diff --git a/core/themes/stable/README.txt b/core/themes/stable/README.txt
new file mode 100644
index 000000000..a8687a0dd
--- /dev/null
+++ b/core/themes/stable/README.txt
@@ -0,0 +1,26 @@
+
+ABOUT STABLE
+------------
+
+Stable is the default base theme; it provides minimal markup and very few
+CSS classes. If you prefer more structured markup see the Classy base theme.
+
+Stable allows core markup and styling to evolve by functioning as a backwards
+compatibility layer for themes against changes to core markup and CSS. If you
+browse Stable's contents, you will find copies of all the Twig templates and
+CSS files provided by core.
+
+Stable will be used as the base theme if no base theme is set in a theme's
+.info.yml file. To opt out of Stable you can set the base theme to false in
+your theme's .info.yml file (see the warning below before doing this):
+  base theme: false
+
+Warning: Themes that opt out of using Stable as a base theme will need
+continuous maintenance as core changes, so only opt out if you are prepared to
+keep track of those changes and how they affect your theme.
+
+ABOUT DRUPAL THEMING
+--------------------
+
+For more information, see Drupal.org's theming guide.
+https://www.drupal.org/theme-guide/8
diff --git a/core/themes/stable/css/color/color.admin.css b/core/themes/stable/css/color/color.admin.css
index 29b6c00cc..2efe6fd4f 100644
--- a/core/themes/stable/css/color/color.admin.css
+++ b/core/themes/stable/css/color/color.admin.css
@@ -74,6 +74,8 @@ button.color-palette__lock,
   left: -10px;
   direction: ltr;
   text-indent: -9999px;
+  border: 0;
+  outline: 0;
 }
 [dir="rtl"] button.color-palette__lock,
 [dir="rtl"] .color-palette__lock {
diff --git a/core/themes/stable/templates/form/container.html.twig b/core/themes/stable/templates/form/container.html.twig
index 3bd88ec25..0da6c388d 100644
--- a/core/themes/stable/templates/form/container.html.twig
+++ b/core/themes/stable/templates/form/container.html.twig
@@ -5,8 +5,10 @@
  *
  * Used for grouped form items. Can also be used as a theme wrapper for any
  * renderable element, to surround it with a <div> and HTML attributes.
- * See the @link forms_api_reference.html Form API reference @endlink for more
- * information on the #theme_wrappers render array property.
+ * See \Drupal\Core\Render\Element\RenderElement for more
+ * information on the #theme_wrappers render array property, and
+ * \Drupal\Core\Render\Element\container for usage of the container render
+ * element.
  *
  * Available variables:
  * - attributes: HTML attributes for the containing element.
diff --git a/profiles/README.txt b/profiles/README.txt
index 91d012ba2..b0f0c0bac 100644
--- a/profiles/README.txt
+++ b/profiles/README.txt
@@ -1,13 +1,13 @@
 Installation profiles define additional steps that run after the base
-installation provided by Drupal core when Drupal is first installed.
+installation of Drupal is completed. They may also offer additional
+functionality and change the behavior of the site.
 
 WHAT TO PLACE IN THIS DIRECTORY?
 --------------------------------
 
 Place downloaded and custom installation profiles in this directory.
-Installation profiles are generally provided as part of a Drupal distribution.
-They only impact the installation of your site. They do not have any effect on
-an already running site.
+Note that installation profiles are generally provided as part of a Drupal
+distribution.
 
 DOWNLOAD ADDITIONAL DISTRIBUTIONS
 ---------------------------------
diff --git a/sites/example.settings.local.php b/sites/example.settings.local.php
index a5d50f2b7..dfcc24411 100644
--- a/sites/example.settings.local.php
+++ b/sites/example.settings.local.php
@@ -5,10 +5,13 @@
  * Local development override configuration feature.
  *
  * To activate this feature, copy and rename it such that its path plus
- * filename is 'sites/example.com/settings.local.php', where example.com
- * is the name of your site. Then, go to the bottom of
- * 'sites/example.com/settings.php' and uncomment the commented lines that
- * mention 'settings.local.php'.
+ * filename is 'sites/default/settings.local.php'. Then, go to the bottom of
+ * 'sites/default/settings.php' and uncomment the commented lines that mention
+ * 'settings.local.php'.
+ *
+ * If you are using a site name in the path, such as 'sites/example.com', copy
+ * this file to 'sites/example.com/settings.local.php', and uncomment the lines
+ * at the bottom of 'sites/example.com/settings.php'.
  */
 
 /**
diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php
index 5e1469e83..990cfdcfa 100644
--- a/vendor/composer/ClassLoader.php
+++ b/vendor/composer/ClassLoader.php
@@ -13,9 +13,7 @@
 namespace Composer\Autoload;
 
 /**
- * ClassLoader implements a PSR-0 class loader
- *
- * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  *
  *     $loader = new \Composer\Autoload\ClassLoader();
  *
@@ -39,6 +37,8 @@ namespace Composer\Autoload;
  *
  * @author Fabien Potencier <fabien@symfony.com>
  * @author Jordi Boggiano <j.boggiano@seld.be>
+ * @see    http://www.php-fig.org/psr/psr-0/
+ * @see    http://www.php-fig.org/psr/psr-4/
  */
 class ClassLoader
 {
diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php
index 52711f4b9..0e9136e0f 100644
--- a/vendor/composer/autoload_files.php
+++ b/vendor/composer/autoload_files.php
@@ -6,8 +6,8 @@ $vendorDir = dirname(dirname(__FILE__));
 $baseDir = dirname($vendorDir);
 
 return array(
-    $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
-    $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
-    $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
-    $baseDir . '/core/lib/Drupal.php',
+    'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
+    'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
+    '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
+    '454414594637b9dd94a19af83f56f1a2' => $baseDir . '/core/lib/Drupal.php',
 );
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 4bd9987b6..4303fced9 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -41,15 +41,19 @@ class ComposerAutoloaderInitDrupal8
         $loader->register(true);
 
         $includeFiles = require __DIR__ . '/autoload_files.php';
-        foreach ($includeFiles as $file) {
-            composerRequireDrupal8($file);
+        foreach ($includeFiles as $fileIdentifier => $file) {
+            composerRequireDrupal8($fileIdentifier, $file);
         }
 
         return $loader;
     }
 }
 
-function composerRequireDrupal8($file)
+function composerRequireDrupal8($fileIdentifier, $file)
 {
-    require $file;
+    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
+        require $file;
+
+        $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
+    }
 }
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index b58ef9a84..e2b799152 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -2735,69 +2735,6 @@
             "phantomjs"
         ]
     },
-    {
-        "name": "jcalderonzumba/mink-phantomjs-driver",
-        "version": "dev-master",
-        "version_normalized": "9999999-dev",
-        "source": {
-            "type": "git",
-            "url": "https://github.com/jcalderonzumba/MinkPhantomJSDriver.git",
-            "reference": "10d7c48c9a4129463052321b52450d98983c4332"
-        },
-        "dist": {
-            "type": "zip",
-            "url": "https://api.github.com/repos/jcalderonzumba/MinkPhantomJSDriver/zipball/10d7c48c9a4129463052321b52450d98983c4332",
-            "reference": "10d7c48c9a4129463052321b52450d98983c4332",
-            "shasum": ""
-        },
-        "require": {
-            "behat/mink": "~1.6",
-            "jcalderonzumba/gastonjs": "~1.0",
-            "php": ">=5.4",
-            "twig/twig": "~1.8"
-        },
-        "require-dev": {
-            "phpunit/phpunit": "~4.6",
-            "silex/silex": "~1.2",
-            "symfony/css-selector": "~2.1",
-            "symfony/phpunit-bridge": "~2.7",
-            "symfony/process": "~2.3"
-        },
-        "time": "2015-10-05 18:24:44",
-        "type": "mink-driver",
-        "extra": {
-            "branch-alias": {
-                "dev-master": "0.4.x-dev"
-            }
-        },
-        "installation-source": "source",
-        "autoload": {
-            "psr-4": {
-                "Zumba\\Mink\\Driver\\": "src"
-            }
-        },
-        "notification-url": "https://packagist.org/downloads/",
-        "license": [
-            "MIT"
-        ],
-        "authors": [
-            {
-                "name": "Juan Francisco Calderón Zumba",
-                "email": "juanfcz@gmail.com",
-                "homepage": "http://github.com/jcalderonzumba"
-            }
-        ],
-        "description": "PhantomJS driver for Mink framework",
-        "homepage": "http://mink.behat.org/",
-        "keywords": [
-            "ajax",
-            "browser",
-            "headless",
-            "javascript",
-            "phantomjs",
-            "testing"
-        ]
-    },
     {
         "name": "symfony/class-loader",
         "version": "v2.7.6",
@@ -3857,5 +3794,68 @@
             }
         ],
         "description": "Composer plugin to merge multiple composer.json files"
+    },
+    {
+        "name": "jcalderonzumba/mink-phantomjs-driver",
+        "version": "v0.3.1",
+        "version_normalized": "0.3.1.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/jcalderonzumba/MinkPhantomJSDriver.git",
+            "reference": "782892dbea4af7d04024374672b3790b6c008def"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://api.github.com/repos/jcalderonzumba/MinkPhantomJSDriver/zipball/782892dbea4af7d04024374672b3790b6c008def",
+            "reference": "782892dbea4af7d04024374672b3790b6c008def",
+            "shasum": ""
+        },
+        "require": {
+            "behat/mink": "~1.6",
+            "jcalderonzumba/gastonjs": "~1.0",
+            "php": ">=5.4",
+            "twig/twig": "~1.20|~2.0"
+        },
+        "require-dev": {
+            "phpunit/phpunit": "~4.6",
+            "silex/silex": "~1.2",
+            "symfony/css-selector": "~2.1",
+            "symfony/phpunit-bridge": "~2.7",
+            "symfony/process": "~2.3"
+        },
+        "time": "2015-12-04 13:55:02",
+        "type": "mink-driver",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "0.4.x-dev"
+            }
+        },
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "Zumba\\Mink\\Driver\\": "src"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Juan Francisco Calderón Zumba",
+                "email": "juanfcz@gmail.com",
+                "homepage": "http://github.com/jcalderonzumba"
+            }
+        ],
+        "description": "PhantomJS driver for Mink framework",
+        "homepage": "http://mink.behat.org/",
+        "keywords": [
+            "ajax",
+            "browser",
+            "headless",
+            "javascript",
+            "phantomjs",
+            "testing"
+        ]
     }
 ]
diff --git a/vendor/jcalderonzumba/mink-phantomjs-driver/.gitignore b/vendor/jcalderonzumba/mink-phantomjs-driver/.gitignore
new file mode 100644
index 000000000..7df1a0bae
--- /dev/null
+++ b/vendor/jcalderonzumba/mink-phantomjs-driver/.gitignore
@@ -0,0 +1,8 @@
+.idea/*
+vendor/*
+bin/behat
+bin/phantomjs
+bin/phpunit
+composer.lock
+tmp/*
+tests/integration/ScreenShotContext.php
diff --git a/vendor/jcalderonzumba/mink-phantomjs-driver/bin/run-tests.sh b/vendor/jcalderonzumba/mink-phantomjs-driver/bin/run-tests.sh
old mode 100644
new mode 100755
diff --git a/vendor/jcalderonzumba/mink-phantomjs-driver/composer.json b/vendor/jcalderonzumba/mink-phantomjs-driver/composer.json
index 31b4f57a4..e5cbde8e7 100644
--- a/vendor/jcalderonzumba/mink-phantomjs-driver/composer.json
+++ b/vendor/jcalderonzumba/mink-phantomjs-driver/composer.json
@@ -22,7 +22,7 @@
   "require": {
     "php": ">=5.4",
     "behat/mink": "~1.6",
-    "twig/twig": "~1.8",
+    "twig/twig": "~1.20|~2.0",
     "jcalderonzumba/gastonjs": "~1.0"
   },
   "require-dev": {