Commit fdcf3021 authored by jurgenhaas's avatar jurgenhaas
Browse files

Add fix to the MR which currently only contains the test

parent 5706a723
...@@ -396,13 +396,19 @@ function editor_entity_update(EntityInterface $entity) { ...@@ -396,13 +396,19 @@ function editor_entity_update(EntityInterface $entity) {
// File references that existed both in the previous version of the revision // File references that existed both in the previous version of the revision
// and in the new one don't need their usage to be updated. // and in the new one don't need their usage to be updated.
else { else {
$original_uuids_by_field = _editor_get_file_uuids_by_field($entity->original); $original_uuids_by_field = empty($entity->original) ? [] :
_editor_get_file_uuids_by_field($entity->original);
$uuids_by_field = _editor_get_file_uuids_by_field($entity); $uuids_by_field = _editor_get_file_uuids_by_field($entity);
// Detect file usages that should be incremented. // Detect file usages that should be incremented.
foreach ($uuids_by_field as $field => $uuids) { foreach ($uuids_by_field as $field => $uuids) {
$added_files = array_diff($uuids_by_field[$field], $original_uuids_by_field[$field]); $original_uuids = isset($original_uuids_by_field[$field]) ?
_editor_record_file_usage($added_files, $entity); $original_uuids_by_field[$field] : [];
if ($added_files = array_diff($uuids_by_field[$field], $original_uuids)) {
_editor_record_file_usage($added_files, $entity);
}
} }
// Detect file usages that should be decremented. // Detect file usages that should be decremented.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment