diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index f366900..330f39c 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -32,6 +32,7 @@ public function __construct(array $values, $entity_type) { parent::__construct($values, $entity_type); // Backup the original ID, if any. + // Configuration entity IDs are strings, and '0' is a valid ID. $original_id = $this->id(); if ($original_id !== NULL && $original_id !== '') { $this->setOriginalID($original_id); @@ -60,6 +61,7 @@ public function setOriginalID($id) { * configuration entity is unique. */ final public function isNew() { + // Configuration entity IDs are strings, and '0' is a valid ID. return !empty($this->enforceIsNew) || $this->id() === NULL || $this->id() === ''; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index eb65f5d..f37acd3 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -225,9 +225,6 @@ public function create(array $values) { $entity = new $class($values, $this->entityType); // Mark this entity as new, so isNew() returns TRUE. This does not check // whether a configuration entity with the same ID (if any) already exists. - // @todo If we expect isNew() to return FALSE when given an ID that exists - // already, wrap this in !config($prefix . $id)->getStorage()->exists(). - // In that case, do we expect existing values to be merged into $values? $entity->enforceIsNew(); // Assign a new UUID if there is none yet. @@ -274,12 +271,14 @@ public function delete($ids) { public function save(EntityInterface $entity) { $prefix = $this->entityInfo['config prefix'] . '.'; + // Configuration entity IDs are strings, and '0' is a valid ID. $id = $entity->id(); if ($id === NULL || $id === '') { throw new EntityMalformedException('The entity does not have an ID.'); } // Load the stored entity, if any. + // At this point, the original ID can only be NULL or a valid ID. if ($entity->getOriginalID() !== NULL) { $id = $entity->getOriginalID(); }