diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 730aaa2..ae23b04 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -14,6 +14,7 @@ use Drupal\Core\Entity\EntityStorageControllerBase; use Drupal\Core\Config\Config; use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Config\ConfigNameException; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\Query\QueryFactory; @@ -37,6 +38,15 @@ */ class ConfigStorageController extends EntityStorageControllerBase implements ConfigStorageControllerInterface, ImportableEntityStorageInterface { + + /** + * The maximum length of a config entity ID. + * + * @see \Drupal\Core\ConfigBase::MAX_NAME_LENGTH + */ + + const MAX_ID_LENGTH = 166; + /** * The UUID service. * @@ -315,6 +325,18 @@ public function save(EntityInterface $entity) { $entity->{$this->idKey} = $entity->id(); } + /** + * Check config entity id length. + * + * @see \Drupal\Core\Config\Entity\ConfigStorageController::MAX_ID_LENGTH + */ + if (strlen($entity->{$this->idKey}) > self::MAX_ID_LENGTH) { + throw new ConfigNameException(String::format('Config entity machine name (id) @name exceeds maximum allowed length of @length characters.', array( + '@name' => $entity->{$this->idKey}, + '@length' => self::MAX_ID_LENGTH, + ))); + } + $entity->preSave($this); $this->invokeHook('presave', $entity);