The architectural concept of drupal_write_record() is obsolete. It should no longer be used.

db_merge() is the direct replacement.

No big news, since db_merge() is the preferred way since D7 already.

CommentFileSizeAuthor
#5 remove-dwr-2194885-5.patch14.45 KBberdir

Comments

nico.pinos’s picture

Assigned: Unassigned » nico.pinos

What about this implementation?

protected function doSave($id, EntityInterface $entity) {
    if (!$entity->isNew()) {
      $return = drupal_write_record($this->entityType->getBaseTable(), $entity, $this->idKey);
      $this->resetCache(array($entity->id()));
    }
    else {
      $return = drupal_write_record($this->entityType->getBaseTable(), $entity);
      // Reset general caches, but keep caches specific to certain entities.
      $this->resetCache(array());
    }

    return $return;
  }

Wouldn't that be db_insert()?

tstoeckler’s picture

Status: Active » Postponed
Related issues: +#2084421: Phase 2 - Decouple book module schema from menu links

So all of the 3 remaining non-test usages in core of drupal_write_record() stem from menu links. Let's postpone this on #2084421: Phase 2 - Decouple book module schema from menu links, which will move menu links to ContentEntityDatabaseStorage, i.e. obsoleting MenuLinkStorage and EntityDatabaseStorage.

Crell’s picture

Status: Postponed » Active

Was that the right issue? That issue has been fixed for months. :-)

nico.pinos’s picture

berdir’s picture

Status: Active » Needs review
StatusFileSize
new14.45 KB

Yep, unused now outside of tests :)

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Beautiful.

chx’s picture

And there was much rejoicing.

Crell’s picture

(yay...)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

As much as I'd love to commit this I think we need a change record for this.

berdir’s picture

Assigned: nico.pinos » Unassigned
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

Yeah, wanted to do that, just wasn't fast enough :)

https://www.drupal.org/node/2340291 good enough?

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3295e62 and pushed to 8.0.x. Thanks!

  • alexpott committed 3295e62 on 8.0.x
    Issue #2194885 by Berdir | sun: Remove drupal_write_record().
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.