Delete a single revision of field data for an entity.
This hook is invoked from field_attach_delete_revision() to ask the field storage module to delete field revision data.
Deleting the current (most recently written) revision is not allowed as has undefined results.
\Drupal\Core\Entity\EntityInterface $entity: The entity on which to operate.
$fields: An array listing the fields to delete. The keys and values of the array are field UUIDs.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_field_storage_delete_revision(\Drupal\Core\Entity\EntityInterface $entity, $fields) {
$vid = $entity
->getRevisionId();
if (isset($vid)) {
foreach ($fields as $field_id) {
$field = field_info_field_by_id($field_id);
$revision_name = _field_sql_storage_revision_tablename($field);
db_delete($revision_name)
->condition('entity_type', $entity_type)
->condition('entity_id', $entity
->id())
->condition('revision_id', $vid)
->execute();
}
}
}