Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Summary

#1701014: Validate config object names limits the maximum file name length of a configuration object name to 250 characters.

Now we need to prevent situations where the individual parts of the configuration object filename (plus the periods that separate them) do exceed 250 characters.

The name of a file that contains the details for a configuration entity is composed of 3 parts.

$extension.$identifier.$machine_name

The $machine_name may itself be comprised of components; this complexity is determined by the config entity class that produces the machine name.

Here is the fully-expanded set of possibilities.

                        |------> Machine name - defined by config entity type
{extension}.{identifier}.{target entity type}.{target entity bundle}.{instance name}

In #1709960: declare a maximum length for entity and bundle machine names, the maximum length of entity type and bundle machine names is limited to 32 characters. By limiting the length of these two names, we leave sufficient character space for a config object instance name. Altogether the entity type machine name, bundle machine name and config entity instance name combined character count may not exceed 166 characters (164 with two dots). This total limit was imposed in #2220757: Limit length of Config::$id to something <= 166 characters.

Code examples

Drupal 7

In Drupal 7 a bundle machine name is stored in the type field of a node database recored. This field is a varchar(32), so no special migration will be necessary.

The entity type machine name is limited by the database storage table length maximum, which for MySQL is 64 characters. Consideration during migration will need to be taken.

If you have created custom entity types with custom bundles, you will need to ensure compliance with this limit when migrating from Drupal 7 to Drupal 8.

See #2229209: Restrict entity ID and bundle machine name string length to 32 characters for more information.

Drupal 8

The entity type and bundle machine names are constrained by the following constants.

interface EntityTypeInterface {
 
  /**
   * The maximum length of ID, in characters.
   */
  const ID_MAX_LENGTH = 32;

  /**
   * The maximum length of bundle name, in characters.
   */
  const BUNDLE_MAX_LENGTH = 32;
}

If ID_MAX_LENGTH is exceeded, the following exception is thrown

\Drupal\Core\Entity\Exception\EntityTypeIdLengthException

If BUNDLE_MAX_LENGTH is exceeded, the following exception is thrown

Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException

Related issues

#2120003: [META] Create sensible limits for the maximum length of configuration object filename components
#2220757: Limit length of Config::$id to something <= 166 characters
#1701014: Validate config object names

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done