diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
index 80a68f6..21990ab 100644
--- a/core/lib/Drupal/Core/Database/Schema.php
+++ b/core/lib/Drupal/Core/Database/Schema.php
@@ -15,6 +15,18 @@
    *
    * @var \Drupal\Core\Database\Connection
    */
+  /**
+   * The maximum allowed length of a database index.
+   *
+   * The MySQL MyISAM storage engine enforces a limit of 1000 bytes, which
+   * corresponds to 333 UTF-8 characters. We enforce this limitation for all
+   * schemata, so that it is not possible to inadvertently declare a schema
+   * that is not compatible with MySQL.
+   *
+   * @see http://dev.mysql.com/doc/refman/5.6/en/myisam-storage-engine.html
+   */
+  const MAX_INDEX_SIZE = 1000;
+
   protected $connection;
 
   /**
@@ -593,6 +605,7 @@ public function createTable($name, $table) {
     if ($this->tableExists($name)) {
       throw new SchemaObjectExistsException(t('Table @name already exists.', ['@name' => $name]));
     }
+    $this->validateTable($name, $table);
     $statements = $this->createTableSql($name, $table);
     foreach ($statements as $statement) {
       $this->connection->query($statement);
@@ -600,6 +613,122 @@ public function createTable($name, $table) {
   }
 
   /**
+   * Validates a table definition.
+   *
+   * @param string $name
+   *   The name of the table.
+   * @param array $table
+   *   A Schema API table definition array.
+   *
+   * @throws Drupal\Core\Database\SchemaIndexSizeException
+   *   If a specified index is too long.
+   *
+   * @see \Drupal\Core\Database\Schema::addIndex()
+   */
+  public function validateTable($name, array $table) {
+    $spec = array_intersect_key($table, array('unique keys' => 1, 'indexes' => 1));
+    if (isset($table['primary key'])) {
+      $spec['primary key'] = array('primary key' => $table['primary key']);
+    }
+    foreach ($spec as $type => $keys) {
+      foreach ($keys as $key_name => $fields) {
+        $size = 0;
+        foreach ($fields as $field) {
+          $size += $this->indexSize($table, $field);
+        }
+        if ($size > static::MAX_INDEX_SIZE) {
+          throw new SchemaIndexSizeException(format_string('Table index @key_name for @table_name exceeds the maximum allowed size. (size = @size, max = @max)', array('@key_name' => $key_name, '@table_name' => $name, '@size' => $size, '@max' => static::MAX_INDEX_SIZE)));
+        }
+      }
+    }
+  }
+
+  /**
+   * Returns the index length to reserve when validating a given field.
+   *
+   * @param array $table
+   *   The database table definition array from hook_schema().
+   * @param array|string $field
+   *   The database index field item from hook_schema().
+   *
+   * @return int.
+   *   The size to allot for the field in the index, in bytes. For fields that
+   *   are too large to include in an index, Schema::MAX_INDEX_SIZE  1 is
+   *   returned instead.
+   */
+  protected function indexSize($table, $field) {
+    // Default to 0, so that custom field types are not counted.
+    $size = 0;
+
+    // If just the field name is provided, the whole field is used for
+    // the index, so add its total length.
+    if (is_string($field)) {
+      // For fields with a specified length, use that.
+      if (isset($table['fields'][$field]['length'])) {
+        // Each unicode character uses 3 bytes.
+        $size = 3 * $table['fields'][$field]['length'];
+      }
+      // For fields without a specified length, allot space based on the
+      // field type's size in MySQL.
+      // @see http://drupal.org/node/159605
+      else {
+        switch ($table['fields'][$field]['type']) {
+          case 'serial':
+          case 'int':
+          case 'float':
+            // If the field type is serial, int, or float, allot 8 bytes for
+            // 'big' field sizes and 4 for others..
+            if (!empty($field['size']) && $field['size'] == 'big') {
+              $size = 8;
+            }
+            else {
+              $size = 4;
+            }
+            break;
+
+          case 'numeric':
+            // If the field type is numeric, allot 29 bytes.
+            $size = 29;
+            break;
+
+          case 'char':
+            // If the field type is char, allot 255 bytes.
+            $size = 255;
+            break;
+
+          case 'char':
+            // If the field type is text, allot 256 bytes for tiny or small
+            // fields, and fail otherwise.
+            if (!empty($field['size']) && ($field['size'] == 'tiny' || $field['size'] == 'small')) {
+              $size = 256;
+            }
+            else {
+              // Larger sizes are too big for an index.
+              $size = static::MAX_INDEX_SIZE + 1;
+            }
+            break;
+
+          case 'blob':
+          case 'varchar':
+            // BLOBs and unlimited varchars are always too big.
+            $size = static::MAX_INDEX_SIZE  1;
+            break;
+        }
+      }
+    }
+
+    // Otherwise, if the field is an array, then the first key of the
+    // array is the field name, and the second is the length used in the
+    // index, e.g. array('my_field', 64)
+    // See \Drupal\Core\Database\Driver\mysql\Schema::createKeySql().
+    else {
+      $size = $field[1];
+    }
+
+    return $size;
+  }
+
+  /**
    * Return an array of field names from an array of key/index column specifiers.
    *
    * This is usually an identity function but if a key/index uses a column prefix
diff --git a/core/lib/Drupal/Core/Database/SchemaIndexSizeException.php b/core/lib/Drupal/Core/Database/SchemaIndexSizeException.php
new file mode 100644
index 0000000..cbc82d2
--- /dev/null
+++ b/core/lib/Drupal/Core/Database/SchemaIndexSizeException.php
@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\Core\Database\SchemaIndexSizeException.
+ */
+
+namespace Drupal\Core\Database;
+
+/**
+ * Exception thrown if a schema contains an index that is too long.
+ *
+ * @see Drupal\Core\Database\Schema::MAX_INDEX_LENGTH
+ */
+class SchemaIndexSizeException extends SchemaException implements DatabaseException { }
\ No newline at end of file
diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
index 05ac9b9..9231681 100644
--- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
+++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
@@ -137,7 +137,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
         '#title' => $this->t('View arguments'),
         '#default_value' => $default,
         '#required' => FALSE,
