diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 3ce4802..9cc63a3 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -163,13 +163,7 @@ public function finalizePurge(FieldStorageDefinitionInterface $storage_definitio protected function doSave($id, EntityInterface $entity) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ - $is_new = $entity->isNew(); - if (!$is_new) { - // @todo, should a different value be returned when saving an entity with - // $isDefaultRevision = FALSE? - $return = $entity->isDefaultRevision() ? SAVED_UPDATED : FALSE; - } - else { + if ($entity->isNew()) { // Ensure the entity is still seen as new after assigning it an id, while // storing its data. $entity->enforceIsNew(); @@ -178,6 +172,11 @@ protected function doSave($id, EntityInterface $entity) { } $return = SAVED_NEW; } + else { + // @todo Consider returning a different value when saving a non-default + // entity revision. See https://www.drupal.org/node/2509360. + $return = $entity->isDefaultRevision() ? SAVED_UPDATED : FALSE; + } $this->doSaveFieldItems($entity); @@ -188,7 +187,7 @@ protected function doSave($id, EntityInterface $entity) { * Writes entity field values to the storage. * * This method is responsible for allocating entity and revision identifiers - * and update the entity object with their values. + * and updating the entity object with their values. * * @param \Drupal\Core\Entity\ContentEntityInterface $entity * The entity object. @@ -283,7 +282,7 @@ protected function invokeFieldMethod($method, ContentEntityInterface $entity) { foreach (array_keys($entity->getTranslationLanguages()) as $langcode) { $translation = $entity->getTranslation($langcode); foreach ($translation->getFields() as $name => $items) { - // call_user_func_array is way slower than a direct call so we avoid + // call_user_func_array() is way slower than a direct call so we avoid // using it if have no parameters. $result[$langcode][$name] = $args ? call_user_func_array([$items, $method], $args) : $items->{$method}(); } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 07456aa..455f829 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -992,7 +992,7 @@ protected function doSaveFieldItems(ContentEntityInterface $entity, array $names $this->saveToSharedTables($entity); } if ($this->revisionDataTable) { - $new_revision = $full_save ? $entity->isNewRevision() : FALSE; + $new_revision = $full_save && $entity->isNewRevision(); $this->saveToSharedTables($entity, $this->revisionDataTable, $new_revision); } } diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 5605f11..1067ae8 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -244,8 +244,8 @@ protected function delegateMethod($method) { $result = []; $args = array_slice(func_get_args(), 1); foreach ($this->list as $delta => $item) { - // call_user_func_array is way slower than a direct call so we avoid using - // it if have no parameters. + // call_user_func_array() is way slower than a direct call so we avoid + // using it if have no parameters. $result[$delta] = $args ? call_user_func_array([$item, $method], $args) : $item->{$method}(); } return $result;