diff --git a/core/includes/menu.inc b/core/includes/menu.inc index c1d4787..46cedbc 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -823,6 +823,8 @@ function menu_link_rebuild_defaults() { $link['customized'] = $existing_item->customized; $link['updated'] = $existing_item->updated; $menu_link = $menu_link_storage->createFromDefaultLink($link); + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 $menu_link->setOriginalId($existing_item->mlid); // Convert the existing item to a typed object. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 6c604ee..73da4df 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1281,8 +1281,10 @@ function comment_prepare_author(CommentInterface $comment) { // The account has been pre-loaded by CommentViewBuilder::buildContent(). $account = $comment->getOwner(); if (empty($account->uid->value)) { + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 $account = entity_create('user', array('uid' => 0, 'name' => $comment->getAuthorName(), 'homepage' => $comment->getHomepage())); - // The anonymous user is not a new account, do not try to save it as one. + // The anonymous user is not a new account, do not treat it as one. $account->enforceIsNew(FALSE); } return $account; diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 2ad5175..59a6ca8 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -173,6 +173,8 @@ function file_copy(File $source, $destination = NULL, $replace = FILE_EXISTS_REN $file->setFileUri($uri); $file->setFilename(drupal_basename($uri)); // If we are replacing an existing file re-use its database record. + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 if ($replace == FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri)); if (count($existing_files)) { @@ -522,6 +524,8 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM 'status' => FILE_STATUS_PERMANENT, )); // If we are replacing an existing file re-use its database record. + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 if ($replace == FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri)); if (count($existing_files)) { @@ -949,6 +953,8 @@ function file_save_upload($form_field_name, $validators = array(), $destination drupal_chmod($file->getFileUri()); // If we are replacing an existing file re-use its database record. + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 if ($replace == FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $file->getFileUri())); if (count($existing_files)) { diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index 6a5990a..99f61dd 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -368,6 +368,8 @@ public function reset() { $original['machine_name'] = $this->machine_name; /** @var \Drupal\menu_link\MenuLinkStorageInterface $storage */ $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 $new_link = $storage->createFromDefaultLink($original); $new_link->setOriginalId($this->id()); // Allow the menu to be determined by the parent diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index b9b76db..d890237 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -566,6 +566,8 @@ function menu_ui_node_submit(EntityInterface $node, $form, $form_state) { if (!empty($form_state['values']['menu'])) { $original_menu_id = !empty($node->menu) ? $node->menu->id() : NULL; $node->menu = entity_create('menu_link', $form_state['values']['menu']); + // @todo Do not create a new entity in order to update it, see + // https://drupal.org/node/2241865 // If this menu had a previous menu link associated, mark it as not new. if ($original_menu_id) { $node->menu->setOriginalId($original_menu_id);