-        '#description' => $this->t('Provide a comma separated list of arguments to pass to the view.'),
+        '#description' => t('Provide a comma separated list of arguments to pass to the view.')  . '<br />' . t('This field supports tokens.'),
       ];
     }
     else {
@@ -213,7 +213,7 @@ protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $
   public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
     $handler_settings = $this->configuration['handler_settings'];
     $display_name = $handler_settings['view']['display_name'];
-    $arguments = $handler_settings['view']['arguments'];
+    $arguments = $this->handleArgs($handler_settings['view']['arguments']);
     $result = [];
     if ($this->initializeView($match, $match_operator, $limit)) {
       // Get the results.
@@ -244,7 +244,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON
   public function validateReferenceableEntities(array $ids) {
     $handler_settings = $this->configuration['handler_settings'];
     $display_name = $handler_settings['view']['display_name'];
-    $arguments = $handler_settings['view']['arguments'];
+    $arguments = $this->handleArgs($handler_settings['view']['arguments']);
     $result = [];
     if ($this->initializeView(NULL, 'CONTAINS', 0, $ids)) {
       // Get the results.
@@ -288,4 +288,32 @@ public static function settingsFormValidate($element, FormStateInterface $form_s
    */
   public function entityQueryAlter(SelectInterface $query) { }
 
+  /**
+   * Handles replacing tokens in arguments for views.
+   *
+   * Replaces tokens using Token::replace.
+   *
+   * @param array $args
+   *   An array of arguments that may contain tokens.
+   *
+   * @return array
+   *   The arguments to be sent to the View.
+   */
+  protected function handleArgs($args) {
+    $token_service = \Drupal::token();
+    $options = array(
+      'clear' => TRUE,
+    );
+
+    $data = array();
+    if ($this->configuration['entity']) {
+     $data = array($this->configuration['entity']->getEntityTypeId() => $this->configuration['entity']);
+    }
+
+    // Replace tokens for each argument.
+    foreach ($args as $key => $arg) {
+      $args[$key] = $token_service->replace($arg, $data, $options);
+    }
+    return $args;
+  }
 }
