Score:0

How to make a traditional entity field excluded from revision?

mx flag
awm

Is it possible to make an entity field excluded from revision? I want to avoid creating revision table for the field if possible. Otherwise, just excluding creating revisions is fine.

I tried to alter the field definition in code:

function mymodule_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'node' && isset($fields['field_my_field'])) {
    $fields['field_my_field']->setDisplayConfigurable('view', TRUE);
    $fields['field_my_field']->setDisplayConfigurable('form', TRUE);
    $fields['field_my_field']->setRevisionable(FALSE);
  }

But got an errro that setRevisionable does not exist. I looked further and found that drupal core has the following:

/**
   * {@inheritdoc}
   */
  public function isRevisionable() {
    // All configurable fields are revisionable.
    return TRUE;
  }

Does this mean we can no longer alter this property on a field added via the UI?

Jaypan avatar
de flag
'Revisionable' is a property that can only be set on base fields, not on fields defined in configuration (aka through the UI). As far as I know it's not 'no longer', and this could never be done on fields defined in configuration.
awm avatar
mx flag
awm
I think this is a duplicate of https://drupal.stackexchange.com/questions/294720/define-fields-created-through-the-ui-as-non-revisionable-on-a-revisionable-entit
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.